nodejs / nodejs/node

build error: unable to find library -latomic (llvm/compiler-rt)

Open
#65,900 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tools/v8_gypfiles/v8.gyp around the referenced atomic-library condition, then reproduce with ./configure and make on the reported Linux aarch64 musl setup. Compare the existing -latomic handling with the linked Mesa approach and verify that the node_js2c build succeeds without an unavailable library while still linking it when required.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, linux
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.