diff options
author | Chris Bieneman <beanz@apple.com> | 2016-06-23 22:07:21 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2016-06-23 22:07:21 +0000 |
commit | 64adae59f3b95ca64464c69081a1c1711f9ddee3 (patch) | |
tree | df71a42de4e173ca7b531d5bfd7b0d86587ba60a /llvm/cmake/modules/LLVMExternalProjectUtils.cmake | |
parent | 31d6da7c0ca24fd247078c32c16e0e95b99e20d6 (diff) | |
download | bcm5719-llvm-64adae59f3b95ca64464c69081a1c1711f9ddee3.tar.gz bcm5719-llvm-64adae59f3b95ca64464c69081a1c1711f9ddee3.zip |
[CMake] Add LLVM runtimes directory
Summary:
There are a few LLVM projects that produce runtime libraries. Ideally
runtime libraries should be built differently than other projects,
specifically they should be built using the just-built toolchain.
There is support for building compiler-rt in this way from the clang
build. Moving this logic into the LLVM build is interesting because it
provides a simpler way to extend the just-built toolchain to include
LLD and the LLVM object file tools.
Once this functionality is better fleshed out and tested we’ll want to
encapsulate it in a module that can be used for clang standalone
builds, and we’ll want to make it the default way to build compiler-rt.
With this patch applied there is no immediate change in the build.
Moving compiler-rt out from llvm/projects into llvm/runtimes enables
the functionality.
This code has a few improvements over the method provided by
LLVM_BUILD_EXTERNAL_COMPILER_RT. Specifically the sub-ninja command is
always invoked, so changes to compiler-rt source files will get built
properly, so this patch can be used for iterative development with
just-built tools.
This first patch only works with compiler-rt. Support for other
runtime projects will be coming in follow-up patches.
Reviewers: chandlerc, bogner
Subscribers: kubabrecka, llvm-commits
Differential Revision: http://reviews.llvm.org/D20992
llvm-svn: 273620
Diffstat (limited to 'llvm/cmake/modules/LLVMExternalProjectUtils.cmake')
-rw-r--r-- | llvm/cmake/modules/LLVMExternalProjectUtils.cmake | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake index 40364aa8707..3e7355d4d6b 100644 --- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake +++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake @@ -19,6 +19,8 @@ endfunction() # Exclude this project from the all target # NO_INSTALL # Don't generate install targets for this project +# ALWAYS_CLEAN +# Always clean the sub-project before building # CMAKE_ARGS arguments... # Optional cmake arguments to pass when configuring the project # TOOLCHAIN_TOOLS targets... @@ -27,11 +29,15 @@ endfunction() # Targets that this project depends on # EXTRA_TARGETS targets... # Extra targets in the subproject to generate targets for +# PASSTHROUGH_PREFIXES prefix... +# Extra variable prefixes (name is always included) to pass down # ) function(llvm_ExternalProject_Add name source_dir) - cmake_parse_arguments(ARG "USE_TOOLCHAIN;EXCLUDE_FROM_ALL;NO_INSTALL" + cmake_parse_arguments(ARG + "USE_TOOLCHAIN;EXCLUDE_FROM_ALL;NO_INSTALL;ALWAYS_CLEAN" "SOURCE_DIR" - "CMAKE_ARGS;TOOLCHAIN_TOOLS;RUNTIME_LIBRARIES;DEPENDS;EXTRA_TARGETS" ${ARGN}) + "CMAKE_ARGS;TOOLCHAIN_TOOLS;RUNTIME_LIBRARIES;DEPENDS;EXTRA_TARGETS;PASSTHROUGH_PREFIXES" + ${ARGN}) canonicalize_tool_name(${name} nameCanon) if(NOT ARG_TOOLCHAIN_TOOLS) set(ARG_TOOLCHAIN_TOOLS clang lld) @@ -52,6 +58,10 @@ function(llvm_ExternalProject_Add name source_dir) endif() endforeach() + if(ARG_ALWAYS_CLEAN) + set(always_clean clean) + endif() + list(FIND TOOLCHAIN_TOOLS clang FOUND_CLANG) if(FOUND_CLANG GREATER -1) set(CLANG_IN_TOOLCHAIN On) @@ -71,15 +81,18 @@ function(llvm_ExternalProject_Add name source_dir) USES_TERMINAL ) - # Find all variables that start with COMPILER_RT and populate a variable with - # them. + # Find all variables that start with a prefix and propagate them through get_cmake_property(variableNames VARIABLES) - foreach(variableName ${variableNames}) - if(variableName MATCHES "^${nameCanon}") - string(REPLACE ";" "\;" value "${${variableName}}") - list(APPEND PASSTHROUGH_VARIABLES - -D${variableName}=${value}) - endif() + + list(APPEND ARG_PASSTHROUGH_PREFIXES ${nameCanon}) + foreach(prefix ${ARG_PASSTHROUGH_PREFIXES}) + foreach(variableName ${variableNames}) + if(variableName MATCHES "^${prefix}") + string(REPLACE ";" "\;" value "${${variableName}}") + list(APPEND PASSTHROUGH_VARIABLES + -D${variableName}=${value}) + endif() + endforeach() endforeach() if(ARG_USE_TOOLCHAIN) @@ -117,6 +130,12 @@ function(llvm_ExternalProject_Add name source_dir) CMAKE_ARGS ${${nameCanon}_CMAKE_ARGS} ${compiler_args} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + -DLLVM_BINARY_DIR=${PROJECT_BINARY_DIR} + -DLLVM_CONFIG_PATH=$<TARGET_FILE:llvm-config> + -DLLVM_ENABLE_WERROR=${LLVM_ENABLE_WERROR} + -DPACKAGE_VERSION=${PACKAGE_VERSION} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} ${ARG_CMAKE_ARGS} ${PASSTHROUGH_VARIABLES} INSTALL_COMMAND "" @@ -138,6 +157,7 @@ function(llvm_ExternalProject_Add name source_dir) DEPENDEES configure ${force_deps} WORKING_DIRECTORY ${BINARY_DIR} + EXCLUDE_FROM_MAIN 1 USES_TERMINAL 1 ) ExternalProject_Add_StepTargets(${name} clean) |