Skip to content

Commit

Permalink
build: remove explicit linker call to libm on macOS
Browse files Browse the repository at this point in the history
/usr/lib/libm.tbd is available via libSystem.*.dylib and
reexports sanitizer symbols. When building for asan
this becomes an issue as the linker will resolve the symbols
from the system library rather from libclang_rt.*

For V8 that rely on specific version of these symbols
that get bundled as part of clang, for ex:
https://source.chromium.org/chromium/chromium/src/+/main:v8/src/heap/cppgc/platform.cc;l=93-97
accepting nullptr for shadow_offset in `asan_get_shadow_mapping`,
linking to system version that doesn't support this will lead to
a crash.

Clang driver eventually links with `-lSystem`
https://github.com/llvm/llvm-project/blob/e82f93890daefeb38fe2a22ee3db87a89948ec57/clang/lib/Driver/ToolChains/Darwin.cpp#L1628-L1631,
this is done after linking the sanitizer libraries which
ensures right order of resolution for the symbols.

PR-URL: #56901
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
deepak1556 authored and nodejs-github-bot committed Feb 7, 2025
1 parent c0953d9 commit 756a242
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion deps/brotli/unofficial.gni
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ template("brotli_gn_build") {
} else if (target_os == "freebsd") {
defines = [ "OS_FREEBSD" ]
}
if (!is_win) {
if (is_linux) {
libs = [ "m" ]
}
if (is_clang || !is_win) {
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/unofficial.gni
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ template("uv_gn_build") {
]
}
if (is_posix) {
libs = [ "m" ]
ldflags = [ "-pthread" ]
}
if (is_linux) {
libs += [
"m",
"dl",
"rt",
]
Expand Down

0 comments on commit 756a242

Please sign in to comment.