Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2120, Support clang for whole archive flags #2204

Merged
merged 1 commit into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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