Skip to content
Snippets Groups Projects
Commit 24fea6a6 authored by Chris Bieneman's avatar Chris Bieneman
Browse files

[CMake] Add clang-bootstrap-deps target

Having this target allows other parts of the build system to add to the bootstrap dependencies without needing to be defined before the bootstrap targets are created.

This will specifically be used connect the builtins build from the LLVM runtimes directory as a dependency of the next build stage.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284648 91177308-0d34-0410-b5e6-96231b3b80d8
parent bf32d4a7
No related branches found
No related tags found
No related merge requests found
...@@ -484,6 +484,8 @@ endif() ...@@ -484,6 +484,8 @@ endif()
if (CLANG_ENABLE_BOOTSTRAP) if (CLANG_ENABLE_BOOTSTRAP)
include(ExternalProject) include(ExternalProject)
add_custom_target(clang-bootstrap-deps DEPENDS clang)
if(NOT CLANG_STAGE) if(NOT CLANG_STAGE)
set(CLANG_STAGE stage1) set(CLANG_STAGE stage1)
endif() endif()
...@@ -510,8 +512,8 @@ if (CLANG_ENABLE_BOOTSTRAP) ...@@ -510,8 +512,8 @@ if (CLANG_ENABLE_BOOTSTRAP)
set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/) set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
# If the next stage is LTO we need to depend on LTO and possibly LLVMgold # If the next stage is LTO we need to depend on LTO and possibly LLVMgold
if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO) if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT LLVM_BUILD_INSTRUMENTED)
set(LTO_DEP LTO) add_dependencies(clang-bootstrap-deps LTO)
if(APPLE) if(APPLE)
# on Darwin we need to set DARWIN_LTO_LIBRARY so that -flto will work # 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 # using the just-built compiler, and we need to override DYLD_LIBRARY_PATH
...@@ -524,7 +526,7 @@ if (CLANG_ENABLE_BOOTSTRAP) ...@@ -524,7 +526,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
set(LTO_LIBRARY -DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib set(LTO_LIBRARY -DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib
-DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR}) -DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR})
elseif(NOT WIN32) elseif(NOT WIN32)
list(APPEND LTO_DEP LLVMgold llvm-ar llvm-ranlib) add_dependencies(clang-bootstrap-deps LLVMgold llvm-ar llvm-ranlib)
set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar) set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib) set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
endif() endif()
...@@ -535,7 +537,7 @@ if (CLANG_ENABLE_BOOTSTRAP) ...@@ -535,7 +537,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
) )
add_custom_command( add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-cleared OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-cleared
DEPENDS clang ${LTO_DEP} DEPENDS clang-bootstrap-deps
COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR} COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
...@@ -562,8 +564,10 @@ if (CLANG_ENABLE_BOOTSTRAP) ...@@ -562,8 +564,10 @@ if (CLANG_ENABLE_BOOTSTRAP)
CMAKE_MAKE_PROGRAM CMAKE_MAKE_PROGRAM
CMAKE_OSX_ARCHITECTURES) CMAKE_OSX_ARCHITECTURES)
if(TARGET compiler-rt) # We don't need to depend on compiler-rt if we're building instrumented
set(RUNTIME_DEP compiler-rt) # because the next stage will use the same compiler used to build this stage.
if(TARGET compiler-rt AND NOT LLVM_BUILD_INSTRUMENTED)
add_dependencies(clang-bootstrap-deps compiler-rt)
endif() endif()
set(COMPILER_OPTIONS set(COMPILER_OPTIONS
...@@ -572,12 +576,12 @@ if (CLANG_ENABLE_BOOTSTRAP) ...@@ -572,12 +576,12 @@ if (CLANG_ENABLE_BOOTSTRAP)
-DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang) -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
if(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED) if(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED)
set(PGO_DEP llvm-profdata) add_dependencies(clang-bootstrap-deps llvm-profdata)
set(PGO_OPT -DLLVM_PROFDATA=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-profdata) set(PGO_OPT -DLLVM_PROFDATA=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-profdata)
endif() endif()
if(LLVM_BUILD_INSTRUMENTED) if(LLVM_BUILD_INSTRUMENTED)
set(PGO_DEP generate-profdata) add_dependencies(clang-bootstrap-deps generate-profdata)
set(PGO_OPT -DLLVM_PROFDATA_FILE=${CMAKE_CURRENT_BINARY_DIR}/utils/perf-training/clang.profdata) set(PGO_OPT -DLLVM_PROFDATA_FILE=${CMAKE_CURRENT_BINARY_DIR}/utils/perf-training/clang.profdata)
# Use the current tools for LTO instead of the instrumented ones # Use the current tools for LTO instead of the instrumented ones
list(APPEND _BOOTSTRAP_DEFAULT_PASSTHROUGH list(APPEND _BOOTSTRAP_DEFAULT_PASSTHROUGH
...@@ -591,8 +595,6 @@ if (CLANG_ENABLE_BOOTSTRAP) ...@@ -591,8 +595,6 @@ if (CLANG_ENABLE_BOOTSTRAP)
set(COMPILER_OPTIONS) set(COMPILER_OPTIONS)
set(LTO_LIBRARY) set(LTO_LIBRARY)
set(RUNTIME_DEP) # Don't set runtime dependencies
set(LTO_DEP) # Don't need to depend on LTO
set(LTO_AR) set(LTO_AR)
set(LTO_RANLIB) set(LTO_RANLIB)
endif() endif()
...@@ -627,7 +629,7 @@ if (CLANG_ENABLE_BOOTSTRAP) ...@@ -627,7 +629,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
endforeach() endforeach()
ExternalProject_Add(${NEXT_CLANG_STAGE} ExternalProject_Add(${NEXT_CLANG_STAGE}
DEPENDS clang ${LTO_DEP} ${RUNTIME_DEP} ${PGO_DEP} DEPENDS clang-bootstrap-deps
PREFIX ${NEXT_CLANG_STAGE} PREFIX ${NEXT_CLANG_STAGE}
SOURCE_DIR ${CMAKE_SOURCE_DIR} SOURCE_DIR ${CMAKE_SOURCE_DIR}
STAMP_DIR ${STAMP_DIR} STAMP_DIR ${STAMP_DIR}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment