File tree Expand file tree Collapse file tree 7 files changed +25
-2
lines changed
Expand file tree Collapse file tree 7 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -311,8 +311,13 @@ compiler_simple_options(simple_options)
311311toolchain_linker_add_compiler_options(${simple_options} )
312312
313313if (CONFIG_LTO)
314- zephyr_compile_options($<TARGET_PROPERTY:compiler,optimization_lto>)
315- add_link_options ($<TARGET_PROPERTY:linker,lto_arguments>)
314+ if (CONFIG_LTO_SINGLE_THREADED)
315+ zephyr_compile_options($<TARGET_PROPERTY:compiler,optimization_lto_st>)
316+ add_link_options ($<TARGET_PROPERTY:linker,lto_arguments_st>)
317+ else ()
318+ zephyr_compile_options($<TARGET_PROPERTY:compiler,optimization_lto>)
319+ add_link_options ($<TARGET_PROPERTY:linker,lto_arguments>)
320+ endif ()
316321endif ()
317322
318323if (CONFIG_STD_C23)
Original file line number Diff line number Diff line change @@ -529,6 +529,14 @@ config LTO
529529 help
530530 This option enables Link Time Optimization.
531531
532+ config LTO_SINGLE_THREADED
533+ bool "Single-threaded LTO"
534+ depends on LTO
535+ help
536+ This option instructs the linker to use a single thread to process
537+ LTO. See the following issue for more info:
538+ https://github.com/zephyrproject-rtos/sdk-ng/issues/1038
539+
532540config COMPILER_WARNINGS_AS_ERRORS
533541 bool "Treat warnings as errors"
534542 help
Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ set_compiler_property(PROPERTY optimization_size_aggressive)
1717
1818set_compiler_property(PROPERTY optimization_fast)
1919
20+ set_compiler_property(PROPERTY optimization_lto)
21+ set_compiler_property(PROPERTY optimization_lto_st)
22+
2023#######################################################
2124# This section covers flags related to warning levels #
2225#######################################################
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ set_compiler_property(PROPERTY optimization_fast -Ofast)
2525
2626if (CMAKE_C_COMPILER_VERSION GREATER_EQUAL "4.5.0" )
2727 set_compiler_property(PROPERTY optimization_lto -flto=auto)
28+ set_compiler_property(PROPERTY optimization_lto_st -flto=1)
2829 set_compiler_property(PROPERTY prohibit_lto -fno-lto)
2930endif ()
3031
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ endif()
4343set_property (TARGET linker PROPERTY partial_linking "-r" )
4444
4545set_property (TARGET linker PROPERTY lto_arguments -flto=auto -fno-ipa-sra -ffunction-sections -fdata-sections)
46+ set_property (TARGET linker PROPERTY lto_arguments_st -flto=1 -fno-ipa-sra -ffunction-sections -fdata-sections)
4647
4748check_set_linker_property(TARGET linker PROPERTY no_relax ${LINKERFLAGPREFIX} ,--no -relax)
4849
Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ set_property(TARGET linker PROPERTY no_relax)
5050# Linker flag for enabling relaxation of address optimization for jump calls.
5151set_property (TARGET linker PROPERTY relax)
5252
53+ # Linker flags for Link Time Optimizations (LTO)
54+ set_property (TARGET linker PROPERTY lto_arguments)
55+ set_property (TARGET linker PROPERTY lto_arguments_st)
56+
5357# Linker flag for defining specs. Defined only by gcc, when gcc is used as
5458# front-end for ld.
5559set_compiler_property(PROPERTY specs)
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ endif()
1414set_property (TARGET linker PROPERTY no_position_independent "${LINKERFLAGPREFIX} ,--no-pie" )
1515
1616set_property (TARGET linker PROPERTY lto_arguments)
17+ set_property (TARGET linker PROPERTY lto_arguments_st)
1718
1819check_set_linker_property(TARGET linker PROPERTY sort_alignment ${LINKERFLAGPREFIX} ,--sort -section=alignment)
1920
You can’t perform that action at this time.
0 commit comments