diff --git a/patches/node/.patches b/patches/node/.patches index ab5a502c4c92..f5296ff5e7a5 100644 --- a/patches/node/.patches +++ b/patches/node/.patches @@ -39,4 +39,5 @@ test_use_static_method_names_in_call_stacks.patch build_use_third_party_simdutf.patch fix_remove_fastapitypedarray_usage.patch test_handle_explicit_resource_management_globals.patch +build_remove_explicit_linker_call_to_libm_on_macos.patch linux_try_preadv64_pwritev64_before_preadv_pwritev_4683.patch diff --git a/patches/node/build_remove_explicit_linker_call_to_libm_on_macos.patch b/patches/node/build_remove_explicit_linker_call_to_libm_on_macos.patch new file mode 100644 index 000000000000..7ef14abffde5 --- /dev/null +++ b/patches/node/build_remove_explicit_linker_call_to_libm_on_macos.patch @@ -0,0 +1,59 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: deepak1556 +Date: Mon, 3 Feb 2025 21:44:36 +0900 +Subject: build: remove explicit linker call to libm on macOS + +/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: https://github.com/nodejs/node/pull/56901 +Reviewed-By: Joyee Cheung +Reviewed-By: Chengzhong Wu +Reviewed-By: Luigi Pinca +Reviewed-By: Shelley Vohr + +diff --git a/deps/brotli/unofficial.gni b/deps/brotli/unofficial.gni +index 5e07e106672a04508a77584c109c97a67926c858..91001fa43ea4807d061f296eaeccb7512e34863e 100644 +--- a/deps/brotli/unofficial.gni ++++ b/deps/brotli/unofficial.gni +@@ -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) { +diff --git a/deps/uv/unofficial.gni b/deps/uv/unofficial.gni +index 7a73f891e3fc3261b77af97af63fca2eade49849..bda1b5dc899558c2b4a22377dde9fb3bcce5488c 100644 +--- a/deps/uv/unofficial.gni ++++ b/deps/uv/unofficial.gni +@@ -82,11 +82,11 @@ template("uv_gn_build") { + ] + } + if (is_posix) { +- libs = [ "m" ] + ldflags = [ "-pthread" ] + } + if (is_linux) { +- libs += [ ++ libs = [ ++ "m", + "dl", + "rt", + ]