build error: unable to find library -latomic (llvm/compiler-rt)
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.4k
- 平均合并
- 4 天 3 小时
- 30 天内合并 PR
- 272
描述
Version
b949c28b7957f913bfbf042e6b07a22af59f1f3f
Platform
Linux aarch64-unknown-linux-musl 7.2.3-gentoo-dist-hardened #1 SMP PREEMPT_DYNAMIC Sat Sep 5 05:15:30 CEST 2026 aarch64 GNU/Linux
llvm stack (clang, libcxx, compiler-rt, libunwind)
Subsystem
No response
What steps will reproduce the bug?
$ ./configure
$ make
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
build succeeds
What do you see instead?
ld.lld: error: unable to find library -latomic
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [node_js2c.target.mk:144: /home/pepper/dev/ghrepos/node/out/Release/node_js2c] Error 1
make: *** [Makefile:145: node] Error 2
Additional information
This comment in tools/v8_gypfiles/v8.gyp suggests, that -latomic was added to facilitate the use of atomic operations as described in the linked clang docs:
# 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"])', {
But the docs also state that compiler-rt (LLVM) or libatomic (GNU) may be used. -latomic requests libatomic while atomics from compiler-rt can be used without linker settings.
Current behaviour
The builds adds -latomic which unconditionally requests to link libatomic even in cases when it is not needed or desired.
Desired behaviour
Check if -latomic is needed e.g. like mesa meson.build, which checks if atomics compile successfully without link settings (which is the case with compiler-rt). Then append them conditionally only when needed.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 tools/v8_gypfiles/v8.gyp 中被引用的 atomic-library 条件附近开始,然后在报告的 Linux aarch64 musl 设置上使用 ./configure 和 make 复现问题。将现有的 -latomic 处理方式与链接的 Mesa 方法进行比较,并验证 node_js2c 构建能够在没有不可用库的情况下成功,同时在需要时仍然链接该库。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, linux
- 领域
- build-system
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 58/100