Skip to content

cmake: Fix compilation options for kobject_hash*.c #84636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
31 changes: 21 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1094,10 +1094,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(GEN_KOBJ_LIST ${ZEPHYR_BASE}/scripts/build/gen_kobject_list.py)
set(PROCESS_GPERF ${ZEPHYR_BASE}/scripts/build/process_gperf.py)
Expand Down Expand Up @@ -1297,11 +1306,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>
Expand Down Expand Up @@ -1509,9 +1520,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>
Expand Down
6 changes: 6 additions & 0 deletions cmake/compiler/arcmwdt/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,9 @@ set_compiler_property(PROPERTY warning_shadow_variables)

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 changes: 6 additions & 0 deletions cmake/compiler/compiler_flags_template.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,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 changes: 6 additions & 0 deletions cmake/compiler/gcc/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,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