Created attachment 885959 [details, diff] ebuild.patch Gentoo Linux amd64 llvm musl libc (merged usr) Clang segfaults when linking firefox with mold and -flto=thin: ``` 209:13.21 Finished release [optimized] target(s) in 30.17s 209:14.75 security/manager/ssl/ipcclientcerts/libipcclientcerts_static.a 209:14.76 : 209:14.76 gmake[4]: Leaving directory '/var/tmp/portage/www-client/firefox-123.0/work/firefox_build/security/manager/ssl/ipcclientcerts' 209:14.77 gmake[4]: Entering directory '/var/tmp/portage/www-client/firefox-123.0/work/firefox_build/security/manager/ssl/ipcclientcerts/dynamic-library' 209:14.78 security/manager/ssl/ipcclientcerts/dynamic-library/libipcclientcerts.so 209:14.78 rm -f libipcclientcerts.so 209:14.82 /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-clang++-17 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -fstack-clash-protection -fno-sized-deallocation -fno-aligned-new -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -stdlib=libc++ -fno-exceptions -fPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -g0 -O3 -fomit-frame-pointer -funwind-tables -shared -Wl,-z,defs -Wl,--gc-sections -Wl,-h,libipcclientcerts.so -o libipcclientcerts.so stub.o -flto=thin -Wl,-plugin-opt=-import-instr-limit=10 -Wl,-plugin-opt=-import-hot-multiplier=30 -lpthread -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -Wl,-O3 -Wl,--as-needed -Wl,--strip-debug -Wl,--undefined-version -Wl,--icf=safe -Wl,--threads=4 -Wl,--compress-debug-sections=zstd -fuse-ld=mold -rtlib=compiler-rt -unwindlib=libunwind -Wl,-z,relro -Wl,-z,now -flto=thin -Wl,--compress-debug-sections=zlib -Wl,-rpath=/usr/lib/firefox,--enable-new-dtags -fuse-ld=mold -Wl,-z,noexecstack -Wl,-z,text -Wl,-z,relro -Wl,-z,now -Wl,-z,nocopyreloc -Wl,-Bsymbolic-functions -fstack-protector-strong -fstack-clash-protection -Wl,-rpath-link,/var/tmp/portage/www-client/firefox-123.0/work/firefox_build/dist/bin -Wl,-rpath-link,/usr/lib ../../../../../build/pure_virtual/libpure_virtual.a /var/tmp/portage/www-client/firefox-123.0/work/firefox_build/x86_64-unknown-linux-musl/release/libipcclientcerts_static.a -Wl,--version-script,libipcclientcerts.so.symbols 209:18.50 /var/tmp/portage/www-client/firefox-123.0/work/firefox_build/srcdirs/firefox-123.0-0fc09215725a/_virtualenvs/build/bin/python -m mozbuild.action.check_binary libipcclientcerts.so 209:19.20 chmod +x libipcclientcerts.so 209:19.22 ../../../../../config/nsinstall -R -m 644 'libipcclientcerts.so' '../../../../../dist/bin' 209:19.22 gmake[4]: Leaving directory '/var/tmp/portage/www-client/firefox-123.0/work/firefox_build/security/manager/ssl/ipcclientcerts/dynamic-library' 209:46.93 /var/tmp/portage/www-client/firefox-123.0/work/firefox_build/srcdirs/firefox-123.0-0fc09215725a/_virtualenvs/build/bin/python -m mozbuild.action.check_binary libmozavcodec.so 209:47.82 chmod +x libmozavcodec.so 209:47.82 ../../../config/nsinstall -R -m 644 'libmozavcodec.so' '../../../dist/bin' 209:47.83 gmake[4]: Leaving directory '/var/tmp/portage/www-client/firefox-123.0/work/firefox_build/media/ffvpx/libavcodec' 216:15.44 x86_64-gentoo-linux-musl-clang++-17: error: unable to execute command: Segmentation fault 216:15.44 x86_64-gentoo-linux-musl-clang++-17: error: linker command failed due to signal (use -v to see invocation) 216:15.47 gmake[4]: *** [/var/tmp/portage/www-client/firefox-123.0/work/firefox-123.0/config/rules.mk:541: libxul.so] Error 1 216:15.47 gmake[4]: Leaving directory '/var/tmp/portage/www-client/firefox-123.0/work/firefox_build/toolkit/library/build' 216:15.47 gmake[3]: *** [/var/tmp/portage/www-client/firefox-123.0/work/firefox-123.0/config/recurse.mk:72: toolkit/library/build/target] Error 2 216:15.49 gmake[3]: Leaving directory '/var/tmp/portage/www-client/firefox-123.0/work/firefox_build' 216:15.49 gmake[2]: *** [/var/tmp/portage/www-client/firefox-123.0/work/firefox-123.0/config/recurse.mk:34: compile] Error 2 216:15.52 gmake[2]: Leaving directory '/var/tmp/portage/www-client/firefox-123.0/work/firefox_build' 216:15.52 gmake[1]: *** [/var/tmp/portage/www-client/firefox-123.0/work/firefox-123.0/config/rules.mk:361: default] Error 2 216:15.56 gmake[1]: Leaving directory '/var/tmp/portage/www-client/firefox-123.0/work/firefox_build' 216:15.56 gmake: *** [client.mk:60: build] Error 2 216:15.61 W 158 compiler warnings present. * ERROR: www-client/firefox-123.0::gentoo failed (compile phase): * (no error message) ``` Replacing -flto=thin with -flto fixes the segfault as a workaround
Created attachment 885960 [details] emerge --info
Created attachment 885961 [details] emerge -pqv
Created attachment 885962 [details] build.log
Closing, opened a new bug report linking with -flto: https://bugs.gentoo.org/925502 *** This bug has been marked as a duplicate of bug 925502 ***
Can you elaborate on how this is a dupe?
> Can you elaborate on how this is a dupe? Not really a duplicate, I've extracted the actual error in https://bugs.gentoo.org/925502 but I'm not sure if mold would still segfault with -flto=thin after applying a workaround.
Sorry, bug is indeed unrelated
Created attachment 886009 [details] build.log(2) build.log (0002-gcc_hidden.patch)
That looks like Clang is segfaulting? Please try to grab a backtrace.
Created attachment 893455 [details] mold backtrace
Created attachment 893456 [details] lld backtrace
Error message is different when running the linking command with lld and gdb instead: LLVM ERROR: Do not know how to split the result of this operator! Thread 8 "ld.lld" received signal SIGABRT, Aborted. [Switching to LWP 583515] 0x00007fffefa61e87 in __syscall4 (n=14, a1=2, a2=140735481379344, a3=0, a4=8) at ./arch/x86_64/syscall_arch.h:38 warning: 38 ./arch/x86_64/syscall_arch.h: No such file or directory