Skip to content

Commit e5b90cd

Browse files
committed
build: Don't add -latomic for clang
compiler-rt supports `__atomic_is_lock_free` since LLVM 12[0]. Requiring `-latomic` on clang builds introduces a dependency on libgcc, which is often undesirable on LLVM-based build environments. This change makes sure it's never added in clang builds, so it can use the compiler-rt's implementation, making it possible to build Node.js on Linux systems with LLVM as the main toolchain, without having to install GCC. compiler-rt's `__atomic_is_lock_free` works on all architectures, so there is no need to to link libatomic for mips64, ppc, arm, riscv etc. as well, as long as clang is used. Similar patch was already adopted or discussed in: * Chimera Linux * https://github.com/chimera-linux/cports/blob/master/contrib/nodejs/patches/no-libatomic.patch * Gentoo (LLVM profiles) * https://bugs.gentoo.org/869992 * https://bugs.gentoo.org/911340 * gentoo/gentoo#33141 [0] llvm/llvm-project@00530de
1 parent 90d91ab commit e5b90cd

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

node.gyp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,6 @@
508508
'-Wl,-bnoerrmsg',
509509
],
510510
}],
511-
['OS=="linux" and clang==1', {
512-
'libraries': ['-latomic'],
513-
}],
514511
],
515512
},
516513

tools/v8_gypfiles/v8.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@
12451245
}],
12461246
# Platforms that don't have Compare-And-Swap (CAS) support need to link atomic library
12471247
# to implement atomic memory access
1248-
['v8_current_cpu in ["mips64", "mips64el", "ppc", "arm", "riscv64", "loong64"]', {
1248+
['clang==0 and v8_current_cpu in ["mips64", "mips64el", "ppc", "arm", "riscv64", "loong64"]', {
12491249
'link_settings': {
12501250
'libraries': ['-latomic', ],
12511251
},

0 commit comments

Comments
 (0)