Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 922494 - sys-devel/gcc fails to build with -flto -fuse-linker-plugin
Summary: sys-devel/gcc fails to build with -flto -fuse-linker-plugin
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-19 12:37 UTC by stefan11111
Modified: 2024-10-05 17:17 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Gcc build log (gcc-build-logs.tar.xz,64.21 KB, application/x-xz)
2024-01-19 12:48 UTC, stefan11111
Details
emerge --info (emerge-info,6.80 KB, text/plain)
2024-01-19 12:49 UTC, stefan11111
Details
build/config.log (config.log,42.35 KB, text/x-log)
2024-01-23 18:17 UTC, stefan11111
Details
build/config.status (config.status,45.50 KB, application/x-shellscript)
2024-01-23 18:17 UTC, stefan11111
Details
config-logs.xz (config-logs.xz,186.04 KB, application/x-xz)
2024-01-23 19:21 UTC, stefan11111
Details
remove-linker-plugin-check.patch (remove-linker-plugin-check.patch,1.04 KB, patch)
2024-01-24 10:33 UTC, stefan11111
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description stefan11111 2024-01-19 12:37:14 UTC
After talking to Arsen on irc, I was told to open a bug about this.
I have -flto -fuse-linker-plugin in my COMMON_FLAGS in make.conf.

However, if I build gcc with:

USE="custom-cflags" CFLAGS="-O3 -pipe -march=native -flto -fuse-linker-plugin" CXXFLAGS="-O3 -pipe -march=native -flto -fuse-linker-plugin" doas emerge -1av gcc

gcc fails to build with:

make[4]: Entering directory '/var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/build-jit/x86_64-pc-linux-gnu/32/libgcc'
/var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/build-jit/./gcc/xgcc -B/var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/build-jit/./gcc/ -B/usr/x86_64-pc-linux-gnu/bin/ -B/usr/x86_64-pc-linux-gnu/lib/ -isystem /usr/x86_64-pc-linux-gnu/include -isystem /usr/x86_64-pc-linux-gnu/sys-include    -O2  -g -O2 -O3 -pipe -march=native -fuse-linker-plugin -DIN_GCC -fPIC   -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fpic -mlong-double-80 -DUSE_ELF_SYMVER  -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fno-stack-clash-protection  -shared -nodefaultlibs -Wl,--soname=libgcc_s.so.1 -Wl,--version-script=libgcc.map -Wl,-O1 -Wl,--as-needed  -m32 -o 32/libgcc_s.so.1.tmp -g -O2 -O3 -pipe -march=native -fuse-linker-plugin -m32 -B./ _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s.o _bswapsi2_s.o _bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _divdi3_s.o _moddi3_s.o _divmoddi4_s.o _udivdi3_s.o _umoddi3_s.o _udivmoddi4_s.o _udiv_w_sdiv_s.o cpuinfo_s.o tf-signs_s.o sfp-exceptions_s.o _divhc3_s.o _mulhc3_s.o addtf3_s.o divtf3_s.o eqtf2_s.o getf2_s.o
letf2_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o extendhfsf2_s.o extendhfdf2_s.o extendhftf2_s.o extendhfxf2_s.o extendsfdf2_s.o extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o extendbfsf2_s.o trunctfhf2_s.o truncxfhf2_s.o truncdfhf2_s.o truncsfhf2_s.o trunctfsf2_s.o truncdfsf2_s.o trunctfdf2_s.o trunctfxf2_s.o trunctfbf2_s.o truncxfbf2_s.o truncdfbf2_s.o truncsfbf2_s.o trunchfbf2_s.o eqhf2_s.o enable-execute-stack_s.o unwind-dw2_s.o unwind-dw2-fde-dip_s.o unwind-sjlj_s.o unwind-c_s.o emutls_s.o libgcc.a -lc && rm -f 32/libgcc_s.so && if [ -f 32/libgcc_s.so.1 ]; then mv -f 32/libgcc_s.so.1 32/libgcc_s.so.1.backup; else true; fi && mv 32/libgcc_s.so.1.tmp 32/libgcc_s.so.1 && (echo "/* GNU ld script"; echo "   Use the shared library, but some functions are only in"; echo "   the static library.  */"; echo "GROUP ( libgcc_s.so.1 -lgcc )" ) > 32/libgcc_s.so
xgcc: error: -fuse-linker-plugin is not supported in this configuration
make[4]: *** [Makefile:998: libgcc_s.so] Error 1
make[4]: Leaving directory '/var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/build-jit/x86_64-pc-linux-gnu/32/libgcc'
make[3]: *** [Makefile:1214: multi-do] Error 1
make[2]: *** [Makefile:127: all-multi] Error 2
make[1]: *** [Makefile:12201: all-target-libgcc] Error 2
make: *** [Makefile:1022: all] Error 2


