aboutsummaryrefslogtreecommitdiff
path: root/src/linker.cpp
diff options
context:
space:
mode:
authorPatrick Cleavelin <patrick@uptrainsoftware.com>2024-01-27 14:12:19 -0600
committerGitHub <noreply@github.com>2024-01-27 14:12:19 -0600
commit7b9ea9eca02bf5dd295439a46ed6103a0c4a44ff (patch)
tree680a3214623087a395f66c11ddf5b6201d099bd7 /src/linker.cpp
parent59aa05170d54edff75aed220bb1653fc369573d7 (diff)
parentda6edb3764b735a839acdd375328574833d782c1 (diff)
Merge branch 'odin-lang:master' into master
Diffstat (limited to 'src/linker.cpp')
-rw-r--r--src/linker.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/linker.cpp b/src/linker.cpp
index 7fec11ad3..b8909ac6a 100644
--- a/src/linker.cpp
+++ b/src/linker.cpp
@@ -233,7 +233,6 @@ gb_internal i32 linker_stage(LinkerData *gen) {
String windows_sdk_bin_path = path_to_string(heap_allocator(), build_context.build_paths[BuildPath_Win_SDK_Bin_Path]);
defer (gb_free(heap_allocator(), windows_sdk_bin_path.text));
- char const *subsystem_str = build_context.use_subsystem_windows ? "WINDOWS" : "CONSOLE";
if (!build_context.use_lld) { // msvc
String res_path = {};
defer (gb_free(heap_allocator(), res_path.text));
@@ -265,14 +264,14 @@ gb_internal i32 linker_stage(LinkerData *gen) {
result = system_exec_command_line_app("msvc-link",
"\"%.*slink.exe\" %s %.*s -OUT:\"%.*s\" %s "
- "/nologo /incremental:no /opt:ref /subsystem:%s "
+ "/nologo /incremental:no /opt:ref /subsystem:%.*s "
"%.*s "
"%.*s "
"%s "
"",
LIT(vs_exe_path), object_files, LIT(res_path), LIT(output_filename),
link_settings,
- subsystem_str,
+ LIT(build_context.ODIN_WINDOWS_SUBSYSTEM),
LIT(build_context.link_flags),
LIT(build_context.extra_linker_flags),
lib_str
@@ -283,14 +282,14 @@ gb_internal i32 linker_stage(LinkerData *gen) {
} else { // lld
result = system_exec_command_line_app("msvc-lld-link",
"\"%.*s\\bin\\lld-link\" %s -OUT:\"%.*s\" %s "
- "/nologo /incremental:no /opt:ref /subsystem:%s "
+ "/nologo /incremental:no /opt:ref /subsystem:%.*s "
"%.*s "
"%.*s "
"%s "
"",
LIT(build_context.ODIN_ROOT), object_files, LIT(output_filename),
link_settings,
- subsystem_str,
+ LIT(build_context.ODIN_WINDOWS_SUBSYSTEM),
LIT(build_context.link_flags),
LIT(build_context.extra_linker_flags),
lib_str
@@ -484,6 +483,17 @@ gb_internal i32 linker_stage(LinkerData *gen) {
defer (gb_string_free(platform_lib_str));
if (build_context.metrics.os == TargetOs_darwin) {
platform_lib_str = gb_string_appendc(platform_lib_str, "-Wl,-syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/usr/local/lib");
+
+ // Homebrew's default library path, checking if it exists to avoid linking warnings.
+ if (gb_file_exists("/opt/homebrew/lib")) {
+ platform_lib_str = gb_string_appendc(platform_lib_str, " -L/opt/homebrew/lib");
+ }
+
+ // MacPort's default library path, checking if it exists to avoid linking warnings.
+ if (gb_file_exists("/opt/local/lib")) {
+ platform_lib_str = gb_string_appendc(platform_lib_str, " -L/opt/local/lib");
+ }
+
#if defined(GB_SYSTEM_OSX)
if(!build_context.no_crt) {
platform_lib_str = gb_string_appendc(platform_lib_str, " -lm ");