Browse Source

cmake: Fix compilation options for kobject_hash*.c

Rework how the compilation-options for the gperf generated
kobject_hash*.c files are put together to fix problems with SHELL:
and cmake-list separators handling.

zephyr_get_compile_options_for_lang_as_string() returns the set of
options as a cmake generator expression string which is cumbersome to
edit. This caused the command line for the IAR toolchain to have broken
SHELL: entries, and other some command line entries being postfixed by
"gnu".

This also adds CMake compiler properties for no_function_sections and
no_data_sections options

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
pull/90908/head
Björn Bergman 7 months ago committed by Anas Nashif
parent
commit
bb797ab421
  1. 31
      CMakeLists.txt
  2. 6
      cmake/compiler/arcmwdt/compiler_flags.cmake
  3. 6
      cmake/compiler/compiler_flags_template.cmake
  4. 6
      cmake/compiler/gcc/compiler_flags.cmake

31
CMakeLists.txt

@ -1104,10 +1104,19 @@ if(CONFIG_CODE_DATA_RELOCATION) @@ -1104,10 +1104,19 @@ if(CONFIG_CODE_DATA_RELOCATION)
endif()
if(CONFIG_USERSPACE)
zephyr_get_compile_options_for_lang_as_string(C compiler_flags_priv)
# Go for raw properties here since zephyr_get_compile_options_for_lang()
# processes the list of options, and wraps it in a $<JOIN thing. When
# generating the build systems this leads to some interesting command lines,
# with SHELL: not being present and other "random" list-join related issues
# (e.g. for IAR toolchains the lists were joined with "gnu" postfixed on a
# bunch of entries).
get_property(compiler_flags_priv TARGET zephyr_interface PROPERTY INTERFACE_COMPILE_OPTIONS)
string(REPLACE "$<TARGET_PROPERTY:compiler,coverage>" ""
NO_COVERAGE_FLAGS "${compiler_flags_priv}"
)
KOBJECT_HASH_COMPILE_OPTIONS "${compiler_flags_priv}")
list(APPEND KOBJECT_HASH_COMPILE_OPTIONS
$<TARGET_PROPERTY:compiler,no_function_sections>
$<TARGET_PROPERTY:compiler,no_data_sections>)
set(PROCESS_GPERF ${ZEPHYR_BASE}/scripts/build/process_gperf.py)
endif()
@ -1305,11 +1314,13 @@ if(CONFIG_USERSPACE) @@ -1305,11 +1314,13 @@ if(CONFIG_USERSPACE)
add_library(
kobj_prebuilt_hash_output_lib
OBJECT ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_PREBUILT_HASH_OUTPUT_SRC}
)
)
set_source_files_properties(${KOBJECT_PREBUILT_HASH_OUTPUT_SRC}
PROPERTIES COMPILE_FLAGS
"${NO_COVERAGE_FLAGS} -fno-function-sections -fno-data-sections")
# set_target_properties sets ALL properties, target_compile_options() adds
# and KOBJECT_HASH_COMPILE_OPTIONS contains all the options.
set_target_properties(kobj_prebuilt_hash_output_lib PROPERTIES
COMPILE_OPTIONS "${KOBJECT_HASH_COMPILE_OPTIONS}"
)
target_compile_definitions(kobj_prebuilt_hash_output_lib
PRIVATE $<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_DEFINITIONS>
@ -1514,9 +1525,9 @@ if(CONFIG_USERSPACE) @@ -1514,9 +1525,9 @@ if(CONFIG_USERSPACE)
OBJECT ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_OUTPUT_SRC}
)
set_source_files_properties(${KOBJECT_HASH_OUTPUT_SRC}
PROPERTIES COMPILE_FLAGS
"${NO_COVERAGE_FLAGS} -fno-function-sections -fno-data-sections")
set_target_properties(kobj_hash_output_lib PROPERTIES
COMPILE_OPTIONS "${KOBJECT_HASH_COMPILE_OPTIONS}"
)
target_compile_definitions(kobj_hash_output_lib
PRIVATE $<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_DEFINITIONS>

6
cmake/compiler/arcmwdt/compiler_flags.cmake

@ -215,3 +215,9 @@ set_compiler_property(PROPERTY warning_no_array_bounds) @@ -215,3 +215,9 @@ set_compiler_property(PROPERTY warning_no_array_bounds)
set_compiler_property(PROPERTY no_builtin -fno-builtin)
set_compiler_property(PROPERTY no_builtin_malloc -fno-builtin-malloc)
# Compiler flag for not placing functions in their own sections:
set_compiler_property(PROPERTY no_function_sections "-fno-function-sections")
# Compiler flag for not placing variables in their own sections:
set_compiler_property(PROPERTY no_data_sections "-fno-data-sections")

6
cmake/compiler/compiler_flags_template.cmake

@ -161,3 +161,9 @@ set_compiler_property(PROPERTY include_file) @@ -161,3 +161,9 @@ set_compiler_property(PROPERTY include_file)
set_compiler_property(PROPERTY cmse)
set_property(TARGET asm PROPERTY cmse)
# Compiler flag for not placing functions in their own sections:
set_compiler_property(PROPERTY no_function_sections)
# Compiler flag for not placing variables in their own sections:
set_compiler_property(PROPERTY no_data_sections)

6
cmake/compiler/gcc/compiler_flags.cmake

@ -266,3 +266,9 @@ set_compiler_property(PROPERTY include_file -include) @@ -266,3 +266,9 @@ set_compiler_property(PROPERTY include_file -include)
set_compiler_property(PROPERTY cmse -mcmse)
set_property(TARGET asm PROPERTY cmse -mcmse)
# Compiler flag for not placing functions in their own sections:
set_compiler_property(PROPERTY no_function_sections "-fno-function-sections")
# Compiler flag for not placing variables in their own sections:
set_compiler_property(PROPERTY no_data_sections "-fno-data-sections")

Loading…
Cancel
Save