]> granicus.if.org Git - clang/commitdiff
[CMake] On Darwin bootstrap LTO builds set DYLD_LIBRARY_PATH instead of using llvm-ar
authorChris Bieneman <beanz@apple.com>
Wed, 27 Apr 2016 18:52:48 +0000 (18:52 +0000)
committerChris Bieneman <beanz@apple.com>
Wed, 27 Apr 2016 18:52:48 +0000 (18:52 +0000)
llvm-ar isn't really supported for Darwin, instead the host tools will load libLTO, so we can use the just-built libLTO.

This actually makes Darwin bootstrap builds a little faster because you don't need to build llvm-ar before starting the next stage.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267756 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt

index 5c0d28de36d47b7079475e7a9c71c694726c0692..66f902209c1ca467202567bd0fdd6bf5d35b55b0 100644 (file)
@@ -685,17 +685,21 @@ if (CLANG_ENABLE_BOOTSTRAP)
   
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
+  set(cmake_command ${CMAKE_COMMAND})
 
-  # If on Darwin we need to make bootstrap depend on LTO and pass
-  # DARWIN_LTO_LIBRARY so that -flto will work using the just-built compiler
+  # If the next stage is LTO we need to depend on LTO and possibly LLVMgold
   if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO)
-    set(LTO_DEP LTO llvm-ar llvm-ranlib)
-    set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
-    set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
+    set(LTO_DEP LTO)
     if(APPLE)
+      # on Darwin we need to set DARWIN_LTO_LIBRARY so that -flto will work
+      # using the just-built compiler, and we need to override DYLD_LIBRARY_PATH
+      # so that the host object file tools will use the just-built libLTO.
       set(LTO_LIBRARY -DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib)
+      set(cmake_command ${CMAKE_COMMAND} -E env DYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR} ${CMAKE_COMMAND})
     elseif(NOT WIN32)
-      list(APPEND LTO_DEP LLVMgold)
+      list(APPEND LTO_DEP LLVMgold llvm-ar llvm-ranlib)
+      set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
+      set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
     endif()
   endif()
 
@@ -791,6 +795,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
                  -DCLANG_STAGE=${NEXT_CLANG_STAGE}
                 ${COMPILER_OPTIONS}
                 ${LTO_LIBRARY} ${LTO_AR} ${LTO_RANLIB} ${verbose} ${PGO_OPT}
+    CMAKE_COMMAND ${cmake_command}
     INSTALL_COMMAND ""
     STEP_TARGETS configure build
     ${cmake_3_4_USES_TERMINAL_OPTIONS}
@@ -799,7 +804,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
   # exclude really-install from main target
   set_target_properties(${NEXT_CLANG_STAGE} PROPERTIES _EP_really-install_EXCLUDE_FROM_MAIN On)
   ExternalProject_Add_Step(${NEXT_CLANG_STAGE} really-install
-    COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target install
+    COMMAND ${cmake_command} --build <BINARY_DIR> --target install
     COMMENT "Performing install step for '${NEXT_CLANG_STAGE}'"
     DEPENDEES build
     ${cmake_3_4_USES_TERMINAL}
@@ -815,7 +820,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
     set_target_properties(${NEXT_CLANG_STAGE} PROPERTIES _EP_${target}_EXCLUDE_FROM_MAIN On)
 
     ExternalProject_Add_Step(${NEXT_CLANG_STAGE} ${target}
-      COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target ${target}
+      COMMAND ${cmake_command} --build <BINARY_DIR> --target ${target}
       COMMENT "Performing ${target} for '${NEXT_CLANG_STAGE}'"
       DEPENDEES configure
       ${cmake_3_4_USES_TERMINAL}