From 3e6dad939bca5550020d8ff212f90b84ba2980ab Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Fri, 11 Oct 2024 10:15:11 -0700 Subject: [PATCH 1/3] cmake: xcc: do not use -fno-printf-return-value XCC does not recognize -fno-printf-return-value as compiler flag. So skip it. Signed-off-by: Daniel Leung --- cmake/compiler/xcc/compiler_flags.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/compiler/xcc/compiler_flags.cmake b/cmake/compiler/xcc/compiler_flags.cmake index 28f76d5d80962..4528b6a7421b9 100644 --- a/cmake/compiler/xcc/compiler_flags.cmake +++ b/cmake/compiler/xcc/compiler_flags.cmake @@ -15,3 +15,6 @@ set_compiler_property(PROPERTY no_position_independent "") # Remove after testing that -Wshadow works set_compiler_property(PROPERTY warning_shadow_variables) + +# xcc does not recognize -fno-printf-return-value +set_compiler_property(PROPERTY no_printf_return_value) From 3fa0711556a490d3bdf5dcd4a2eddfe264600802 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Fri, 11 Oct 2024 10:16:04 -0700 Subject: [PATCH 2/3] cmake: xcc: use xt-ld linker cmake code Shuffling of ld/lld on C library linking cmake code causes issue with XCC as the HAL library is not being included in linking. So make XCC to use xt-ld linker cmake code such that the HAL library is included. Signed-off-by: Daniel Leung --- cmake/toolchain/xcc/generic.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/toolchain/xcc/generic.cmake b/cmake/toolchain/xcc/generic.cmake index 02a9063bf5f43..daf00acc16c01 100644 --- a/cmake/toolchain/xcc/generic.cmake +++ b/cmake/toolchain/xcc/generic.cmake @@ -6,6 +6,7 @@ set(COMPILER xcc) set(OPTIMIZE_FOR_DEBUG_FLAG "-O0") set(CC xcc) set(C++ xc++) +set(LINKER xt-ld) list(APPEND TOOLCHAIN_C_FLAGS -imacros${ZEPHYR_BASE}/include/zephyr/toolchain/xcc_missing_defs.h From 9dcbd21d52c52b86eff4a48e41f043f2192c8140 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Fri, 11 Oct 2024 13:24:24 -0700 Subject: [PATCH 3/3] cmake: xcc: remove TOOLCHAIN_LIBS Following the footstep of GCC/Clang cmake code to remove TOOLCHAIN_LIBS, xcc also has it removed and utilizes something similar to c_library to link the HAL library. Signed-off-by: Daniel Leung --- cmake/compiler/xcc/target.cmake | 6 ------ cmake/linker/xt-ld/linker_libraries.cmake | 3 ++- cmake/linker/xt-ld/target.cmake | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/cmake/compiler/xcc/target.cmake b/cmake/compiler/xcc/target.cmake index a23c9d5bde68c..db965e715a839 100644 --- a/cmake/compiler/xcc/target.cmake +++ b/cmake/compiler/xcc/target.cmake @@ -40,12 +40,6 @@ foreach(file_name include/stddef.h include-fixed/limits.h) list(APPEND NOSTDINC ${_OUTPUT}) endforeach() -list(APPEND TOOLCHAIN_LIBS - gcc - hal - ) - - # 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. diff --git a/cmake/linker/xt-ld/linker_libraries.cmake b/cmake/linker/xt-ld/linker_libraries.cmake index 64c185c74b42c..f4fedfc4f0d46 100644 --- a/cmake/linker/xt-ld/linker_libraries.cmake +++ b/cmake/linker/xt-ld/linker_libraries.cmake @@ -5,4 +5,5 @@ set_linker_property(NO_CREATE PROPERTY c_library "-lc") set_linker_property(NO_CREATE PROPERTY rt_library "-lgcc") set_linker_property(NO_CREATE PROPERTY c++_library "-lstdc++") -set_linker_property(PROPERTY link_order_library "c;rt") +set_linker_property(NO_CREATE PROPERTY hal_library "-lhal") +set_linker_property(PROPERTY link_order_library "c;rt;hal") diff --git a/cmake/linker/xt-ld/target.cmake b/cmake/linker/xt-ld/target.cmake index 3546881cc718e..9a6b76cda621e 100644 --- a/cmake/linker/xt-ld/target.cmake +++ b/cmake/linker/xt-ld/target.cmake @@ -130,7 +130,6 @@ function(toolchain_ld_link_elf) ${NO_WHOLE_ARCHIVE_LIBS} $ -L${PROJECT_BINARY_DIR} - ${TOOLCHAIN_LIBS} ${TOOLCHAIN_LD_LINK_ELF_DEPENDENCIES} )