toolchain: Add COMPILER_FREESTANDING to control use of -ffreestanding

Add an explicit compiler configuration, COMPILER_FREESTANDING, which
controls whether the compiler should operate in freestanding or hosted mode
(according to the C and C++ language specifications.

This depends on having a C library which conforms with the language
specification, and the minimal C library does not. Have the minimal C
library select COMPILER_FREESTANDING to continue using freestanding mode
with that library.

For other C libraries, leave this disabled by default while allowing users
to enable it if they want to go back to the previous configuration.

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2023-02-08 14:56:50 -08:00 committed by Stephanos Ioannidis
commit 6c5d806bcb
3 changed files with 11 additions and 1 deletions

View file

@ -282,7 +282,7 @@ endif()
# @Intent: Set compiler specific macro inclusion of AUTOCONF_H
zephyr_compile_options("SHELL: $<TARGET_PROPERTY:compiler,imacros> ${AUTOCONF_H}")
if(NOT CONFIG_PICOLIBC)
if(CONFIG_COMPILER_FREESTANDING)
# @Intent: Set compiler specific flag for bare metal freestanding option
zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,freestanding>>)
zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:$<TARGET_PROPERTY:compiler,freestanding>>)