Skip to content

Commit f616aa3

Browse files
ozhurakinashif
authored andcommitted
posix: cmake: Abstract freestanding options
clang has problems compiling the native_posix with -fno-freestanding. Signed-off-by: Oleg Zhurakivskyy <[email protected]>
1 parent ab2f00e commit f616aa3

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

arch/posix/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
zephyr_compile_options(
4-
-fno-freestanding
54
-m32
65
-MMD
76
-MP
87
${ARCH_FLAG}
98
-include ${ZEPHYR_BASE}/arch/posix/include/posix_cheats.h
109
)
1110

11+
# @Intent: Obtain compiler specific flags for no freestanding compilation
12+
toolchain_cc_no_freestanding_options()
13+
1214
zephyr_include_directories(${BOARD_DIR})
1315

1416
zephyr_compile_options_ifdef(CONFIG_COVERAGE

cmake/compiler/clang/target.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,8 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_baremetal.cmake)
7979
macro(toolchain_cc_security_fortify)
8080
# No op, clang doesn't understand fortify at all
8181
endmacro()
82+
83+
macro(toolchain_cc_no_freestanding_options)
84+
# No op, this is used by the native_posix, clang has problems
85+
# compiling the native_posix with -fno-freestanding.
86+
endmacro()

cmake/compiler/gcc/target.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ list(APPEND CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags
131131
string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
132132

133133
# Load toolchain_cc-family macros
134+
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_freestanding.cmake)
134135
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_security_fortify.cmake)
135136
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_security_canaries.cmake)
136137
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_optimizations.cmake)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2019 Intel Corporation.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
macro(toolchain_cc_no_freestanding_options)
5+
6+
zephyr_cc_option(-fno-freestanding)
7+
8+
endmacro()

cmake/compiler/host-gcc/target.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ endforeach()
8181

8282
# Load toolchain_cc-family macros
8383
# Significant overlap with freestanding gcc compiler so reuse it
84+
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_freestanding.cmake)
8485
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_security_fortify.cmake)
8586
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_security_canaries.cmake)
8687
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_optimizations.cmake)

0 commit comments

Comments
 (0)