cmake: parameterized flags to not include standard defines/files
Not all compiles/linkers support the GCC flags to not include standard defines, include files and libraries. So make these parameters such that the toolchain can define them when supported. Also, according to documentation, -nostdlib does the same for both -nostartfiles and -nodefaultlibs. So remove the redundant ones. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
aa2bdbe322
commit
3829cb5c41
4 changed files with 15 additions and 5 deletions
|
@ -165,8 +165,6 @@ endif()
|
|||
|
||||
if(NOT CONFIG_NATIVE_APPLICATION)
|
||||
zephyr_ld_options(
|
||||
-nostartfiles
|
||||
-nodefaultlibs
|
||||
-nostdlib
|
||||
-static
|
||||
-no-pie
|
||||
|
@ -748,7 +746,7 @@ function(construct_add_custom_command_for_linker_pass linker_output_name output_
|
|||
COMMAND ${CMAKE_C_COMPILER}
|
||||
-x assembler-with-cpp
|
||||
${NOSTDINC_F}
|
||||
-undef
|
||||
${NOSYSDEF_CFLAG}
|
||||
-MD -MF ${linker_cmd_file_name}.dep -MT ${BASE_NAME}/${linker_cmd_file_name}
|
||||
${ZEPHYR_INCLUDES}
|
||||
${LINKER_SCRIPT_DEFINES}
|
||||
|
|
|
@ -53,6 +53,12 @@ find_program(CMAKE_CXX_COMPILER ${cplusplus_compiler} PATH ${TOOLCHAIN_HOME} NO_
|
|||
|
||||
set(NOSTDINC "")
|
||||
|
||||
# Note that NOSYSDEF_CFLAG may be an empty string, and
|
||||
# set_ifndef() does not work with empty string.
|
||||
if(NOT DEFINED NOSYSDEF_CFLAG)
|
||||
set(NOSYSDEF_CFLAG -undef)
|
||||
endif()
|
||||
|
||||
foreach(file_name include include-fixed)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
|
||||
set(NOSTDINC "")
|
||||
|
||||
# Note that NOSYSDEF_CFLAG may be an empty string, and
|
||||
# set_ifndef() does not work with empty string.
|
||||
if(NOT DEFINED NOSYSDEF_CFLAG)
|
||||
set(NOSYSDEF_CFLAG -undef)
|
||||
endif()
|
||||
|
||||
foreach(file_name include include-fixed)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
|
||||
|
@ -19,4 +25,3 @@ endforeach()
|
|||
|
||||
set(CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags} -Wl,--unresolved-symbols=ignore-in-object-files)
|
||||
string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
||||
|
||||
|
|
|
@ -92,7 +92,8 @@ if(CONFIG_HAS_DTS)
|
|||
-include ${AUTOCONF_H}
|
||||
${DTC_INCLUDE_FLAG_FOR_DTS} # include the DTS source and overlays
|
||||
-I${ZEPHYR_BASE}/dts/common
|
||||
-undef -D__DTS__
|
||||
${NOSYSDEF_CFLAG}
|
||||
-D__DTS__
|
||||
-P
|
||||
-E ${ZEPHYR_BASE}/misc/empty_file.c
|
||||
-o ${BOARD}.dts.pre.tmp
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue