aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Dionne <ldionne.2@gmail.com>2022-03-01 09:17:57 -0500
committerLouis Dionne <ldionne.2@gmail.com>2022-05-06 15:44:25 -0400
commit7b04bf9d6f27a9c5f4de2287fcd73edea9213bcb (patch)
tree486af044f9e28191e5c09c52a10831892a5a9942 /runtimes
parentEnable the use of ThreadPoolTaskGroup in MLIR threading helper to enable nest... (diff)
downloadllvm-project-7b04bf9d6f27a9c5f4de2287fcd73edea9213bcb.tar.gz
llvm-project-7b04bf9d6f27a9c5f4de2287fcd73edea9213bcb.tar.bz2
llvm-project-7b04bf9d6f27a9c5f4de2287fcd73edea9213bcb.zip
[runtimes] Always configure libc++abi before libc++
That makes it possible to reuse libc++abi targets from the libc++ configuration, which is necessary to allow major CMake simplifications. As a fly-by fix, we also unify how compiler-rt ordering is handled so it matches how libc++ and libc++abi are handled (compiler-rt always ends up first). Differential Revision: https://reviews.llvm.org/D120719
Diffstat (limited to 'runtimes')
-rw-r--r--runtimes/CMakeLists.txt44
1 files changed, 22 insertions, 22 deletions
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 2246da7ea625..1783e0114291 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -9,6 +9,28 @@ if(LLVM_ENABLE_RUNTIMES STREQUAL "all" )
set(LLVM_ENABLE_RUNTIMES ${LLVM_ALL_RUNTIMES})
endif()
+# Some of the runtimes will conditionally use the compiler-rt sanitizers.
+# To make this work smoothly, we ensure that compiler-rt is added first in
+# the list of sub-projects. This allows other sub-projects to have checks
+# like `if(TARGET asan)` to enable building with asan.
+if (compiler-rt IN_LIST LLVM_ENABLE_RUNTIMES)
+ list(REMOVE_ITEM LLVM_ENABLE_RUNTIMES compiler-rt)
+ if(NOT DEFINED LLVM_BUILD_COMPILER_RT OR LLVM_BUILD_COMPILER_RT)
+ list(PREPEND LLVM_ENABLE_RUNTIMES compiler-rt)
+ endif()
+endif()
+
+# If both libc++ and libc++abi are being built, always configure libc++abi before libc++.
+# This allows libc++ to depend on targets set up by libc++abi when it needs to.
+if (libcxx IN_LIST LLVM_ENABLE_RUNTIMES AND libcxxabi IN_LIST LLVM_ENABLE_RUNTIMES)
+ list(FIND LLVM_ENABLE_RUNTIMES libcxx _libcxx_index)
+ list(FIND LLVM_ENABLE_RUNTIMES libcxxabi _libcxxabi_index)
+ if (_libcxx_index LESS _libcxxabi_index)
+ list(TRANSFORM LLVM_ENABLE_RUNTIMES REPLACE "^libcxx$" "libcxxabi" AT ${_libcxx_index})
+ list(TRANSFORM LLVM_ENABLE_RUNTIMES REPLACE "^libcxxabi$" "libcxx" AT ${_libcxxabi_index})
+ endif()
+endif()
+
foreach(proj ${LLVM_ENABLE_RUNTIMES})
set(proj_dir "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
if(IS_DIRECTORY ${proj_dir} AND EXISTS ${proj_dir}/CMakeLists.txt)
@@ -42,28 +64,6 @@ list(INSERT CMAKE_MODULE_PATH 0
set(LLVM_THIRD_PARTY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../third-party")
-function(get_compiler_rt_path path)
- foreach(entry ${runtimes})
- get_filename_component(projName ${entry} NAME)
- if("${projName}" MATCHES "compiler-rt")
- set(${path} ${entry} PARENT_SCOPE)
- return()
- endif()
- endforeach()
-endfunction()
-
-# Some of the runtimes will conditionally use the compiler-rt sanitizers
-# to make this work smoothly we ensure that compiler-rt is added first in
-# the list of sub-projects. This allows other sub-projects to have checks
-# like `if(TARGET asan)` to enable building with asan.
-get_compiler_rt_path(compiler_rt_path)
-if(compiler_rt_path)
- list(REMOVE_ITEM runtimes ${compiler_rt_path})
- if(NOT DEFINED LLVM_BUILD_COMPILER_RT OR LLVM_BUILD_COMPILER_RT)
- list(INSERT runtimes 0 ${compiler_rt_path})
- endif()
-endif()
-
# If building standalone by pointing CMake at this runtimes directory,
# LLVM_BINARY_DIR isn't set, find_package(LLVM) will fail and these
# intermediate paths are unset.