cmake: compiler: Add compiler property for no-builtin
Abstracts these flags for multiple toolchain support Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
This commit is contained in:
parent
679d82c484
commit
a3ff19a39e
7 changed files with 18 additions and 6 deletions
|
@ -94,12 +94,12 @@ elseif (CONFIG_NATIVE_LIBRARY)
|
||||||
|
|
||||||
# Do not use the C library from this compiler/host,
|
# Do not use the C library from this compiler/host,
|
||||||
# but still use the basic compiler headers
|
# but still use the basic compiler headers
|
||||||
# -fno-builtin to avoid the compiler using builtin replacements for std library functions
|
# no_builtin to avoid the compiler using builtin replacements for std library functions
|
||||||
zephyr_compile_options(
|
zephyr_compile_options(
|
||||||
-nostdinc
|
-nostdinc
|
||||||
-isystem ${COMPILER_OWN_INCLUDE_PATH}
|
-isystem ${COMPILER_OWN_INCLUDE_PATH}
|
||||||
$<TARGET_PROPERTY:compiler,freestanding>
|
$<TARGET_PROPERTY:compiler,freestanding>
|
||||||
-fno-builtin
|
$<TARGET_PROPERTY:compiler,no_builtin>
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -206,3 +206,6 @@ endif()
|
||||||
|
|
||||||
# Remove after testing that -Wshadow works
|
# Remove after testing that -Wshadow works
|
||||||
set_compiler_property(PROPERTY warning_shadow_variables)
|
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)
|
||||||
|
|
|
@ -133,3 +133,7 @@ set_compiler_property(PROPERTY no_global_merge)
|
||||||
|
|
||||||
# Compiler flag for warning about shadow variables
|
# Compiler flag for warning about shadow variables
|
||||||
set_compiler_property(PROPERTY warning_shadow_variables)
|
set_compiler_property(PROPERTY warning_shadow_variables)
|
||||||
|
|
||||||
|
# Compiler flags to avoid recognizing built-in functions
|
||||||
|
set_compiler_property(PROPERTY no_builtin)
|
||||||
|
set_compiler_property(PROPERTY no_builtin_malloc)
|
||||||
|
|
|
@ -227,3 +227,6 @@ set_compiler_property(PROPERTY no_position_independent
|
||||||
set_compiler_property(PROPERTY no_global_merge "")
|
set_compiler_property(PROPERTY no_global_merge "")
|
||||||
|
|
||||||
set_compiler_property(PROPERTY warning_shadow_variables -Wshadow)
|
set_compiler_property(PROPERTY warning_shadow_variables -Wshadow)
|
||||||
|
|
||||||
|
set_compiler_property(PROPERTY no_builtin -fno-builtin)
|
||||||
|
set_compiler_property(PROPERTY no_builtin_malloc -fno-builtin-malloc)
|
||||||
|
|
|
@ -8,4 +8,4 @@ zephyr_library_sources_ifdef(CONFIG_COMMON_LIBC_MALLOC source/stdlib/malloc.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_COMMON_LIBC_STRNLEN source/string/strnlen.c)
|
zephyr_library_sources_ifdef(CONFIG_COMMON_LIBC_STRNLEN source/string/strnlen.c)
|
||||||
|
|
||||||
# Prevent compiler from optimizing calloc into an infinite recursive call
|
# Prevent compiler from optimizing calloc into an infinite recursive call
|
||||||
zephyr_library_cc_option(-fno-builtin-malloc)
|
zephyr_library_compile_options($<TARGET_PROPERTY:compiler,no_builtin_malloc>)
|
||||||
|
|
|
@ -7,7 +7,7 @@ zephyr_library()
|
||||||
set(GEN_DIR ${ZEPHYR_BINARY_DIR}/include/generated)
|
set(GEN_DIR ${ZEPHYR_BINARY_DIR}/include/generated)
|
||||||
set(STRERROR_TABLE_H ${GEN_DIR}/libc/minimal/strerror_table.h)
|
set(STRERROR_TABLE_H ${GEN_DIR}/libc/minimal/strerror_table.h)
|
||||||
|
|
||||||
zephyr_library_cc_option(-fno-builtin)
|
zephyr_library_compile_options($<TARGET_PROPERTY:compiler,no_builtin>)
|
||||||
|
|
||||||
zephyr_library_sources(
|
zephyr_library_sources(
|
||||||
source/stdlib/atoi.c
|
source/stdlib/atoi.c
|
||||||
|
|
|
@ -547,7 +547,8 @@ target_compile_definitions(ot-config INTERFACE
|
||||||
# libraries do not include this header. So we add the defines to all
|
# libraries do not include this header. So we add the defines to all
|
||||||
# OpenThread files through the gcc flag -imacros instead.
|
# OpenThread files through the gcc flag -imacros instead.
|
||||||
target_compile_options(ot-config INTERFACE
|
target_compile_options(ot-config INTERFACE
|
||||||
$<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_OPTIONS> -fno-builtin
|
$<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_OPTIONS>
|
||||||
|
$<TARGET_PROPERTY:compiler,no_builtin>
|
||||||
-imacros ${AUTOCONF_H}
|
-imacros ${AUTOCONF_H}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -600,7 +601,8 @@ endif()
|
||||||
|
|
||||||
if(CONFIG_OPENTHREAD_SETTINGS_RAM)
|
if(CONFIG_OPENTHREAD_SETTINGS_RAM)
|
||||||
target_compile_options(openthread-platform-utils PRIVATE
|
target_compile_options(openthread-platform-utils PRIVATE
|
||||||
$<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_OPTIONS> -fno-builtin)
|
$<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_OPTIONS>
|
||||||
|
$<TARGET_PROPERTY:compiler,no_builtin>)
|
||||||
add_dependencies(openthread-platform-utils syscall_list_h_target)
|
add_dependencies(openthread-platform-utils syscall_list_h_target)
|
||||||
|
|
||||||
list(APPEND ot_libs openthread-platform-utils-static)
|
list(APPEND ot_libs openthread-platform-utils-static)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue