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] Undefined references with linking with -lunwind-ptrace and -unwind-generic #54700

Closed
Kmeakin opened this issue Apr 1, 2022 · 3 comments
Labels
invalid Resolved as invalid, i.e. not a bug lld:ELF

Comments

@Kmeakin
Copy link
Contributor

Kmeakin commented Apr 1, 2022

lld reports undefined references, while ld is able to link this without issue:

main.c:

int main() {}

clang main.c -lunwind-ptrace -lunwind-generic produces no error.

clang main.c -lunwind-ptrace -lundwind-genric -fuse-ld=lld produces:

ld.lld: error: /lib/x86_64-linux-gnu/libunwind-ptrace.so: undefined reference to lzma_stream_buffer_decode [--no-allow-shlib-undefined]
ld.lld: error: /lib/x86_64-linux-gnu/libunwind-ptrace.so: undefined reference to lzma_index_uncompressed_size [--no-allow-shlib-undefined]
ld.lld: error: /lib/x86_64-linux-gnu/libunwind-ptrace.so: undefined reference to lzma_index_end [--no-allow-shlib-undefined]
ld.lld: error: /lib/x86_64-linux-gnu/libunwind-ptrace.so: undefined reference to lzma_index_buffer_decode [--no-allow-shlib-undefined]
ld.lld: error: /lib/x86_64-linux-gnu/libunwind-ptrace.so: undefined reference to lzma_stream_footer_decode [--no-allow-shlib-undefined]
ld.lld: error: /lib/x86_64-linux-gnu/libunwind-ptrace.so: undefined reference to lzma_index_size [--no-allow-shlib-undefined]
clang: error: linker command failed with exit code 1 (use -v to see invocation)

clang --version:

Ubuntu clang version 15.0.0-++20220321012320+9aa52ba574ad-1~exp1~20220321012418.363
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

ld.lld --version:

Ubuntu LLD 15.0.0 (compatible with GNU linkers)
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 1, 2022

@llvm/issue-subscribers-lld-elf

@MaskRay
Copy link
Member

MaskRay commented Apr 1, 2022

Not a bug. See https://maskray.me/blog/2021-06-13-dependency-related-linker-options#no-allow-shlib-undefined

Your main executable needs to link in liblzma for lzma_stream_buffer_decode and other symbols.

@MaskRay MaskRay closed this as completed Apr 1, 2022
@MaskRay MaskRay added the invalid Resolved as invalid, i.e. not a bug label Apr 1, 2022
@Kmeakin
Copy link
Contributor Author

Kmeakin commented Apr 1, 2022

I believe this should be considered a bug. lld is described as "a drop in replacement for bfd and gold". This implies that it should be possible to append -fuse-ld=lld to a compiler invocation and get the same behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Resolved as invalid, i.e. not a bug lld:ELF
Projects
None yet
Development

No branches or pull requests

3 participants