Bug 1986141

Summary: Enable LTO when building gcc for RHEL 9
Product: Red Hat Enterprise Linux 9 Reporter: Marek Polacek <mpolacek>
Component: gccAssignee: Marek Polacek <mpolacek>
gcc sub component: system-version QA Contact: Václav Kadlčík <vkadlcik>
Status: CLOSED CURRENTRELEASE Docs Contact:
Severity: unspecified    
Priority: unspecified CC: ahajkova, fweimer, jakub, ohudlick, vkadlcik
Version: 9.0Keywords: FutureFeature, Triaged
Target Milestone: beta   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: gcc-11.2.1-2.1.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-12-07 21:30:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Marek Polacek 2021-07-26 18:17:42 UTC
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>.

Comment 1 Marek Polacek 2021-07-29 17:09:59 UTC
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.

Comment 13 Václav Kadlčík 2021-08-05 07:22:23 UTC
verified: gcc-11.2.1-2.1.el9