Currently, our gcc build filters out LTO flags: OPT_FLAGS=`echo $OPT_FLAGS|sed -e 's/-flto=auto//g;s/-flto//g;s/-ffat-lto-objects//g'` we ought to be able to do away with that and build with LTO on. Part of <https://issues.redhat.com/browse/RHELPLAN-54371>.
GCC is now built with --with-build-config=bootstrap-lto --enable-link-serialization=1. config/bootstrap-lto.mk enables these flags: # This option enables LTO for stage2 and stage3 in slim mode STAGE2_CFLAGS += -flto=jobserver -frandom-seed=1 STAGE3_CFLAGS += -flto=jobserver -frandom-seed=1 STAGEprofile_CFLAGS += -flto=jobserver -frandom-seed=1 STAGEtrain_CFLAGS += -flto=jobserver -frandom-seed=1 STAGEfeedback_CFLAGS += -flto=jobserver -frandom-seed=1 checking the build.log: /prev-gcc/ -B/usr/x86_64-redhat-linux/bin/ -nostdinc++ -B/builddir/build/BUILD/gcc-11.2.1-20210728/obj-x86_64-redhat-linux/prev-x86_64-redhat-linux/libstdc++-v3/src/.libs -B/builddir/build/BUILD/gcc-11.2.1-20210728/obj-x86_64-redhat-linux/prev-x86_64-redhat-linux/libstdc++-v3/libsupc++/.libs -I/builddir/build/BUILD/gcc-11.2.1-20210728/obj-x86_64-redhat-linux/prev-x86_64-redhat-linux/libstdc++-v3/include/x86_64-redhat-linux -I/builddir/build/BUILD/gcc-11.2.1-20210728/obj-x86_64-redhat-linux/prev-x86_64-redhat-linux/libstdc++-v3/include -I/builddir/build/BUILD/gcc-11.2.1-20210728/libstdc++-v3/libsupc++ -L/builddir/build/BUILD/gcc-11.2.1-20210728/obj-x86_64-redhat-linux/prev-x86_64-redhat-linux/libstdc++-v3/src/.libs -L/builddir/build/BUILD/gcc-11.2.1-20210728/obj-x86_64-redhat-linux/prev-x86_64-redhat-linux/libstdc++-v3/libsupc++/.libs -fno-PIE -c -DIN_GCC_FRONTEND -O2 -fexceptions -g -grecord-gcc-switches -Wall -Wformat-security -Wp,-D_GLIBCXX_ASSERTIONS -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fprofile-use -fprofile-reproducible=parallel-runs -flto=jobserver -frandom-seed=1 -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -Icp -I../../gcc -I../../gcc/cp -I../../gcc/../include -I../../gcc/../libcpp/include -I../../gcc/../libcody -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/../libbacktrace -o cp/parser.o -MT cp/parser.o -MMD -MP -MF cp/.deps/parser.TPo ../../gcc/cp/parser.c I see that "-flto=jobserver -frandom-seed=1" is there.
verified: gcc-11.2.1-2.1.el9