diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-05-22 16:04:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-22 16:04:42 +0100 |
| commit | c383e550f9da373631bea702c4614f62eb7ad804 (patch) | |
| tree | add4106cbde3d52df97cef761622a0719ded61a6 /src/linker.cpp | |
| parent | ea65a7b870736311747c517970df3921d227e024 (diff) | |
| parent | 93d2e6aca2c771477b133af0decfefa3eb607ab9 (diff) | |
Merge branch 'master' into bill/raddebugger-custom-section
Diffstat (limited to 'src/linker.cpp')
| -rw-r--r-- | src/linker.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/linker.cpp b/src/linker.cpp index ec165ef7d..41d4a13a1 100644 --- a/src/linker.cpp +++ b/src/linker.cpp @@ -769,7 +769,17 @@ try_cross_linking:; gbString platform_lib_str = gb_string_make(heap_allocator(), ""); 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 "); + // Get the MacOSX SDK path. + gbString darwin_sdk_path = gb_string_make(temporary_allocator(), ""); + if (!system_exec_command_line_app_output("xcrun --sdk macosx --show-sdk-path", &darwin_sdk_path)) { + darwin_sdk_path = gb_string_set(darwin_sdk_path, "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"); + } else { + // Trim the trailing newline. + darwin_sdk_path = gb_string_trim_space(darwin_sdk_path); + } + platform_lib_str = gb_string_append_fmt(platform_lib_str, "--sysroot %s ", darwin_sdk_path); + + platform_lib_str = gb_string_appendc(platform_lib_str, "-L/usr/local/lib "); // Homebrew's default library path, checking if it exists to avoid linking warnings. if (gb_file_exists("/opt/homebrew/lib")) { @@ -791,6 +801,9 @@ try_cross_linking:; // This points the linker to where the entry point is link_settings = gb_string_appendc(link_settings, "-e _main "); } + } else if (build_context.metrics.os == TargetOs_freebsd) { + // FreeBSD pkg installs third-party shared libraries in /usr/local/lib. + platform_lib_str = gb_string_appendc(platform_lib_str, "-Wl,-L/usr/local/lib "); } else if (build_context.metrics.os == TargetOs_openbsd) { // OpenBSD ports install shared libraries in /usr/local/lib. Also, we must explicitly link libpthread. platform_lib_str = gb_string_appendc(platform_lib_str, "-lpthread -Wl,-L/usr/local/lib "); |