llvm / llvm/llvm-project

Compiler error when compiling with -rdynamic and LTO

Open
#190,737 5 comments 0 reactions 0 assignees View on GitHub
backend:X86 crash lld:ELF LTO
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

When compiling 447.dealII from the SPEC2006 benchmark suite, I get an error in ld.lld. The error only happens when both `-flto` and `-rdynamic` are passed as flags. I also tested for the same error with clang 21, 18, and 15, and all have the same issue
I have included a minimal reproducer and the stack trace.

[repro_reduced.zip](https://github.com/user-attachments/files/26528914/repro_reduced.zip)

```
Alias must point to a definition
ptr @_ZN12SparseMatrixIdE15ExcInvalidIndexD1Ev
Alias must point to a definition
ptr @_ZN12SparseMatrixIfE15ExcInvalidIndexD1Ev
LLVM ERROR: Broken module found, compilation aborted!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /home/anton/llvm-project/build/bin/ld.lld -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -export-dynamic -pie -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o dealII /lib/x86_64-linux-gnu/Scrt1.o /lib/x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/13/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/13 -L/usr/lib/gcc/x86_64-linux-gnu/13/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib64 -L/lib -L/usr/lib -plugin-opt=mcpu=x86-64 -plugin-opt=O2 -plugin-opt=-debugger-tune=gdb --reproduce=repro.tar ...

-lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/13/crtendS.o /lib/x86_64-linux-gnu/crtn.o
1. Running pass "verify" on module "ld-temp.o"
#0 0x0000555555e7ea22 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/anton/llvm-project/build/bin/ld.lld+0x92aa22)
#1 0x0000555555e7b602 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#2 0x00007ffff7645330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#3 0x00007ffff769eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#4 0x00007ffff769eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#5 0x00007ffff769eb2c pthread_kill ./nptl/pthread_kill.c:89:10
#6 0x00007ffff764527e raise ./signal/../sysdeps/posix/raise.c:27:6
#7 0x00007ffff76288ff abort ./stdlib/abort.c:81:7
#8 0x0000555555c83935 llvm::DisplayGraph(llvm::StringRef, bool, llvm::GraphProgram::Name) (.cold) GraphWriter.cpp:0:0
#9 0x0000555555e0a7de (/home/anton/llvm-project/build/bin/ld.lld+0x8b67de)
#10 0x000055555a9f7403 (/home/anton/llvm-project/build/bin/ld.lld+0x54a3403)
#11 0x00005555583ef395 llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/home/anton/llvm-project/build/bin/ld.lld+0x2e9b395)
#12 0x000055555a9b78f0 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/home/anton/llvm-project/build/bin/ld.lld+0x54638f0)
#13 0x00005555583f5970 runNewPMPasses(llvm::lto::Config const&, llvm::Module&, llvm::TargetMachine*, unsigned int, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*) LTOBackend.cpp:0:0
#14 0x00005555583f7563 llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine*, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*, std::vector> const&) (/home/anton/llvm-project/build/bin/ld.lld+0x2ea3563)
#15 0x00005555583f9eda llvm::lto::backend(llvm::lto::Config const&, std::function>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) (/home/anton/llvm-project/build/bin/ld.lld+0x2ea5eda)
#16 0x00005555583d4429 llvm::lto::LTO::runRegularLTO(std::function>> (unsigned int, llvm::Twine const&)>) (/home/anton/llvm-project/build/bin/ld.lld+0x2e80429)
#17 0x00005555583ee8b5 llvm::lto::LTO::run(std::function>> (unsigned int, llvm::Twine const&)>, llvm::FileCache) (/home/anton/llvm-project/build/bin/ld.lld+0x2e9a8b5)
#18 0x0000555556078f68 lld::elf::BitcodeCompiler::compile() (/home/anton/llvm-project/build/bin/ld.lld+0xb24f68)
#19 0x0000555555fdea0d void lld::elf::LinkerDriver::compileBitcodeFiles>(bool) (/home/anton/llvm-project/build/bin/ld.lld+0xa8aa0d)
#20 0x0000555555ff6d89 void lld::elf::LinkerDriver::link>(llvm::opt::InputArgList&) (/home/anton/llvm-project/build/bin/ld.lld+0xaa2d89)
#21 0x0000555555fffb7c lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef) (/home/anton/llvm-project/build/bin/ld.lld+0xaabb7c)
#22 0x0000555556000227 lld::elf::link(llvm::ArrayRef, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/home/anton/llvm-project/build/bin/ld.lld+0xaac227)
#23 0x0000555555ebc332 lld::unsafeLldMain(llvm::ArrayRef, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef, bool) (/home/anton/llvm-project/build/bin/ld.lld+0x968332)
#24 0x0000555555debe4e lld_main(int, char**, llvm::ToolContext const&) (/home/anton/llvm-project/build/bin/ld.lld+0x897e4e)
#25 0x0000555555ca287d main (/home/anton/llvm-project/build/bin/ld.lld+0x74e87d)
#26 0x00007ffff762a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#27 0x00007ffff762a28b call_init ./csu/../csu/libc-start.c:128:20
#28 0x00007ffff762a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
#29 0x0000555555deb715 _start (/home/anton/llvm-project/build/bin/ld.lld+0x897715)
clang++: error: unable to execute command: Aborted (core dumped)
clang++: error: linker command failed with exit code -2 (use -v to see invocation)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.