Skip to content

Commit

Permalink
Merge pull request #2204 from skliper/fix2120-clang_support
Browse files Browse the repository at this point in the history
Fix #2120, Support clang for whole archive flags
  • Loading branch information
dzbaker committed Nov 23, 2022
2 parents 348a98b + 7644697 commit 48dfae0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions cmake/sample_defs/toolchain-i686-linux-clang.cmake
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 2 additions & 1 deletion cmake/target/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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.
Expand Down

0 comments on commit 48dfae0

Please sign in to comment.