Skip to content

Commit 0cadd94

Browse files
committed
cmake: move specs compiler and linker flags to toolchain properties
Moving specs argument to compiler and linker properties so that the compiler and linker in use can decide how the flags are mapped / handled for the compiler and linker in use. This avoids specifying `--specs=spec.picolibc` for clang which prints a warning about an unused argument. Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent 669d625 commit 0cadd94

File tree

6 files changed

+16
-3
lines changed

6 files changed

+16
-3
lines changed

cmake/compiler/clang/compiler_flags.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,5 @@ set_compiler_property(PROPERTY warning_error_coding_guideline
125125
)
126126

127127
set_compiler_property(PROPERTY no_global_merge "-mno-global-merge")
128+
129+
set_compiler_property(PROPERTY specs)

cmake/compiler/compiler_flags_template.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,7 @@ set_compiler_property(PROPERTY warning_shadow_variables)
139139
# Compiler flags to avoid recognizing built-in functions
140140
set_compiler_property(PROPERTY no_builtin)
141141
set_compiler_property(PROPERTY no_builtin_malloc)
142+
143+
# Compiler flag for defining specs. Used only by gcc, other compilers may keep
144+
# this undefined.
145+
set_compiler_property(PROPERTY specs)

cmake/compiler/gcc/compiler_flags.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,5 @@ set_compiler_property(PROPERTY warning_shadow_variables -Wshadow)
241241

242242
set_compiler_property(PROPERTY no_builtin -fno-builtin)
243243
set_compiler_property(PROPERTY no_builtin_malloc -fno-builtin-malloc)
244+
245+
set_compiler_property(PROPERTY specs -specs=)

cmake/linker/ld/gcc/linker_flags.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ add_link_options(-gdwarf-4)
1515

1616
# Extra warnings options for twister run
1717
set_property(TARGET linker PROPERTY warnings_as_errors -Wl,--fatal-warnings)
18+
19+
set_linker_property(PROPERTY specs -specs=)

cmake/linker/linker_flags_template.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,7 @@ set_property(TARGET linker PROPERTY no_relax)
4949

5050
# Linker flag for enabling relaxation of address optimization for jump calls.
5151
set_property(TARGET linker PROPERTY relax)
52+
53+
# Linker flag for defining specs. Defined only by gcc, when gcc is used as
54+
# front-end for ld.
55+
set_compiler_property(PROPERTY specs)

lib/libc/picolibc/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ if(NOT CONFIG_PICOLIBC_USE_MODULE)
1515
# Use picolibc provided with the toolchain. This requires a new enough
1616
# toolchain so that the version of picolibc supports auto-detecting a
1717
# Zephyr build (via the __ZEPHYR__ macro) to expose the Zephyr C API
18-
19-
zephyr_compile_options(--specs=picolibc.specs)
20-
zephyr_libc_link_libraries(--specs=picolibc.specs)
18+
zephyr_compile_options(PROPERTY specs picolibc.specs)
19+
zephyr_link_libraries(PROPERTY specs picolibc.specs)
2120
if(CONFIG_PICOLIBC_IO_FLOAT)
2221
zephyr_compile_definitions(PICOLIBC_DOUBLE_PRINTF_SCANF)
2322
zephyr_link_libraries(-DPICOLIBC_DOUBLE_PRINTF_SCANF)

0 commit comments

Comments
 (0)