[PATCH] Add the option to build/test compiler-rt as a standalone project with just-built Clang.

Alexey Samsonov samsonov at google.com
Mon Feb 24 06:41:23 PST 2014


  Address reviewers' comments.

Hi brad.king, chapuni,

http://llvm-reviews.chandlerc.com/D2868

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2868?vs=7312&id=7313#toc

Files:
  runtime/CMakeLists.txt

Index: runtime/CMakeLists.txt
===================================================================
--- runtime/CMakeLists.txt
+++ runtime/CMakeLists.txt
@@ -1,12 +1,61 @@
 # TODO: Set the install directory.
 
+include(ExternalProject)
+
 set(known_subdirs
-  "compiler-rt"
   "libcxx"
   )
 
 foreach (dir ${known_subdirs})
   if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/CMakeLists.txt)
     add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${dir})
   endif()
 endforeach()
+
+set(COMPILER_RT_SRC_ROOT ${LLVM_MAIN_SRC_DIR}/projects/compiler-rt)
+if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
+  # Add compiler-rt as an external project.
+  set(COMPILER_RT_PREFIX ${CMAKE_BINARY_DIR}/projects/compiler-rt)
+  
+  ExternalProject_Add(compiler-rt
+    PREFIX ${COMPILER_RT_PREFIX}
+    SOURCE_DIR ${COMPILER_RT_SRC_ROOT}
+    CMAKE_ARGS -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
+               -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
+               -DCMAKE_BUILD_TYPE=Release
+               -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config
+               -DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}
+               -DCOMPILER_RT_INSTALL_PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
+               -DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
+               -DCOMPILER_RT_ENABLE_WERROR=${LLVM_ENABLE_WERROR}
+    INSTALL_COMMAND ""
+    )
+  # Due to a bug, DEPENDS in ExternalProject_Add doesn't work
+  # in CMake 2.8.9 and 2.8.10.
+  add_dependencies(compiler-rt llvm-config clang clang++)
+
+  # Add a custom step to always re-build compiler-rt (in case some of its
+  # sources have changed).
+  ExternalProject_Add_Step(compiler-rt force-reconfigure
+    DEPENDERS build
+    ALWAYS 1
+    )
+
+  ExternalProject_Add_Step(compiler-rt clobber
+    COMMAND ${CMAKE_COMMAND} -E remove_directory <BINARY_DIR>
+    COMMAND ${CMAKE_COMMAND} -E make_directory <BINARY_DIR>
+    COMMENT "Clobberring compiler-rt build directory..."
+    DEPENDERS configure
+    DEPENDS ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
+  )
+
+  ExternalProject_Get_Property(compiler-rt BINARY_DIR)
+  add_custom_target(check-compiler-rt
+          COMMAND ${CMAKE_COMMAND} --build . --target check-all
+                                   --config $<CONFIGURATION>
+          DEPENDS compiler-rt
+          WORKING_DIRECTORY ${BINARY_DIR})
+  # Add binaries that compiler-rt tests depend on.
+  add_dependencies(check-compiler-rt FileCheck count
+                                     not llvm-nm llvm-symbolizer)
+endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2868.3.patch
Type: text/x-patch
Size: 2606 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140224/2219e52a/attachment.bin>


More information about the cfe-commits mailing list