llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.63k stars 11.83k forks source link

[LLD][ARM] Assertion "If the source is ARM, we should not need Thumb PLTs" #99008

Closed ostannard closed 2 months ago

ostannard commented 3 months ago

This reproducer tarball (found while building https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/) causes an assertion in lld:

repro.tar.gz

$ /work/et/build/llvm/bin/ld.lld --chroot . -l crt0-semihost -l semihost -rpath work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi tmp/ucmpdi2_test-71ac06.o work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi/libclang_rt.builtins.a -l c -l m -Bstatic -EL --script picolibcpp.ld -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib --target2 rel -o ucmpdi2_test.c.tmp
ld.lld: /work/et/repos/llvm-project/lld/ELF/Arch/ARM.cpp:396: virtual bool {anonymous}::ARM::needsThunk(lld::elf::RelExpr, lld::elf::RelType, const lld::elf::InputFile*, uint64_t, const lld::elf::Symbol&, int64_t) const: Assertion `!config->armThumbPLTs && "If the source is ARM, we should not need Thumb PLTs"' failed.
PLEASE submit a bug report to https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/issues and include the crash backtrace.
Stack dump:
0.      Program arguments: /work/et/build/llvm/bin/ld.lld --chroot . -l crt0-semihost -l semihost -rpath work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi tmp/ucmpdi2_test-71ac06.o work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi/libclang_rt.builtins.a -l c -l m -Bstatic -EL --script picolibcpp.ld -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib --target2 rel -o ucmpdi2_test.c.tmp
 #0 0x0000561187063f00 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/et/build/llvm/bin/ld.lld+0x1c25f00)
 #1 0x000056118706131f llvm::sys::RunSignalHandlers() (/work/et/build/llvm/bin/ld.lld+0x1c2331f)
 #2 0x0000561187061475 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f1c1a242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f1c1a2969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f1c1a2969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f1c1a2969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f1c1a242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f1c1a2287f3 abort ./stdlib/abort.c:81:7
 #9 0x00007f1c1a22871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f1c1a239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00005611871dfce6 (anonymous namespace)::ARM::needsThunk(lld::elf::RelExpr, unsigned int, lld::elf::InputFile const*, unsigned long, lld::elf::Symbol const&, long) const ARM.cpp:0:0
#12 0x00005611872f6103 lld::elf::ThunkCreator::createThunks(unsigned int, llvm::ArrayRef<lld::elf::OutputSection*>) (/work/et/build/llvm/bin/ld.lld+0x1eb8103)
#13 0x00005611873df80d (anonymous namespace)::Writer<llvm::object::ELFType<(llvm::endianness)1, false>>::finalizeAddressDependentContent() Writer.cpp:0:0
#14 0x00005611873e0d33 (anonymous namespace)::Writer<llvm::object::ELFType<(llvm::endianness)1, false>>::finalizeSections() Writer.cpp:0:0
#15 0x00005611873e2a2c (anonymous namespace)::Writer<llvm::object::ELFType<(llvm::endianness)1, false>>::run() Writer.cpp:0:0
#16 0x00005611873e3abd void lld::elf::writeResult<llvm::object::ELFType<(llvm::endianness)1, false>>() (/work/et/build/llvm/bin/ld.lld+0x1fa5abd)
#17 0x00005611871c9a75 void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::endianness)1, false>>(llvm::opt::InputArgList&) (/work/et/build/llvm/bin/ld.lld+0x1d8ba75)
#18 0x00005611871d344b lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/work/et/build/llvm/bin/ld.lld+0x1d9544b)
#19 0x00005611871d54c0 lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/work/et/build/llvm/bin/ld.lld+0x1d974c0)
#20 0x0000561187065f70 lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/work/et/build/llvm/bin/ld.lld+0x1c27f70)
#21 0x0000561186fa02a6 lld_main(int, char**, llvm::ToolContext const&) (/work/et/build/llvm/bin/ld.lld+0x1b622a6)
#22 0x0000561186fa064b main (/work/et/build/llvm/bin/ld.lld+0x1b6264b)
#23 0x00007f1c1a229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#24 0x00007f1c1a229e40 call_init ./csu/../csu/libc-start.c:128:20
#25 0x00007f1c1a229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#26 0x0000561186f9fae5 _start (/work/et/build/llvm/bin/ld.lld+0x1b61ae5)
fish: Job 1, '/work/et/build/llvm/bin/ld.lld…' terminated by signal SIGABRT (Abort)
llvmbot commented 3 months ago

@llvm/issue-subscribers-backend-arm

Author: Oliver Stannard (ostannard)

This reproducer tarball (found while building https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/) causes an assertion in lld: [repro.tar.gz](https://github.com/user-attachments/files/16246302/repro.tar.gz) ``` $ /work/et/build/llvm/bin/ld.lld --chroot . -l crt0-semihost -l semihost -rpath work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi tmp/ucmpdi2_test-71ac06.o work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi/libclang_rt.builtins.a -l c -l m -Bstatic -EL --script picolibcpp.ld -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib --target2 rel -o ucmpdi2_test.c.tmp ld.lld: /work/et/repos/llvm-project/lld/ELF/Arch/ARM.cpp:396: virtual bool {anonymous}::ARM::needsThunk(lld::elf::RelExpr, lld::elf::RelType, const lld::elf::InputFile*, uint64_t, const lld::elf::Symbol&, int64_t) const: Assertion `!config->armThumbPLTs && "If the source is ARM, we should not need Thumb PLTs"' failed. PLEASE submit a bug report to https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/issues and include the crash backtrace. Stack dump: 0. Program arguments: /work/et/build/llvm/bin/ld.lld --chroot . -l crt0-semihost -l semihost -rpath work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi tmp/ucmpdi2_test-71ac06.o work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi/libclang_rt.builtins.a -l c -l m -Bstatic -EL --script picolibcpp.ld -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib --target2 rel -o ucmpdi2_test.c.tmp #0 0x0000561187063f00 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/et/build/llvm/bin/ld.lld+0x1c25f00) #1 0x000056118706131f llvm::sys::RunSignalHandlers() (/work/et/build/llvm/bin/ld.lld+0x1c2331f) #2 0x0000561187061475 SignalHandler(int) Signals.cpp:0:0 #3 0x00007f1c1a242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520) #4 0x00007f1c1a2969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76 #5 0x00007f1c1a2969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10 #6 0x00007f1c1a2969fc pthread_kill ./nptl/pthread_kill.c:89:10 #7 0x00007f1c1a242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6 #8 0x00007f1c1a2287f3 abort ./stdlib/abort.c:81:7 #9 0x00007f1c1a22871b _nl_load_domain ./intl/loadmsgcat.c:1177:9 #10 0x00007f1c1a239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96) #11 0x00005611871dfce6 (anonymous namespace)::ARM::needsThunk(lld::elf::RelExpr, unsigned int, lld::elf::InputFile const*, unsigned long, lld::elf::Symbol const&, long) const ARM.cpp:0:0 #12 0x00005611872f6103 lld::elf::ThunkCreator::createThunks(unsigned int, llvm::ArrayRef<lld::elf::OutputSection*>) (/work/et/build/llvm/bin/ld.lld+0x1eb8103) #13 0x00005611873df80d (anonymous namespace)::Writer<llvm::object::ELFType<(llvm::endianness)1, false>>::finalizeAddressDependentContent() Writer.cpp:0:0 #14 0x00005611873e0d33 (anonymous namespace)::Writer<llvm::object::ELFType<(llvm::endianness)1, false>>::finalizeSections() Writer.cpp:0:0 #15 0x00005611873e2a2c (anonymous namespace)::Writer<llvm::object::ELFType<(llvm::endianness)1, false>>::run() Writer.cpp:0:0 #16 0x00005611873e3abd void lld::elf::writeResult<llvm::object::ELFType<(llvm::endianness)1, false>>() (/work/et/build/llvm/bin/ld.lld+0x1fa5abd) #17 0x00005611871c9a75 void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::endianness)1, false>>(llvm::opt::InputArgList&) (/work/et/build/llvm/bin/ld.lld+0x1d8ba75) #18 0x00005611871d344b lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/work/et/build/llvm/bin/ld.lld+0x1d9544b) #19 0x00005611871d54c0 lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/work/et/build/llvm/bin/ld.lld+0x1d974c0) #20 0x0000561187065f70 lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/work/et/build/llvm/bin/ld.lld+0x1c27f70) #21 0x0000561186fa02a6 lld_main(int, char**, llvm::ToolContext const&) (/work/et/build/llvm/bin/ld.lld+0x1b622a6) #22 0x0000561186fa064b main (/work/et/build/llvm/bin/ld.lld+0x1b6264b) #23 0x00007f1c1a229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #24 0x00007f1c1a229e40 call_init ./csu/../csu/libc-start.c:128:20 #25 0x00007f1c1a229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5 #26 0x0000561186f9fae5 _start (/work/et/build/llvm/bin/ld.lld+0x1b61ae5) fish: Job 1, '/work/et/build/llvm/bin/ld.lld…' terminated by signal SIGABRT (Abort) ```
llvmbot commented 3 months ago