To fix this. I add CFLAGS="${CFLAGS} -fno-use-linker-pligin" CXXFLAGS="${CXXFLAGS} -fno-use-linker-pligin" to /etc/portage/env/sys-devel/gcc.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-01-19 12:42:59 UTC
Missing build.log & emerge --info.
Comment 2 stefan11111 2024-01-19 12:48:20 UTC
Created attachment 882624 [details]
Gcc build log
Comment 3 stefan11111 2024-01-19 12:49:46 UTC
Created attachment 882625 [details]
emerge --info
Comment 4 Arsen Arsenović gentoo-dev 2024-01-20 16:48:06 UTC
this gcc-build-logs.tar is missing gcc/config.log somehow..
Comment 5 Arsen Arsenović gentoo-dev 2024-01-20 16:57:54 UTC
could you post the output of /usr/x86_64-pc-linux-gnu/bin/ld --version ?

also check whether the build dir has liblto_plugin.la anywhere ( find /var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/gcc-13-20230826 -name liblto_plugin.la )
Comment 6 stefan11111 2024-01-21 09:16:35 UTC
(In reply to Arsen Arsenović from comment #5)
> could you post the output of /usr/x86_64-pc-linux-gnu/bin/ld --version ?
> 
> also check whether the build dir has liblto_plugin.la anywhere ( find
> /var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/gcc-13-20230826 -name
> liblto_plugin.la )

$ /usr/x86_64-pc-linux-gnu/bin/ld --version
GNU ld (Gentoo 2.41 p4) 2.41.0
Copyright (C) 2023 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.


$ doas find /var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/gcc-13-20230826 -name liblto_plugin.la
/var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/gcc-13-20230826/liblto_plugin.la


(In reply to Arsen Arsenović from comment #4)
> this gcc-build-logs.tar is missing gcc/config.log somehow..

That's what portage told me to include:

Please include /var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/gcc-build-logs.tar.xz in your bug report.
Comment 7 Arsen Arsenović gentoo-dev 2024-01-22 00:26:26 UTC
could you try finding that config.log in the gcc subdir in the work dir (note, *not* the toplevel configure, the inner gcc/config.{log,status} instead)?  the config.status would be useful too.
Comment 8 stefan11111 2024-01-23 18:15:32 UTC
(In reply to Arsen Arsenović from comment #7)
> could you try finding that config.log in the gcc subdir in the work dir
> (note, *not* the toplevel configure, the inner gcc/config.{log,status}
> instead)?  the config.status would be useful too.

/var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work # ls */config.{log,status}
build/config.log  build/config.status  build-jit/config.log  build-jit/config.status

# ls */*/config.{log,status}
build-jit/c++tools/config.log     build-jit/gcc/config.status   build-jit/libbacktrace/config.log     build-jit/libcc1/config.status   build-jit/libcpp/config.log        build-jit/libdecnumber/config.status
build-jit/c++tools/config.status  build-jit/intl/config.log     build-jit/libbacktrace/config.status  build-jit/libcody/config.log     build-jit/libcpp/config.status     build-jit/libiberty/config.log
build-jit/gcc/config.log          build-jit/intl/config.status  build-jit/libcc1/config.log           build-jit/libcody/config.status  build-jit/libdecnumber/config.log  build-jit/libiberty/config.status

I'll also use this opportunity to ask, should USE="jit" be turned on for gcc?
Does that improve performance?
Comment 9 stefan11111 2024-01-23 18:17:02 UTC
Created attachment 882997 [details]
build/config.log
Comment 10 stefan11111 2024-01-23 18:17:21 UTC
Created attachment 882998 [details]
build/config.status
Comment 11 Arsen Arsenović gentoo-dev 2024-01-23 18:52:03 UTC
as the USE=jit descriptions state, it toggles libgccjit

re, the config.stuff, we need the build/gcc/config.stuff, as I mentioned (though, IMO, you should tar up all of them and post them, to avoid back and forth)
Comment 12 stefan11111 2024-01-23 19:03:02 UTC
(In reply to Arsen Arsenović from comment #11)
> as the USE=jit descriptions state, it toggles libgccjit
> 
> re, the config.stuff, we need the build/gcc/config.stuff, as I mentioned
> (though, IMO, you should tar up all of them and post them, to avoid back and
> forth)

So it does not affect performance.

Seems like USE="jit" is more important here that I thought.
When building without USE="jit", it build correctly.
Comment 13 stefan11111 2024-01-23 19:21:10 UTC
Created attachment 882999 [details]
config-logs.xz
Comment 14 stefan11111 2024-01-23 19:22:06 UTC
(In reply to Arsen Arsenović from comment #11)
> as the USE=jit descriptions state, it toggles libgccjit
> 
> re, the config.stuff, we need the build/gcc/config.stuff, as I mentioned
> (though, IMO, you should tar up all of them and post them, to avoid back and
> forth)

Ran :

# tar cvf ./config-logs */{config.*,*/config.*,*/*/config.*,*/*/*/config.*,*/*/*/*/config.*,*/*/*/*/*/config.*}

This should be everything
Comment 15 stefan11111 2024-01-24 10:33:58 UTC
Created attachment 883028 [details, diff]
remove-linker-plugin-check.patch
Comment 16 stefan11111 2024-01-24 10:36:29 UTC
The patch I added as an attachment removes the check for whether or not
-fuse-linker-plugin is supported or not.

However, that's not where the problem comes from.
After applying the patch, the build fails with:

make[4]: Entering directory '/var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/build-jit/x86_64-pc-linux-gnu/32/libgcc'
/var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/build-jit/./gcc/xgcc -B/var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/build-jit/./gcc/ -B/usr/x86_64-pc-linux-gnu/bin/ -B/usr/x86_64-pc-linux-gnu/lib/ -isystem /usr/x86_64-pc-linux-gnu/include -isystem /usr/x86_64-pc-linux-gnu/sys-include    -O2  -g -O2 -O3 -pipe -march=native -fuse-linker-plugin -DIN_GCC -fPIC   -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fpic -mlong-double-80 -DUSE_ELF_SYMVER  -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fno-stack-clash-protection  -shared -nodefaultlibs -Wl,--soname=libgcc_s.so.1 -Wl,--version-script=libgcc.map -Wl,-O1 -Wl,--as-needed  -m32 -o 32/libgcc_s.so.1.tmp -g -O2 -O3 -pipe -march=native -fuse-linker-plugin -m32 -B./ _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s.o _bswapsi2_s.o _bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _divdi3_s.o _moddi3_s.o _divmoddi4_s.o _udivdi3_s.o _umoddi3_s.o _udivmoddi4_s.o _udiv_w_sdiv_s.o cpuinfo_s.o tf-signs_s.o sfp-exceptions_s.o _divhc3_s.o _mulhc3_s.o addtf3_s.o divtf3_s.o eqtf2_s.o getf2_s.o letf2_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o extendhfsf2_s.o extendhfdf2_s.o extendhftf2_s.o extendhfxf2_s.o extendsfdf2_s.o extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o extendbfsf2_s.o trunctfhf2_s.o truncxfhf2_s.o truncdfhf2_s.o truncsfhf2_s.o trunctfsf2_s.o truncdfsf2_s.o trunctfdf2_s.o trunctfxf2_s.o trunctfbf2_s.o truncxfbf2_s.o truncdfbf2_s.o truncsfbf2_s.o trunchfbf2_s.o eqhf2_s.o enable-execute-stack_s.o unwind-dw2_s.o unwind-dw2-fde-dip_s.o unwind-sjlj_s.o unwind-c_s.o emutls_s.o libgcc.a -lc && rm -f 32/libgcc_s.so && if [ -f 32/libgcc_s.so.1 ]; then mv -f 32/libgcc_s.so.1 32/libgcc_s.so.1.backup; else true; fi && mv 32/libgcc_s.so.1.tmp 32/libgcc_s.so.1 && (echo "/* GNU ld script"; echo "
Use the shared library, but some functions are only in"; echo "   the static library.  */"; echo "GROUP ( libgcc_s.so.1 -lgcc )" )
> 32/libgcc_s.so
/usr/x86_64-pc-linux-gnu/bin/ld: -plugin-opt=/var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/build-jit/./gcc/lto-wrapper: error loading plugin: -plugin-opt=/var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/build-jit/./gcc/lto-wrapper: cannot open shared
object file: No such file or directory
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:998: libgcc_s.so] Error 1
make[4]: Leaving directory '/var/tmp/portage/sys-devel/gcc-13.2.1_p20230826/work/build-jit/x86_64-pc-linux-gnu/32/libgcc'
make[3]: *** [Makefile:1214: multi-do] Error 1
make[2]: *** [Makefile:127: all-multi] Error 2
make[1]: *** [Makefile:12201: all-target-libgcc] Error 2
make: *** [Makefile:1022: all] Error 2
Comment 17 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-09-17 23:07:38 UTC
Did you use slibtool? (bug 932245)
Comment 18 stefan11111 2024-09-18 06:20:00 UTC
(In reply to Sam James from comment #17)
> Did you use slibtool? (bug 932245)

No. Regular dev-build/libtool.