Skip to content

Commit a222f96

Browse files
committed
arch: xtensa: use optimization configs
Use optimization configs that come from Kconfig in CMake to set appropriate compiler flags. Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
1 parent 5c34e2c commit a222f96

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/arch/xtensa/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ else()
6161
set(stdlib_flag "-nostdlib")
6262
endif()
6363

64+
if(CONFIG_OPTIMIZE_FOR_PERFORMANCE)
65+
set(optimization_flag "-O2")
66+
elseif(CONFIG_OPTIMIZE_FOR_SIZE)
67+
set(optimization_flag "-Os")
68+
elseif(CONFIG_OPTIMIZE_FOR_DEBUG)
69+
set(optimization_flag "-Og")
70+
elseif(CONFIG_OPTIMIZE_FOR_NONE)
71+
set(optimization_flag "-O0")
72+
endif()
73+
6474
# linker flags
6575
target_link_libraries(sof_options INTERFACE ${stdlib_flag} -Wl,--no-check-sections -ucall_user_start -Wl,-static)
6676

@@ -77,7 +87,7 @@ target_compile_options(sof_options INTERFACE ${stdlib_flag} -fno-inline-function
7787
# better to have set of default flags and change it only for special cases
7888
# 3) custom function that is used instead of target_sources and sets flags
7989
# for each added source based on file extension
80-
target_compile_options(sof_options INTERFACE $<$<COMPILE_LANGUAGE:C>:-O2 -g -Wall -Werror -Wl,-EL -Wmissing-prototypes -Wpointer-arith -mtext-section-literals>)
90+
target_compile_options(sof_options INTERFACE $<$<COMPILE_LANGUAGE:C>: ${optimization_flag} -g -Wall -Werror -Wl,-EL -Wmissing-prototypes -Wpointer-arith -mtext-section-literals>)
8191

8292
if(BUILD_UNIT_TESTS)
8393
# rest of this file is not needed for unit tests

0 commit comments

Comments
 (0)