@llvm/issue-subscribers-lld-elf

Author: Oliver Stannard (ostannard)

This reproducer tarball (found while building https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/) causes an assertion in lld: [repro.tar.gz](https://github.com/user-attachments/files/16246302/repro.tar.gz) ``` $ /work/et/build/llvm/bin/ld.lld --chroot . -l crt0-semihost -l semihost -rpath work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi tmp/ucmpdi2_test-71ac06.o work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi/libclang_rt.builtins.a -l c -l m -Bstatic -EL --script picolibcpp.ld -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib --target2 rel -o ucmpdi2_test.c.tmp ld.lld: /work/et/repos/llvm-project/lld/ELF/Arch/ARM.cpp:396: virtual bool {anonymous}::ARM::needsThunk(lld::elf::RelExpr, lld::elf::RelType, const lld::elf::InputFile*, uint64_t, const lld::elf::Symbol&, int64_t) const: Assertion `!config->armThumbPLTs && "If the source is ARM, we should not need Thumb PLTs"' failed. PLEASE submit a bug report to https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/issues and include the crash backtrace. Stack dump: 0. Program arguments: /work/et/build/llvm/bin/ld.lld --chroot . -l crt0-semihost -l semihost -rpath work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi tmp/ucmpdi2_test-71ac06.o work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi/libclang_rt.builtins.a -l c -l m -Bstatic -EL --script picolibcpp.ld -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib --target2 rel -o ucmpdi2_test.c.tmp #0 0x0000561187063f00 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/et/build/llvm/bin/ld.lld+0x1c25f00) #1 0x000056118706131f llvm::sys::RunSignalHandlers() (/work/et/build/llvm/bin/ld.lld+0x1c2331f) #2 0x0000561187061475 SignalHandler(int) Signals.cpp:0:0 #3 0x00007f1c1a242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520) #4 0x00007f1c1a2969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76 #5 0x00007f1c1a2969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10 #6 0x00007f1c1a2969fc pthread_kill ./nptl/pthread_kill.c:89:10 #7 0x00007f1c1a242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6 #8 0x00007f1c1a2287f3 abort ./stdlib/abort.c:81:7 #9 0x00007f1c1a22871b _nl_load_domain ./intl/loadmsgcat.c:1177:9 #10 0x00007f1c1a239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96) #11 0x00005611871dfce6 (anonymous namespace)::ARM::needsThunk(lld::elf::RelExpr, unsigned int, lld::elf::InputFile const*, unsigned long, lld::elf::Symbol const&, long) const ARM.cpp:0:0 #12 0x00005611872f6103 lld::elf::ThunkCreator::createThunks(unsigned int, llvm::ArrayRef<lld::elf::OutputSection*>) (/work/et/build/llvm/bin/ld.lld+0x1eb8103) #13 0x00005611873df80d (anonymous namespace)::Writer<llvm::object::ELFType<(llvm::endianness)1, false>>::finalizeAddressDependentContent() Writer.cpp:0:0 #14 0x00005611873e0d33 (anonymous namespace)::Writer<llvm::object::ELFType<(llvm::endianness)1, false>>::finalizeSections() Writer.cpp:0:0 #15 0x00005611873e2a2c (anonymous namespace)::Writer<llvm::object::ELFType<(llvm::endianness)1, false>>::run() Writer.cpp:0:0 #16 0x00005611873e3abd void lld::elf::writeResult<llvm::object::ELFType<(llvm::endianness)1, false>>() (/work/et/build/llvm/bin/ld.lld+0x1fa5abd) #17 0x00005611871c9a75 void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::endianness)1, false>>(llvm::opt::InputArgList&) (/work/et/build/llvm/bin/ld.lld+0x1d8ba75) #18 0x00005611871d344b lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/work/et/build/llvm/bin/ld.lld+0x1d9544b) #19 0x00005611871d54c0 lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/work/et/build/llvm/bin/ld.lld+0x1d974c0) #20 0x0000561187065f70 lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/work/et/build/llvm/bin/ld.lld+0x1c27f70) #21 0x0000561186fa02a6 lld_main(int, char**, llvm::ToolContext const&) (/work/et/build/llvm/bin/ld.lld+0x1b622a6) #22 0x0000561186fa064b main (/work/et/build/llvm/bin/ld.lld+0x1b6264b) #23 0x00007f1c1a229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #24 0x00007f1c1a229e40 call_init ./csu/../csu/libc-start.c:128:20 #25 0x00007f1c1a229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5 #26 0x0000561186f9fae5 _start (/work/et/build/llvm/bin/ld.lld+0x1b61ae5) fish: Job 1, '/work/et/build/llvm/bin/ld.lld…' terminated by signal SIGABRT (Abort) ```
MaskRay commented 2 months ago

LGTM! Can you also make a /cherry-pick backport request for the release/19.x branch after this lands?

llvmbot commented 2 months ago

LGTM! Can you also make a /cherry-pick backport request for the release/19.x branch after this lands?

Error: Command failed due to missing milestone.

ostannard commented 2 months ago

/cherry-pick a1c6467bd

llvmbot commented 2 months ago

/pull-request llvm/llvm-project#102292