diff options
author | Yuval Peress <peress@google.com> | 2022-10-17 14:55:46 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-10-18 17:23:23 +0000 |
commit | 88be9ff4c3da020c772ead59d46fb82675a620c2 (patch) | |
tree | df77ae182f3e513bcd7a6664937e33f7cd63b188 | |
parent | c8b1e5a372885e7a49da17ab0014f2c2f3f7b4f3 (diff) | |
download | chrome-ec-88be9ff4c3da020c772ead59d46fb82675a620c2.tar.gz |
flash_reg: Add missing LTO property
This will eventually be factored out to a common library construct
either upstream or in our own extensions.cmake. For now its better
to just have it done locally so that when it is extracted we can show
all the places that are affected.
BRANCH=none
BUG=none
TEST=zmake build --all
Signed-off-by: Yuval Peress <peress@google.com>
Change-Id: I30f86f377d796750b9d80ad4013aff93ab050f28
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3960903
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | common/spi/flash_reg/CMakeLists.txt | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/common/spi/flash_reg/CMakeLists.txt b/common/spi/flash_reg/CMakeLists.txt index 50656f4a26..fda467d2e4 100644 --- a/common/spi/flash_reg/CMakeLists.txt +++ b/common/spi/flash_reg/CMakeLists.txt @@ -10,6 +10,25 @@ if(BOARD STREQUAL unit_testing) else() zephyr_library_named(spi_flash_reg) target_link_libraries(spi_flash_reg PRIVATE cros_ec_interface) + # When LTO is enabled, enable only for the "app" library, which compiles + # and links all Chromium OS sources. + # TODO: Enable LTO for all sources when Zephyr supports it. + # See https://github.com/zephyrproject-rtos/zephyr/issues/2112 + if (DEFINED CONFIG_LTO) + # The Zephyr toolchain generates linker errors if both CONFIG_LTO and + # CONFIG_FPU are used. See b/184302085. + if(("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "zephyr") AND + (DEFINED CONFIG_FPU)) + message(STATUS "Zephyr toolchain and CONFIG_FPU detected: disabling LTO") + else() + set_property( + TARGET + spi_flash_reg + PROPERTY + INTERPROCEDURAL_OPTIMIZATION True + ) + endif() + endif() endif() # Add the sources |