Created attachment 11435 [details] gcc-lto-616038.tar.gz Original example is a build failure of elfutils-0.175 against CFLAGS=-flto at: https://bugs.gentoo.org/616038 In case it's a gcc bug I also files: https://gcc.gnu.org/PR88396 Angrew suspects it might be related to https://sourceware.org/PR12319 Extracted minimal reproducer looks like that: $ cat libdw.map ELFUTILS_0.143 { global: dwarf_bytesize; }; $ cat dwarf_bytesize.os.c void dwarf_bytesize (void) {} asm (".symver dwarf_bytesize,dwarf_bytesize@@@ELFUTILS_0.143"); Reproducer: $ gcc -flto -c dwarf_bytesize.os.c -o dwarf_bytesize.os -fPIC $ gcc-ar cr libdw_pic.a dwarf_bytesize.os $ gcc-ranlib libdw_pic.a $ gcc -flto -o libdw.so -shared -Wl,--version-script,libdw.map,--no-undefined -Wl,--whole-archive libdw_pic.a -Wl,--no-whole-archive -fuse-ld=bfd /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.bfd: /tmp/ccYR58eH.ltrans0.ltrans.o:(*IND*+0x0): multiple definition of `dwarf_bytesize'; dwarf_bytesize.os (symbol from plugin):(.text+0x0): first defined here Using binutils-2.31.1 / gcc-8.2.0 here. $ gcc -v Using built-in specs. COLLECT_GCC=/usr/bin/gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /tmp/portage-tmpdir/portage/sys-devel/gcc-8.2.0-r5/work/gcc-8.2.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/8.2.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/8.2.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/8.2.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/8.2.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/8.2.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 8.2.0-r5 p1.6' --disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libmudflap --disable-libssp --disable-libmpx --disable-systemtap --enable-vtable-verify --enable-libvtv --enable-lto --with-isl --disable-isl-version-check --enable-libsanitizer --enable-default-pie --enable-default-ssp Thread model: posix gcc version 8.2.0 (Gentoo 8.2.0-r5 p1.6)
Please try 2.31 branch. This looks like a dup of PR 23818.
A patch is posted at https://sourceware.org/ml/binutils/2018-12/msg00087.html
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fbcc8bafeb413a111cd3caab39b3ab57d5b8ce93 commit fbcc8bafeb413a111cd3caab39b3ab57d5b8ce93 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri Dec 7 15:39:49 2018 -0800 Override the previous definition from IR object Mark the previous definition from IR object as undefined so that the generic linker will override it. bfd/ PR ld/23958 * elflink.c (_bfd_elf_add_default_symbol): Override the previous definition from IR object. ld/ PR ld/23958 * testsuite/ld-plugin/lto.exp: Run PR ld/23958 test. * testsuite/ld-plugin/pr23958.c: New file. * testsuite/ld-plugin/pr23958.t: Likewise.
Fixed for 2.32.