https://sourceware.org/bugzilla/show_bug.cgi?id=33470
Bug ID: 33470
Summary: binutils build fails with clang and -flto
Product: binutils
Version: 2.46 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: binutils
Assignee: unassigned at sourceware dot org
Reporter: amodra at gmail dot com
Target Milestone: ---
On an x86_64-linux host
CC="clang" \
CXX="clang++" \
CFLAGS="-O2 -g -flto" \
CXXFLAGS="-O2 -g -flto" \
~/src/binutils-gdb/configure --enable-targets=all \
--enable-gold --enable-threads --disable-gdb --disable-gdbserver --disable-sim
\
--disable-readline --disable-libdecnumber --disable-libbacktrace
--disable-gprofng \
--disable-x86-used-note \
--enable-plugins --enable-nls
...
libtool: link: clang -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow
-Werror -Wwrite-strings -I/home/alan/src/binutils-gdb/gas/../zlib -O2 -g -flto
-o as-new app.o as.o atof-generic.o codeview.o compress-debug.o cond.o depend.o
dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o flonum-konst.o
flonum-mult.o frags.o gen-sframe.o ginsn.o hash.o input-file.o input-scrub.o
listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o
scfidw2gen.o scfi.o sframe-opt.o stabs.o subsegs.o symbols.o write.o
config/tc-i386.o config/obj-elf.o config/atof-ieee.o ../bfd/.libs/libbfd.a
-L/home/alan/build/gas/all-clang/zlib
/home/alan/build/gas/all-clang/libsframe/.libs/libsframe.a
../libiberty/libiberty.a -lz -lzstd
/usr/bin/ld: ../bfd/.libs/libbfd.a: error adding symbols: archive has no index;
run ranlib to add one
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [Makefile:1298: as-new] Error 1
make[4]: Leaving directory '/build/gas/all-clang/gas'
make[3]: *** [Makefile:1676: all-recursive] Error 1
make[3]: Leaving directory '/build/gas/all-clang/gas'
make[2]: *** [Makefile:1025: all] Error 2
make[2]: Leaving directory '/build/gas/all-clang/gas'
make[1]: *** [Makefile:5867: all-gas] Error 2
make[1]: Leaving directory '/build/gas/all-clang'
make: *** [Makefile:1028: all] Error 2
checking the logs shows both ar and ranlib are invoked with
--plugin /usr/lib/gcc/x86_64-linux-gnu/14/liblto_plugin.so when creating
libbfd.a
That's the wrong plugin for clang. For my Ubuntu 25.04 system apparently the
correct option is --plugin /usr/lib/llvm-20/lib/LLVMgold.so. Just how we are
supposed to figure that out is not clear to me, particularly since
clang --print-file-name liblto_plugin.so
/usr/lib/gcc/x86_64-linux-gnu/14/liblto_plugin.so
Also another bug, perhaps relevant. The system binutils-2.44 results in
/usr/bin/nm bfd/bfd.o
bfd plugin: LLVM gold plugin has failed to create LTO module: Invalid attribute
group entry (Producer: 'LLVM20.1.2' Reader: 'LLVM 16.0.6')
nm: bfd/bfd.o: no symbols
/usr/lib/bfd-plugins/ has
liblto_plugin.so LLVMgold-15.so LLVMgold-16.so LLVMgold-18.so
LLVMgold-19.so LLVMgold-20.so
At a guess, this is misbehaviour of LLVMgold-16.so, or perhaps all of the
LLVMgold*.so since the error comes from whichever one is opened last (ie. is
last in the directory) unless that happens to be LLVMgold-20.so.
--
You are receiving this mail because:
You are on the CC list for the bug.