From 764469717fe6a6b4c595d50b98417eb827df7574 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Thu, 10 Nov 2022 21:12:57 +0000 Subject: [PATCH] Fix #2120, Support clang for whole archive flags --- .../toolchain-i686-linux-clang.cmake | 23 +++++++++++++++++++ cmake/target/CMakeLists.txt | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 cmake/sample_defs/toolchain-i686-linux-clang.cmake diff --git a/cmake/sample_defs/toolchain-i686-linux-clang.cmake b/cmake/sample_defs/toolchain-i686-linux-clang.cmake new file mode 100644 index 000000000..7b7aa96f0 --- /dev/null +++ b/cmake/sample_defs/toolchain-i686-linux-clang.cmake @@ -0,0 +1,23 @@ +# This example toolchain file describes the cross compiler to use for +# the target architecture indicated in the configuration file. + +# Basic cross system configuration +SET(CMAKE_SYSTEM_NAME Linux) +SET(CMAKE_SYSTEM_VERSION 1) +SET(CMAKE_SYSTEM_PROCESSOR i686) + +# Specify the cross compiler executables +# Typically these would be installed in a home directory or somewhere +# in /opt. However in this example the system compiler is used. +SET(CMAKE_C_COMPILER "/usr/bin/clang") +SET(CMAKE_CXX_COMPILER "/usr/bin/clang++") + +# Configure the find commands +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) + +# These variable settings are specific to cFE/OSAL and determines which +# abstraction layers are built when using this toolchain +SET(CFE_SYSTEM_PSPNAME "pc-linux") +SET(OSAL_SYSTEM_OSTYPE "posix") diff --git a/cmake/target/CMakeLists.txt b/cmake/target/CMakeLists.txt index 94efbf45d..5e5eb73c4 100644 --- a/cmake/target/CMakeLists.txt +++ b/cmake/target/CMakeLists.txt @@ -156,7 +156,7 @@ if (${TGTNAME}_APPLIST) set_target_properties(core-${TGTNAME} PROPERTIES ENABLE_EXPORTS TRUE) - if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") + if (("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")) # The option pair for GNU gcc/ld tools set(START_WHOLE_ARCHIVE "--whole-archive") set(STOP_WHOLE_ARCHIVE "--no-whole-archive") @@ -165,6 +165,7 @@ if (${TGTNAME}_APPLIST) set(COMPILER_LINKER_OPTION_PREFIX "-Wl,") else() # Other toolchain options may be added here + message(WARNING "Unmatched compiler id, WHOLE_ARCHIVE flags not automatically set and may need custom config") endif() # Determine if a pass-through prefix is needed for a linker option.