diff --git a/cmake/compiler/gcc/compiler_flags.cmake b/cmake/compiler/gcc/compiler_flags.cmake index 53b42823717f..836a1dabdeed 100644 --- a/cmake/compiler/gcc/compiler_flags.cmake +++ b/cmake/compiler/gcc/compiler_flags.cmake @@ -116,6 +116,7 @@ set_compiler_property(PROPERTY cstd -std=) if (NOT CONFIG_NEWLIB_LIBC AND NOT (CONFIG_PICOLIBC AND NOT CONFIG_PICOLIBC_USE_MODULE) AND NOT COMPILER STREQUAL "xcc" AND + NOT COMPILER STREQUAL "xt-clang" AND NOT CONFIG_HAS_ESPRESSIF_HAL AND NOT CONFIG_NATIVE_BUILD) set_compiler_property(PROPERTY nostdinc -nostdinc) diff --git a/cmake/compiler/xcc/target.cmake b/cmake/compiler/xcc/target.cmake index f9e9c721a15e..56d15451d3d5 100644 --- a/cmake/compiler/xcc/target.cmake +++ b/cmake/compiler/xcc/target.cmake @@ -37,7 +37,22 @@ foreach(file_name include/stddef.h include-fixed/limits.h) get_filename_component(_OUTPUT "${_OUTPUT}" DIRECTORY) string(REGEX REPLACE "\n" "" _OUTPUT "${_OUTPUT}") - list(APPEND NOSTDINC ${_OUTPUT}) + # Need to make sure the path exists before we add it to ${NOSTDINC}. + # For example, include-fixed is in xcc but not xt-clang. + if(EXISTS "${_OUTPUT}") + list(APPEND NOSTDINC ${_OUTPUT}) + + if("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "xt-clang") + # This forcibly adds -isystem so that the xt-clang system + # include paths are before the xcc include paths. + # For some reason, xt-clang places xcc include paths before + # xt-clang ones so we need to force it. + # + # Some modules ignores the compiler property nostdinc_include + # so we need to make sure -isystem is used there. + add_compile_options(-isystem ${_OUTPUT}) + endif() + endif() endforeach() # This libgcc code is partially duplicated in compiler/*/target.cmake diff --git a/cmake/compiler/xt-clang/compiler_flags.cmake b/cmake/compiler/xt-clang/compiler_flags.cmake index c70832ebc0f9..54451194c6d3 100644 --- a/cmake/compiler/xt-clang/compiler_flags.cmake +++ b/cmake/compiler/xt-clang/compiler_flags.cmake @@ -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: diff --git a/include/zephyr/toolchain/xcc.h b/include/zephyr/toolchain/xcc.h index 2a7b678e0abe..bc9c69e227eb 100644 --- a/include/zephyr/toolchain/xcc.h +++ b/include/zephyr/toolchain/xcc.h @@ -15,7 +15,9 @@ * XCC does not support using deprecated attribute in enum, * so just nullify it here to avoid compilation errors. */ +#ifndef __deprecated #define __deprecated +#endif #define __in_section_unique(seg) \ __attribute__((section("." STRINGIFY(seg) "." STRINGIFY(__COUNTER__)))) diff --git a/scripts/build/gen_app_partitions.py b/scripts/build/gen_app_partitions.py index 4a178762afcc..26afc582b5f6 100755 --- a/scripts/build/gen_app_partitions.py +++ b/scripts/build/gen_app_partitions.py @@ -472,7 +472,7 @@ def parse_args(): parser.add_argument("--pinpartitions", action="store", required=False, default="", help="Comma separated names of partitions to be pinned in physical memory") - args = parser.parse_args() + args, _ = parser.parse_known_args() def main():