mold
mold copied to clipboard
linux/ppc64el: fails to build LLVM with `./elf/thunks.cc:257: void mold::elf::OutputSection<E>::create_range_extension_thunks(mold::elf::Context<E>&) [with E = mold::elf::PPC64V2]: Assertion `thunk->size() < max_thunk_size' failed.`
using mold: 2.4.1+dfsg-1 (i will try with 2.30 but i don't see any potential fix in the release notes))
Full log: https://buildd.debian.org/status/fetch.php?pkg=llvm-toolchain-18&arch=ppc64el&ver=1%3A18.1.2-1&stamp=1710939656&raw=0
Just to confirm: I can reproduce the issue if I build Clang with mold on ppc64le, right?
Yes, except if it is caused by some extra LDFLAGS that we use (but you can see them in the log)
I also see it on arm64: https://llvm-jenkins.debian.net/job/llvm-toolchain-18-binaries/architecture=arm64,distribution=unstable,label=arm64/73/console
It is not easy to reproduce the issue for me because it involves lots of Debian-specific toolings. Could you reproduce the issue just by building LLVM from source without using Debian-specific tools?
Just running the cmake will all the arg should be good but I will try to make a test case. Any recommendation on what to do next? Thanks
I fired up debian:unstable docker image, installed build-deps for clang-18, installed mold, checked out the llvm repo from github, and then copy-and-pasted the cmake command line, but it built just fine. So I think there's a hidden condition to reproduce the issue. Ideally, I want to know a procedure to reproduce the issue with the docker image.
I'm seeing the same thing on fedora 40 aarch64 (asahi linux) on a different codebase. Trace:
Thread 1 "ld.mold" hit Breakpoint 1.1, mold::elf::OutputSection<mold::elf::ARM64>::create_range_extension_thunks (this=0x40cbe27ca80, ctx=...) at /usr/src/debug/mold-2.31.0-1.fc40.aarch64/elf/thunks.cc:257
257 assert(thunk->size() < max_thunk_size);
(gdb) bt
#0 mold::elf::OutputSection<mold::elf::ARM64>::create_range_extension_thunks (this=0x40cbe27ca80, ctx=...) at /usr/src/debug/mold-2.31.0-1.fc40.aarch64/elf/thunks.cc:257
#1 mold::elf::compute_section_sizes<mold::elf::ARM64> (ctx=...) at /usr/src/debug/mold-2.31.0-1.fc40.aarch64/elf/passes.cc:1429
#2 0x0000aaaaaafc6158 in mold::elf::elf_main<mold::elf::ARM64> (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/mold-2.31.0-1.fc40.aarch64/elf/main.cc:578
#3 0x0000aaaaaafb30a0 in mold::elf::redo_main<mold::elf::X86_64> (ctx=..., argc=82, argv=0xffffffffdae8) at /usr/src/debug/mold-2.31.0-1.fc40.aarch64/elf/passes.cc:26
#4 mold::elf::elf_main<mold::elf::X86_64> (argc=82, argv=0xffffffffdae8) at /usr/src/debug/mold-2.31.0-1.fc40.aarch64/elf/main.cc:366
#5 0x0000fffff7900a1c in __libc_start_call_main (main=main@entry=0xaaaaaaba0fc0 <main(int, char**)>, argc=argc@entry=82, argv=argv@entry=0xffffffffdae8) at ../sysdeps/nptl/libc_start_call_main.h:58
#6 0x0000fffff7900afc in __libc_start_main_impl (main=0xaaaaaaba0fc0 <main(int, char**)>, argc=82, argv=0xffffffffdae8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=<optimized out>)
at ../csu/libc-start.c:360
#7 0x0000aaaaaaba2a70 in _start ()
(gdb)
Dump: https://fromsmash.com/2qzqnkmPiN-it
I need a reproducer to debug it. Is your program open-source?
Here's a small reproducer:
$ ld.mold --version
mold 2.31.0 (compatible with GNU ld)
$ ld.mold -EL --hash-style=gnu --build-id --eh-frame-hdr -m aarch64linux -shared obj.o lib.a
ld.mold: /builddir/build/BUILD/mold-2.31.0/elf/thunks.cc:257: void mold::elf::OutputSection<E>::create_range_extension_thunks(mold::elf::Context<E>&) [with E = mold::elf::ARM64]: Assertion `thunk->size() < max_thunk_size' failed.
Please try again with git head.