diff options
author | Vadim Sukhomlinov <sukhomlinov@google.com> | 2021-10-11 20:31:29 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-10-14 07:02:54 +0000 |
commit | b72f2a1c948ad6e1a5a4402cf07121d815400d58 (patch) | |
tree | 54fd8c63e8ec4295e4800dac6e368fff4fa580fe | |
parent | 31bf4f49ecbbeb2ce4f4d86c334d4c3fa4144a26 (diff) | |
download | chrome-ec-b72f2a1c948ad6e1a5a4402cf07121d815400d58.tar.gz |
cr50: add run-time detection of gcc version to support gcc 11.2 LTO
With planned upgrade to gcc 11.2 we need to make sure it will not fail
cr50 build as it will be a reason to revert. gcc 11.2 gives us 1768 b
back after TPM2 LTO, but it changes default linker behavior and produce
LTO object file during partial link unless -flinker-output=nolto-rel is
used. This option however fail 8.3 build.
Also, gcc 11.2 introduced new optimization path IPA modref which doesn't
play nice with LTO and partial link used together, causing gcc crash.
To overcome this issue add -fno-ipa-modref when gcc 11.2 is used. This
results in almost no impact on code size.
BUG=none
TEST=make BOARD=cr50 tested with gcc 8.3 and gcc 11.2
Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com>
Change-Id: I78a3b3403e84dc4a426dede02b399d9d249ece81
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3218577
Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org>
-rw-r--r-- | board/cr50/build.mk | 3 | ||||
-rw-r--r-- | core/cortex-m/build.mk | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/board/cr50/build.mk b/board/cr50/build.mk index a7bde7a688..f92a527ad8 100644 --- a/board/cr50/build.mk +++ b/board/cr50/build.mk @@ -210,7 +210,8 @@ rw_board_deps := $(addsuffix .d, $(RW_FIPS_OBJS)) FIPS_CFLAGS = $(CFLAGS) -frandom-seed=0 -flto=1 -flto-partition=1to1 -fipa-pta\ -fvisibility=hidden -fipa-cp-clone -fweb -ftree-partial-pre\ -flive-range-shrinkage -fgcse-after-reload -fgcse-sm -fgcse-las -fivopts\ - -fpredictive-commoning -freorder-blocks-algorithm=stc + -fpredictive-commoning -freorder-blocks-algorithm=stc\ + $(CFLAGS_LTO_PARTIAL_LINK) $(RW_BD_OUT)/$(FIPS_MODULE): $(RW_FIPS_OBJS) $(FIPS_LD_SCRIPT) @echo " LD $(notdir $@)" diff --git a/core/cortex-m/build.mk b/core/cortex-m/build.mk index 2bcf32317d..1066f71137 100644 --- a/core/cortex-m/build.mk +++ b/core/cortex-m/build.mk @@ -24,6 +24,16 @@ CFLAGS_CPU+=-flto LDFLAGS_EXTRA+=-flto endif +# TODO: remove this workaround once migration to gcc 11.2 completed. +GCC_VERSION := $(shell $(CROSS_COMPILE)gcc -dumpversion) +ifeq ("$(GCC_VERSION)","11.2.0") +# IPA modref pass crashes gcc 11.2 when LTO is used with partial linking +CFLAGS_CPU += -fno-ipa-modref + +# Set an option to force LTO to generate target machine code +export CFLAGS_LTO_PARTIAL_LINK := -flinker-output=nolto-rel +endif + core-y=cpu.o init.o ldivmod.o llsr.o uldivmod.o vecttable.o core-$(CONFIG_AES)+=aes.o core-$(CONFIG_AES_GCM)+=ghash.o |