diff options
| author | Vincent Billet <vingtsang.billet@gmail.com> | 2025-05-26 08:16:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-26 08:16:45 +0200 |
| commit | bb274ab512c6f379930643853c90f3ae7fa03f7e (patch) | |
| tree | 3737c8dbbdf8e116553cbafcfe70942985328b18 /src/linker.cpp | |
| parent | 1ed05c2498325c97fd6d2856a6a190ab7e5820fc (diff) | |
| parent | 655fab7227fbd92837c82fdbeea65c9121b0f70b (diff) | |
Merge branch 'odin-lang:master' into badaxis/Windows-Audio&Winmm
Diffstat (limited to 'src/linker.cpp')
| -rw-r--r-- | src/linker.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/linker.cpp b/src/linker.cpp index 087bb49f1..447d66d0a 100644 --- a/src/linker.cpp +++ b/src/linker.cpp @@ -801,6 +801,21 @@ 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) { + if (build_context.sanitizer_flags & (SanitizerFlag_Address | SanitizerFlag_Memory)) { + // It's imperative that `pthread` is linked before `libc`, + // otherwise ASan/MSan will be unable to call `pthread_key_create` + // because FreeBSD's `libthr` implementation of `pthread` + // needs to replace the relevant stubs first. + // + // (Presumably TSan implements its own `pthread` interface, + // which is why it isn't required.) + // + // See: https://reviews.llvm.org/D39254 + platform_lib_str = gb_string_appendc(platform_lib_str, "-lpthread "); + } + // 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 "); |