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>
This commit is contained in:
parent
e87e0542b8
commit
bb797ab421
4 changed files with 39 additions and 10 deletions
|
@ -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)
|
|||
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)
|
|||
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>
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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…
Add table
Add a link
Reference in a new issue