xcc-clang: add default C includes when build C++ code
nostdinc_include flag needs to contain path to llvm libraries
and remove other relative paths. Change compiler flag to add
default C includes on building C++ code using xcc-clang compiler.
Fixes
include(${ZEPHYR_BASE}/cmake/compiler/clang/compiler_flags.cmake)
-# Clear "nostdinc"
+# nostdinc_include contains path to llvm headers and also relative
+# path of "include-fixed".
+# Clear "nostdinc" and nostdinc_include
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()
+
if($ENV{XCC_NO_G_FLAG})
# Older xcc/clang cannot use "-g" due to this bug:
# https://bugs.llvm.org/show_bug.cgi?id=11740.
