Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lld fails to build on targets that need -latomic #46467

Closed
cuviper opened this issue Aug 11, 2020 · 5 comments
Closed

lld fails to build on targets that need -latomic #46467

cuviper opened this issue Aug 11, 2020 · 5 comments
Labels
bugzilla Issues migrated from bugzilla lld

Comments

@cuviper
Copy link
Member

cuviper commented Aug 11, 2020

Bugzilla Link 47123
Resolution FIXED
Resolved on Aug 24, 2020 10:47
Version unspecified
OS Linux
Blocks #46070
CC @aaronpuchert,@zmodem,@smithp35
Fixed by commit(s) b26b32b

Extended Description

In Rust CI, while trying to upgrade to LLVM 11 rc1, arm-unknown-linux-gnueabi failed to link lld due to missing symbols for Timer.cpp:

rust-lang/rust#73526 (comment)

[100%] Linking CXX executable ../../bin/lld
/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/8.3.0/../../../../arm-unknown-linux-gnueabi/bin/ld: ../../lib/liblldCommon.a(Timer.cpp.o): in function lld::ScopedTimer::stop()': Timer.cpp:(.text._ZN3lld11ScopedTimer4stopEv+0x44): undefined reference to __atomic_fetch_add_8'
/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/8.3.0/../../../../arm-unknown-linux-gnueabi/bin/ld: ../../lib/liblldCommon.a(Timer.cpp.o): in function lld::Timer::millis() const': Timer.cpp:(.text._ZNK3lld5Timer6millisEv+0x8): undefined reference to __atomic_load_8'
/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/8.3.0/../../../../arm-unknown-linux-gnueabi/bin/ld: ../../lib/liblldCommon.a(Timer.cpp.o): in function lld::Timer::print(int, double, bool) const': Timer.cpp:(.text._ZNK3lld5Timer5printEidb+0x2c0): undefined reference to __atomic_load_8'
/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/8.3.0/../../../../arm-unknown-linux-gnueabi/bin/ld: ../../lib/liblldCommon.a(Timer.cpp.o): in function lld::Timer::print()': Timer.cpp:(.text._ZN3lld5Timer5printEv+0x34): undefined reference to __atomic_load_8'

This can be solved by linking libatomic on targets that need it. I've tried to add this in https://reviews.llvm.org/D85691, but it seems that the use of atomics for Timer at all is controversial.

@smithp35
Copy link
Collaborator

I'm trying to work out if there is a problem with LLD here, or with the command-line option that it is given. It isn't possible to work this out with the bug details, and I'm not sure anyone is going to go to the trouble to work it out from the Rust CI system.

For the former it would imply that there is a dependency on libatomic encoded in the inputs that LLD is not picking up on but ld.bfd is. Perhaps we've missed a DT_NEEDED or a file masquerading as a linker script.

Would it be possible to make a reproducer lld --reproduce=<file.tar> is a good way to do this although bugzilla file size limits usually mean the file has to be hosted somewhere else.

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 12, 2020

@​Peter the issue here is not LLD itself but linking LLD with ld.bfd.

Since https://reviews.llvm.org/D80298 LLD fails to compile on the targets which need to link libatomic explicitly.

@smithp35
Copy link
Collaborator

My apologies, thanks for clarifying, and thanks for pointing out https://reviews.llvm.org/D80298 that makes it much clearer.

Peter

@cuviper
Copy link
Member Author

cuviper commented Aug 22, 2020

D85691 is now committed, but I think this should be included in 11.0.0 too.

@zmodem
Copy link
Collaborator

zmodem commented Aug 24, 2020

Cherry-picked to 11.x as 1708358. Thanks!

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla lld
Projects
None yet
Development

No branches or pull requests

4 participants