Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
build: add arg to disable linking against -latomic
building using `clang` with `compiler-rt` fails with an error due to
`-latomic` being added even when it is not needed:
```
ld.lld: error: unable to find library -latomic
```

Ideally, the build would run a link test to determine if `-latomic`
is needed and does not add `-latomic`,  when the compiler runtime
provides atomic builtin. This workaround adds `--without_libatomic`
to manually disable `-latomic`.

Bug: #65900
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
  • Loading branch information
peppergrayxyz committed Sep 10, 2026
commit 5922b57f19ecac68dd4a39d61d70b66a18e3492e
3 changes: 3 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ may reduce build time. For more information, see the
The above requires that `python` resolves to a supported version of
Python. See [Prerequisites](#prerequisites).

> Note: When the compiler runtime provides atomic builtins, such as with compiler-rt (llvm),
> passing `--without-libatomic` disables linking against `libatomic` (`-latomic`).

After building, setting up [firewall rules](tools/macos-firewall.sh) can avoid
popups asking to accept incoming network connections when running tests.

Expand Down
1 change: 1 addition & 0 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'force_dynamic_crt%': 0,
'node_use_v8_platform%': 'true',
'node_use_bundled_v8%': 'true',
'node_use_libatomic%': 'true',
'node_module_version%': '',
'node_with_ltcg%': '',
'node_shared_openssl%': 'false',
Expand Down
8 changes: 8 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,13 @@
default=None,
help='build without FFI (Foreign Function Interface) support')

parser.add_argument('--without-libatomic', '--without_libatomic',
action='store_true',
dest='without_libatomic',
default=None,
help='do not link against libatomic when the compiler runtime ' +
'provides atomic builtins (e.g. compiler-rt)')

parser.add_argument('--experimental-quic',
action='store_true',
dest='experimental_quic',
Expand Down Expand Up @@ -1907,6 +1914,7 @@ def configure_node(o):
o['variables']['node_install_corepack'] = b(options.with_corepack)
o['variables']['control_flow_guard'] = b(options.enable_cfg)
o['variables']['node_use_amaro'] = b(not options.without_amaro)
o['variables']['node_use_libatomic'] = b(not options.without_libatomic)
o['variables']['debug_node'] = b(options.debug_node)
o['variables']['debug_symbols'] = b(options.debug_symbols)
if options.debug_symbols:
Expand Down
2 changes: 1 addition & 1 deletion node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@
'-Wl,-bnoerrmsg',
],
}],
['OS=="linux" and clang==1', {
['OS=="linux" and clang==1 and node_use_libatomic=="true"', {
'libraries': ['-latomic'],
}],
],
Expand Down
2 changes: 1 addition & 1 deletion tools/v8_gypfiles/v8.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@
# Platforms that don't have Compare-And-Swap (CAS) support need to link atomic library
# to implement atomic memory access.
# Clang needs it for some atomic operations (https://clang.llvm.org/docs/Toolchain.html#atomics-library).
['(OS=="linux" and clang==1) or (v8_current_cpu in ["mips64", "mips64el", "arm", "riscv64", "loong64"])', {
['((OS=="linux" and clang==1) or (v8_current_cpu in ["mips64", "mips64el", "arm", "riscv64", "loong64"])) and node_use_libatomic=="true"', {
'link_settings': {
'libraries': ['-latomic', ],
},
Expand Down
Loading