From 94b87c6422178c742f63ddcf37839f019c2f5160 Mon Sep 17 00:00:00 2001 From: Evgeniy Paltsev Date: Mon, 28 Nov 2022 17:45:05 +0400 Subject: [PATCH] ARC: arcmwdt: fix & rework inclusion of C/C++ headers Currently we try to manually specify C/C++ headers locations with -isystem flag which lead to issues with "include_next" directive which is used in C/C++ headers. As advised by MWDT R&D team let's rely on the default C/C++ include locations which are provided by MWDT if we do build with MW C / C++ libraries. For that case we still need to manually specify header directory to ASM builds which bay use 'stdbool.h' In case of building with minimal libc (provided by Zephyr) we rely on minimal libc headers and manually specify toolchain's C header directory (as minimal libc still uses some toolchain's C headers. Signed-off-by: Eugeniy Paltsev Signed-off-by: Evgeniy Paltsev --- cmake/compiler/arcmwdt/compiler_flags.cmake | 10 ++++++++-- cmake/compiler/arcmwdt/target.cmake | 20 ++++---------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/cmake/compiler/arcmwdt/compiler_flags.cmake b/cmake/compiler/arcmwdt/compiler_flags.cmake index bfebf98f89..c9e612ea9d 100644 --- a/cmake/compiler/arcmwdt/compiler_flags.cmake +++ b/cmake/compiler/arcmwdt/compiler_flags.cmake @@ -117,10 +117,9 @@ set_compiler_property(PROPERTY cstd -std=) if (NOT CONFIG_ARCMWDT_LIBC) set_compiler_property(PROPERTY nostdinc -Hno_default_include -Hnoarcexlib) + set_compiler_property(APPEND PROPERTY nostdinc_include ${NOSTDINC}) endif() -set_compiler_property(APPEND PROPERTY nostdinc_include ${NOSTDINC}) - # C++ std options set_property(TARGET compiler-cpp PROPERTY dialect_cpp98 "-std=c++98") set_property(TARGET compiler-cpp PROPERTY dialect_cpp11 "-std=c++11") @@ -186,3 +185,10 @@ set_compiler_property(PROPERTY no_position_independent "") # Required ASM flags when using mwdt set_property(TARGET asm PROPERTY required "-Hasmcpp") + +if(CONFIG_ARCMWDT_LIBC) + # We rely on the default C/C++ include locations which are provided by MWDT if we do build with + # MW C / C++ libraries. However, for that case we still need to explicitly set header directory + # to ASM builds (which may use 'stdbool.h'). + set_property(TARGET asm APPEND PROPERTY required "-I${NOSTDINC}") +endif() diff --git a/cmake/compiler/arcmwdt/target.cmake b/cmake/compiler/arcmwdt/target.cmake index bb3652c66f..40e313a8ed 100644 --- a/cmake/compiler/arcmwdt/target.cmake +++ b/cmake/compiler/arcmwdt/target.cmake @@ -22,23 +22,11 @@ list(APPEND CMAKE_REQUIRED_FLAGS ) string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") -set(NOSTDINC "") +set(NOSTDINC ${TOOLCHAIN_HOME}/arc/inc) -list(APPEND NOSTDINC ${TOOLCHAIN_HOME}/arc/inc) - -if(CONFIG_ARCMWDT_LIBC AND CONFIG_LIB_CPLUSPLUS) - list(APPEND NOSTDINC ${TOOLCHAIN_HOME}/arc/lib/src/c++/inc) -endif() - -# For CMake to be able to test if a compiler flag is supported by the -# toolchain we need to give CMake the necessary flags to compile and -# link a dummy C file. -# -# CMake checks compiler flags with check_c_compiler_flag() (Which we -# wrap with target_cc_option() in extensions.cmake) -foreach(isystem_include_dir ${NOSTDINC}) - list(APPEND isystem_include_flags -isystem "\"${isystem_include_dir}\"") -endforeach() +# For CMake to be able to test if a compiler flag is supported by the toolchain +# (check_c_compiler_flag function which we wrap with target_cc_option in extensions.cmake) +# we rely on default MWDT header locations and don't manually specify headers directories. # common compile options, no copyright msg, little-endian, no small data, # no MWDT stack checking