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
2 changes: 1 addition & 1 deletion node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@
],
}],
['OS=="linux" and clang==1', {
'libraries': ['-latomic'],
'libraries': ['<!@(clang++ -print-file-name=libatomic.a)'],
}],
],
},
Expand Down
8 changes: 7 additions & 1 deletion tools/v8_gypfiles/v8.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -1397,11 +1397,17 @@
# 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" or clang!=1) and (v8_current_cpu in ["mips64", "mips64el", "arm", "riscv64", "loong64"])', {
'link_settings': {
'libraries': ['-latomic', ],
},
}],
# Statically link libatomic for Linux Clang builds
['OS=="linux" and clang==1', {
'link_settings': {
'libraries': ['<!@(clang++ -print-file-name=libatomic.a)', ],

@legendecas legendecas Nov 9, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not hardcode clang++ in the gyp file. The library should be resolved in configure.gyp with CXX compiler like:

if is_clang and flavor == 'linux':
  p = subprocess.check_output(shlex.split(CXX) + ['-print-file-name=libatomic.a']).decode().strip()
  if os.path.isabs(p):
    o['variables']['libatomic'] = p
  else:
    warn('libatomic.a not found; node will depend on libatomic.so.1 at runtime')
    o['variables']['libatomic'] = '-latomic'

And use it like:

'libraries': ['<(libatomic)'].

},
}],
['node_shared_abseil=="false"', {
'dependencies': ['abseil.gyp:abseil'],
}],
Expand Down
Loading