toolchain: abstract setting -nostdinc

- newlib needs c standard includes (so no -nostdinc)
- xcc needs toolchain headers (so no -nostdinc)
- with host gcc:
  - x86_64 should not build with standard includes (-nostdinc needed)
  - native_posix should build with standard include (no -nostdinc)
..
..

To simplify, abstract this and move it to compilers/toolchains and still
depend on what the application wants.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2019-02-21 14:13:28 -05:00
parent 59841c9c67
commit aa049e5d8f
5 changed files with 14 additions and 13 deletions

View file

@ -187,9 +187,8 @@ if(NOT CONFIG_RTTI)
)
endif()
if(NOT CONFIG_NATIVE_APPLICATION)
set(NOSTDINC_F -nostdinc)
endif()
# @Intent: Obtain compiler specific flags for standard C includes
toolchain_cc_nostdinc()
zephyr_compile_options(
-g # TODO: build configuration enough?
@ -201,7 +200,6 @@ zephyr_compile_options(
-ffreestanding
-Wno-main
-fno-common
${NOSTDINC_F}
${TOOLCHAIN_C_FLAGS}
)
@ -478,7 +476,6 @@ function(construct_add_custom_command_for_linker_pass linker_output_name output_
${linker_script_dep}
COMMAND ${CMAKE_C_COMPILER}
-x assembler-with-cpp
${NOSTDINC_F}
${NOSYSDEF_CFLAG}
-MD -MF ${linker_cmd_file_name}.dep -MT ${base_name}/${linker_cmd_file_name}
${current_includes}

View file

@ -135,3 +135,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_security_canaries.cmake
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_optimizations.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_cpp.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_asm.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_baremetal.cmake)

View file

@ -0,0 +1,10 @@
macro(toolchain_cc_nostdinc)
if (NOT CONFIG_NEWLIB_LIBC AND
NOT COMPILER STREQUAL "xcc" AND
NOT CONFIG_NATIVE_APPLICATION)
zephyr_compile_options( -nostdinc)
endif()
endmacro()

View file

@ -82,3 +82,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_security_canaries.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_optimizations.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_cpp.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_asm.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_baremetal.cmake)

View file

@ -1,8 +0,0 @@
macro(toolchain_cc_nostdinc)
zephyr_compile_options_ifndef(CONFIG_NATIVE_APPLICATION
-nostdinc
)
endmacro()