[PATCH] D68833: [CMake] Re-order runtimes in the order of dependencies

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 14:05:50 PDT 2019


phosek created this revision.
phosek added reviewers: ldionne, beanz.
Herald added subscribers: llvm-commits, dexonsmith, mgorny.
Herald added a project: LLVM.
phosek added a comment.

This is an alternative to D68791 <https://reviews.llvm.org/D68791> which is trying to address the issue introduced in r374116.


This allows runtimes to have checks like `if(TARGET ${runtime})`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68833

Files:
  llvm/runtimes/CMakeLists.txt


Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -38,10 +38,10 @@
   set(LLVM_EXTERNAL_${canon_name}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}")
 endforeach()
 
-function(get_compiler_rt_path path)
+function(get_runtime_path runtime path)
   foreach(entry ${runtimes})
     get_filename_component(projName ${entry} NAME)
-    if("${projName}" MATCHES "compiler-rt")
+    if("${projName}" MATCHES "${runtime}")
       set(${path} ${entry} PARENT_SCOPE)
       return()
     endif()
@@ -68,18 +68,6 @@
     "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules"
   )
 
-  # 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()
-
   # Setting these variables will allow the sub-build to put their outputs into
   # the library and bin directories of the top-level build.
   set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_DIR})
@@ -122,6 +110,17 @@
     include(UseLibtool)
   endif()
 
+  # Re-order runtimes in the order of dependencies: libcxxabi depend on libunwind,
+  # libcxx depends on libcxxabi, some compiler-rt runtimes depend on libcxx. This
+  # allows these runtimes to have checks like `if(TARGET ${runtime})`.
+  foreach(runtime compiler-rt libcxx libcxxabi libunwind)
+    get_runtime_path(${runtime} runtime_path)
+    if(runtime_path)
+      list(REMOVE_ITEM runtimes ${runtime_path})
+      list(INSERT runtimes 0 ${runtime_path})
+    endif()
+  endforeach()
+
   # This can be used to detect whether we're in the runtimes build.
   set(RUNTIMES_BUILD ON)
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68833.224468.patch
Type: text/x-patch
Size: 2095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191010/0b9032fa/attachment.bin>


More information about the llvm-commits mailing list