Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,13 @@
toolchain_linker_add_compiler_options(${simple_options})

if(CONFIG_LTO)
zephyr_compile_options($<TARGET_PROPERTY:compiler,optimization_lto>)
add_link_options($<TARGET_PROPERTY:linker,lto_arguments>)
if(CONFIG_LTO_SINGLE_THREADED)
zephyr_compile_options($<TARGET_PROPERTY:compiler,optimization_lto_st>)
add_link_options($<TARGET_PROPERTY:linker,lto_arguments_st>)
else()
zephyr_compile_options($<TARGET_PROPERTY:compiler,optimization_lto>)
add_link_options($<TARGET_PROPERTY:linker,lto_arguments>)
endif()
endif()

if(CONFIG_STD_C23)
Expand Down Expand Up @@ -409,7 +414,7 @@
zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:$<TARGET_PROPERTY:compiler,freestanding>>)
endif()

if (CONFIG_PICOLIBC AND NOT CONFIG_PICOLIBC_IO_FLOAT)

Check failure on line 417 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

CMakeLists.txt:417 CMakeStyle
# @Intent: Set compiler specific flag to disable printf-related optimizations
zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,no_printf_return_value>>)
endif()
Expand Down Expand Up @@ -1129,7 +1134,7 @@

get_property(OUTPUT_FORMAT GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT)

if (CONFIG_CODE_DATA_RELOCATION)

Check failure on line 1137 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

CMakeLists.txt:1137 CMakeStyle
set(CODE_RELOCATION_DEP code_relocation_source_lib)
endif() # CONFIG_CODE_DATA_RELOCATION

Expand Down Expand Up @@ -2106,7 +2111,7 @@
)
endif()

if (CONFIG_LLEXT AND CONFIG_LLEXT_EXPORT_BUILTINS_BY_SLID)

Check failure on line 2114 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

CMakeLists.txt:2114 CMakeStyle
#slidgen must be the first post-build command to be executed
#on the Zephyr ELF to ensure that all other commands, such as
#binary file generation, are operating on a preparated ELF.
Expand Down Expand Up @@ -2172,7 +2177,7 @@
endif()

# Generate USB-C VIF policies in XML format
if (CONFIG_BUILD_OUTPUT_VIF)

Check failure on line 2180 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

CMakeLists.txt:2180 CMakeStyle
include(${CMAKE_CURRENT_LIST_DIR}/cmake/vif.cmake)
endif()

Expand Down Expand Up @@ -2223,7 +2228,7 @@
--build-header ${PROJECT_BINARY_DIR}/include/generated/zephyr/version.h
)

if (NOT CONFIG_LOG_DICTIONARY_DB_TARGET)

Check failure on line 2231 in CMakeLists.txt

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

CMakeLists.txt:2231 CMakeStyle
# If not using a separate target for generating logging dictionary
# database, add the generation to post build command to make sure
# the database is actually being generated.
Expand Down
8 changes: 8 additions & 0 deletions Kconfig.zephyr
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,14 @@ config LTO
help
This option enables Link Time Optimization.

config LTO_SINGLE_THREADED
bool "Single-threaded LTO"
depends on LTO
help
This option instructs the linker to use a single thread to process
LTO. See the following issue for more info:
https://github.com/zephyrproject-rtos/sdk-ng/issues/1038

config COMPILER_WARNINGS_AS_ERRORS
bool "Treat warnings as errors"
help
Expand Down
3 changes: 3 additions & 0 deletions cmake/compiler/compiler_flags_template.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ set_compiler_property(PROPERTY optimization_size_aggressive)

set_compiler_property(PROPERTY optimization_fast)

set_compiler_property(PROPERTY optimization_lto)
set_compiler_property(PROPERTY optimization_lto_st)

#######################################################
# This section covers flags related to warning levels #
#######################################################
Expand Down
1 change: 1 addition & 0 deletions cmake/compiler/gcc/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

if(CMAKE_C_COMPILER_VERSION GREATER_EQUAL "4.5.0")
set_compiler_property(PROPERTY optimization_lto -flto=auto)
set_compiler_property(PROPERTY optimization_lto_st -flto=1)
set_compiler_property(PROPERTY prohibit_lto -fno-lto)
endif()

