Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: remove explicit linker call to libm on macOS #56901

Closed
wants to merge 2 commits into from

Conversation

deepak1556
Copy link
Contributor

/usr/lib/libm.tbd is available via libSystem.*.dylib and reexports sanitizer symbols. When building for asan or other sanitizers 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 linker 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.

After:

% nm -m ./out/Release/node | grep asan_get_shadow_mapping
                 (undefined) external ___asan_get_shadow_mapping (from libclang_rt.asan_osx_dynamic)

Fixes #55583

/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.
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added brotli Issues and PRs related to the brotli dependency. dependencies Pull requests that update a dependency file. libuv Issues and PRs related to the libuv dependency or the uv binding. needs-ci PRs that need a full CI run. labels Feb 3, 2025
@codebytere codebytere self-requested a review February 3, 2025 14:54
deps/uv/unofficial.gni Show resolved Hide resolved
@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 3, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 3, 2025
@nodejs-github-bot
Copy link
Collaborator

@lpinca lpinca added the commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. label Feb 3, 2025
@nodejs-github-bot
Copy link
Collaborator

@legendecas legendecas added the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 7, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 7, 2025
@nodejs-github-bot
Copy link
Collaborator

Landed in c0953d9...b7ce941

nodejs-github-bot pushed a commit that referenced this pull request Feb 7, 2025
/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>
nodejs-github-bot pushed a commit that referenced this pull request Feb 7, 2025
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
brotli Issues and PRs related to the brotli dependency. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. dependencies Pull requests that update a dependency file. libuv Issues and PRs related to the libuv dependency or the uv binding. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ASAN build does not work
6 participants