Skip to content

Commit

Permalink
cmake: Toolchain abstraction: Introducing toolchain_cc_freestanding
Browse files Browse the repository at this point in the history
The macro is intended to abstract the -ffreestanding compiler option
which tells the compiler that this is a bare metal env. The option is
compiler and thus toolchain specific, but this macro leaves it up to
the toolchain to decide the value of the option.

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <[email protected]>
  • Loading branch information
daor-oti authored and aescolar committed Jun 12, 2019
1 parent a946b2c commit faa72b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,12 @@ endif()
# @Intent: Set compiler specific flags for standard C includes
toolchain_cc_nostdinc()

# @Intent: Set compiler specific flag for bare metal freestanding option
toolchain_cc_freestanding()

zephyr_compile_options(
-g # TODO: build configuration enough?
-imacros ${AUTOCONF_H}
-ffreestanding
-fno-common
${TOOLCHAIN_C_FLAGS}
)
Expand Down
7 changes: 7 additions & 0 deletions cmake/compiler/gcc/target_baremetal.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

# See root CMakeLists.txt for description and expectations of these macros

macro(toolchain_cc_nostdinc)

Expand All @@ -11,3 +12,9 @@ macro(toolchain_cc_nostdinc)
endif()

endmacro()

macro(toolchain_cc_freestanding)

zephyr_compile_options(-ffreestanding)

endmacro()

0 comments on commit faa72b7

Please sign in to comment.