build error: unable to find library -latomic (llvm/compiler-rt)
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.3k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 283
説明
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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、参照されている atomic-library の条件付近にある tools/v8_gypfiles/v8.gyp から始め、報告された Linux aarch64 musl のセットアップで ./configure と make を使って再現します。既存の -latomic の扱いをリンク先の Mesa のアプローチと比較し、利用できないライブラリなしで node_js2c のビルドが成功する一方、必要な場合には引き続きそのライブラリがリンクされることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, linux
- 領域
- build-system
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 活発
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 58/100