Expand Down Expand Up @@ -113,7 +114,7 @@
# GCC compiler flags for C standard. The specific standard must be appended by user.
set_compiler_property(PROPERTY cstd -std=)

if (NOT CONFIG_NEWLIB_LIBC AND

Check failure on line 117 in cmake/compiler/gcc/compiler_flags.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/compiler/gcc/compiler_flags.cmake:117 CMakeStyle
NOT (CONFIG_PICOLIBC AND NOT CONFIG_PICOLIBC_USE_MODULE) AND
NOT COMPILER STREQUAL "xcc" AND
NOT COMPILER STREQUAL "xt-clang" AND
Expand Down
1 change: 1 addition & 0 deletions cmake/linker/ld/linker_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ endif()
set_property(TARGET linker PROPERTY partial_linking "-r")

set_property(TARGET linker PROPERTY lto_arguments -flto=auto -fno-ipa-sra -ffunction-sections -fdata-sections)
set_property(TARGET linker PROPERTY lto_arguments_st -flto=1 -fno-ipa-sra -ffunction-sections -fdata-sections)

check_set_linker_property(TARGET linker PROPERTY no_relax ${LINKERFLAGPREFIX},--no-relax)

Expand Down
4 changes: 4 additions & 0 deletions cmake/linker/linker_flags_template.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ set_property(TARGET linker PROPERTY no_relax)
# Linker flag for enabling relaxation of address optimization for jump calls.
set_property(TARGET linker PROPERTY relax)

# Linker flags for Link Time Optimizations (LTO)
set_property(TARGET linker PROPERTY lto_arguments)
set_property(TARGET linker PROPERTY lto_arguments_st)

# Linker flag for defining specs. Defined only by gcc, when gcc is used as
# front-end for ld.
set_compiler_property(PROPERTY specs)
1 change: 1 addition & 0 deletions cmake/linker/lld/linker_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ endif()
set_property(TARGET linker PROPERTY no_position_independent "${LINKERFLAGPREFIX},--no-pie")

set_property(TARGET linker PROPERTY lto_arguments)
set_property(TARGET linker PROPERTY lto_arguments_st)

check_set_linker_property(TARGET linker PROPERTY sort_alignment ${LINKERFLAGPREFIX},--sort-section=alignment)

Expand Down
2 changes: 1 addition & 1 deletion dts/vendor/nordic/nrf54l_05_10_15.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@
gpio-controller;
reg = <0x10a000 0x300>;
#gpio-cells = <2>;
ngpios = <5>;
ngpios = <7>;
status = "disabled";
port = <0>;
gpiote-instance = <&gpiote30>;
Expand Down
14 changes: 14 additions & 0 deletions tests/kernel/common/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,17 @@ tests:
integration_platforms:
- qemu_x86
- mps2/an385
kernel.common.lto.singlethreaded:
platform_key:
- arch
# CONFIG_CODE_DATA_RELOCATION causes a build error (issue #69730)
filter: CONFIG_ISR_TABLES_LOCAL_DECLARATION_SUPPORTED and not CONFIG_CODE_DATA_RELOCATION
tags: lto
extra_configs:
- CONFIG_TEST_USERSPACE=n
- CONFIG_ISR_TABLES_LOCAL_DECLARATION=y
- CONFIG_LTO=y
- CONFIG_LTO_SINGLE_THREADED=y
integration_platforms:
- qemu_x86
- mps2/an385
9 changes: 9 additions & 0 deletions tests/misc/test_build/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ tests:
- CONFIG_ISR_TABLES_LOCAL_DECLARATION=y
- CONFIG_LTO=y
- CONFIG_PICOLIBC_USE_MODULE=y
buildsystem.lto.st.picolibc_module:
build_only: true
platform_allow:
- nucleo_f746zg
extra_configs:
- CONFIG_ISR_TABLES_LOCAL_DECLARATION=y
- CONFIG_LTO=y
- CONFIG_LTO_SINGLE_THREADED=y
- CONFIG_PICOLIBC_USE_MODULE=y
buildsystem.arm.null_pointer_exception_detection_dwt:
build_only: true
platform_allow:
Expand Down
Loading