cmake: xcc/xt-clang: fix for proper system include paths
Although xt-clang is based on clang, for some reason, it still lists xcc system include path as the first search path (e.g. for stddef.h), and the clang system include path as last. This creates a big issue when the code starts to use any standards past C89 (since xcc is based on GCC 4.2). We can use compiler property nostdin_include to add -isystem to compiler options. However, some modules (e.g. picolibcs) somehow ignore this. So we also need to forcibly do add_compile_options() to make sure the clang system include path is placed before the xcc system include path. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
f7b314347e
commit
146e22fca4
2 changed files with 19 additions and 19 deletions
|
@ -2,25 +2,10 @@
|
|||
|
||||
include(${ZEPHYR_BASE}/cmake/compiler/clang/compiler_flags.cmake)
|
||||
|
||||
# nostdinc_include contains path to llvm headers and also relative
|
||||
# path of "include-fixed".
|
||||
# Clear "nostdinc" and nostdinc_include
|
||||
# nostdinc needs to be cleared as it is needed for xtensa/config/core.h.
|
||||
# nostdinc_include contains path to llvm headers.
|
||||
set_compiler_property(PROPERTY nostdinc)
|
||||
set_compiler_property(PROPERTY nostdinc_include)
|
||||
|
||||
# For C++ code, re-add the standard includes directory which was
|
||||
# cleared up from nostdinc_inlcude in above lines with no
|
||||
# "include-fixed" this time"
|
||||
if(CONFIG_CPP)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} --print-file-name=include/stddef.h
|
||||
OUTPUT_VARIABLE _OUTPUT
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
)
|
||||
get_filename_component(_OUTPUT "${_OUTPUT}" DIRECTORY)
|
||||
string(REGEX REPLACE "\n" "" _OUTPUT "${_OUTPUT}")
|
||||
set_compiler_property(PROPERTY nostdinc_include "${_OUTPUT}")
|
||||
endif()
|
||||
set_compiler_property(APPEND PROPERTY nostdinc_include ${NOSTDINC})
|
||||
|
||||
if($ENV{XCC_NO_G_FLAG})
|
||||
# Older xcc/clang cannot use "-g" due to this bug:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue