[compiler-rt] 2da5501 - [compiler-rt][CMake] Use linker semantics for unwinder and C++ library
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 14 14:15:56 PDT 2022
Author: Petr Hosek
Date: 2022-07-14T21:12:36Z
New Revision: 2da550140aa98cf6a3e96417c87f1e89e3a26047
URL: https://github.com/llvm/llvm-project/commit/2da550140aa98cf6a3e96417c87f1e89e3a26047
DIFF: https://github.com/llvm/llvm-project/commit/2da550140aa98cf6a3e96417c87f1e89e3a26047.diff
LOG: [compiler-rt][CMake] Use linker semantics for unwinder and C++ library
Try the shared library first, and if it doesn't exist fallback onto
the static one. When the static library is requested, skip the shared
library.
Differential Revision: https://reviews.llvm.org/D129470
Added:
Modified:
compiler-rt/CMakeLists.txt
Removed:
################################################################################
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 8f9bd931f725..8467557d76bf 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -534,11 +534,10 @@ set(COMPILER_RT_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_CFLAGS})
if(COMPILER_RT_USE_LLVM_UNWINDER)
if (COMPILER_RT_ENABLE_STATIC_UNWINDER)
- set(unwinder_target unwind_static)
+ list(APPEND SANITIZER_CXX_ABI_LIBRARIES "$<TARGET_LINKER_FILE:unwind_static>")
else()
- set(unwinder_target unwind_shared)
+ list(APPEND SANITIZER_CXX_ABI_LIBRARIES "$<TARGET_LINKER_FILE:$<IF:$<TARGET_EXISTS:unwind_shared>,unwind_shared,unwind_static>>")
endif()
- list(APPEND SANITIZER_CXX_ABI_LIBRARIES "$<$<TARGET_EXISTS:${unwinder_target}>:$<TARGET_LINKER_FILE:${unwinder_target}>>")
endif()
if (COMPILER_RT_CXX_LIBRARY STREQUAL "libcxx")
@@ -546,13 +545,12 @@ if (COMPILER_RT_CXX_LIBRARY STREQUAL "libcxx")
append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ COMPILER_RT_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ COMPILER_RT_COMMON_LINK_FLAGS)
# Use the in-tree libc++ through explicit include and library paths.
+ set(COMPILER_RT_CXX_CFLAGS "$<$<TARGET_EXISTS:cxx-headers>:-isystem$<JOIN:$<TARGET_PROPERTY:cxx-headers,INTERFACE_INCLUDE_DIRECTORIES>,$<SEMICOLON>-isystem>>")
if (COMPILER_RT_STATIC_CXX_LIBRARY)
- set(cxx_target cxx_static)
+ set(COMPILER_RT_CXX_LINK_LIBS "$<TARGET_LINKER_FILE:cxx_static>")
else()
- set(cxx_target cxx_shared)
+ set(COMPILER_RT_CXX_LINK_LIBS "$<TARGET_LINKER_FILE:$<IF:$<TARGET_EXISTS:cxx_shared>,cxx_shared,cxx_static>>")
endif()
- list(APPEND COMPILER_RT_CXX_CFLAGS "$<$<TARGET_EXISTS:cxx-headers>:-isystem$<JOIN:$<TARGET_PROPERTY:cxx-headers,INTERFACE_INCLUDE_DIRECTORIES>,$<SEMICOLON>-isystem>>")
- list(APPEND COMPILER_RT_CXX_LINK_LIBS "$<$<TARGET_EXISTS:${cxx_target}>:$<TARGET_LINKER_FILE:${cxx_target}>>")
elseif (COMPILER_RT_CXX_LIBRARY STREQUAL "none")
# We aren't using any C++ standard library so avoid including the default one.
append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ COMPILER_RT_COMMON_CFLAGS)
@@ -589,13 +587,12 @@ endif()
if (SANITIZER_TEST_CXX_LIBNAME STREQUAL "libc++")
if (SANITIZER_TEST_CXX_INTREE)
+ list(APPEND SANITIZER_TEST_CXX_CFLAGS "$<$<TARGET_EXISTS:cxx-headers>:-isystem$<JOIN:$<TARGET_PROPERTY:cxx-headers,INTERFACE_INCLUDE_DIRECTORIES>,$<SEMICOLON>-isystem>>")
if (SANITIZER_USE_STATIC_TEST_CXX)
- set(cxx_target cxx_static)
+ list(APPEND SANITIZER_TEST_CXX_LIBRARIES "$<TARGET_LINKER_FILE:cxx_static>")
else()
- set(cxx_target cxx_shared)
+ list(APPEND SANITIZER_TEST_CXX_LIBRARIES "$<TARGET_LINKER_FILE:$<IF:$<TARGET_EXISTS:cxx_shared>,cxx_shared,cxx_static>>")
endif()
- list(APPEND SANITIZER_TEST_CXX_LIBRARIES "$<$<TARGET_EXISTS:${cxx_target}>:$<TARGET_LINKER_FILE:${cxx_target}>>")
- list(APPEND SANITIZER_TEST_CXX_CFLAGS "$<$<TARGET_EXISTS:cxx-headers>:-isystem$<JOIN:$<TARGET_PROPERTY:cxx-headers,INTERFACE_INCLUDE_DIRECTORIES>,$<SEMICOLON>-isystem>>")
# We are using the in tree libc++ so avoid including the default one.
append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ COMPILER_RT_UNITTEST_CFLAGS)
append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ COMPILER_RT_UNITTEST_LINK_FLAGS)
More information about the llvm-commits
mailing list