Bug 1986141 - Enable LTO when building gcc for RHEL 9
Summary: Enable LTO when building gcc for RHEL 9
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: gcc
Version: 9.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: beta
: ---
Assignee: Marek Polacek
QA Contact: Václav Kadlčík
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-07-26 18:17 UTC by Marek Polacek
Modified: 2023-07-18 14:25 UTC (History)
5 users (show)

Fixed In Version: gcc-11.2.1-2.1.el9
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-12-07 21:30:47 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.