2016-06-24 00:07:21 +02:00
|
|
|
# This file handles building LLVM runtime sub-projects.
|
|
|
|
|
|
|
|
# Runtimes are different from tools or other drop-in projects because runtimes
|
|
|
|
# should be built with the LLVM toolchain from the build directory. This file is
|
|
|
|
# a first step to formalizing runtime build interfaces.
|
|
|
|
|
2019-05-23 19:06:46 +02:00
|
|
|
# Setting CMake minimum required version should be at the very top of the file
|
|
|
|
# if this is the entry point.
|
|
|
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
2020-04-22 17:15:05 +02:00
|
|
|
cmake_minimum_required(VERSION 3.13.4)
|
2019-05-23 19:06:46 +02:00
|
|
|
project(Runtimes C CXX ASM)
|
|
|
|
endif()
|
2016-06-24 00:07:21 +02:00
|
|
|
|
|
|
|
# Find all subdirectories containing CMake projects
|
|
|
|
file(GLOB entries *)
|
|
|
|
foreach(entry ${entries})
|
|
|
|
if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt)
|
|
|
|
list(APPEND runtimes ${entry})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2017-11-27 23:31:11 +01:00
|
|
|
# Side-by-side subprojects layout.
|
2021-01-10 22:45:39 +01:00
|
|
|
set(LLVM_ALL_RUNTIMES "libcxx;libcxxabi;libunwind;compiler-rt;openmp")
|
2017-11-27 23:31:11 +01:00
|
|
|
set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
|
|
|
|
"Semicolon-separated list of runtimes to build (${LLVM_ALL_RUNTIMES}), or \"all\".")
|
|
|
|
if(LLVM_ENABLE_RUNTIMES STREQUAL "all" )
|
|
|
|
set(LLVM_ENABLE_RUNTIMES ${LLVM_ALL_RUNTIMES})
|
|
|
|
endif()
|
|
|
|
foreach(proj ${LLVM_ENABLE_RUNTIMES})
|
|
|
|
set(proj_dir "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}")
|
|
|
|
if(IS_DIRECTORY ${proj_dir} AND EXISTS ${proj_dir}/CMakeLists.txt)
|
|
|
|
list(APPEND runtimes ${proj_dir})
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "LLVM_ENABLE_RUNTIMES requests ${proj} but directory not found: ${proj_dir}")
|
|
|
|
endif()
|
|
|
|
string(TOUPPER "${proj}" canon_name)
|
|
|
|
STRING(REGEX REPLACE "-" "_" canon_name ${canon_name})
|
|
|
|
set(LLVM_EXTERNAL_${canon_name}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
function(get_compiler_rt_path path)
|
|
|
|
foreach(entry ${runtimes})
|
|
|
|
get_filename_component(projName ${entry} NAME)
|
|
|
|
if("${projName}" MATCHES "compiler-rt")
|
|
|
|
set(${path} ${entry} PARENT_SCOPE)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
2016-06-24 00:07:21 +02:00
|
|
|
# If this file is acting as a top-level CMake invocation, this code path is
|
|
|
|
# triggered by the external project call for the runtimes target below.
|
|
|
|
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
2016-08-25 22:49:51 +02:00
|
|
|
function(runtime_register_component name)
|
|
|
|
set_property(GLOBAL APPEND PROPERTY SUB_COMPONENTS ${name})
|
|
|
|
endfunction()
|
|
|
|
|
2020-04-22 17:15:05 +02:00
|
|
|
cmake_minimum_required(VERSION 3.13.4)
|
2017-09-01 03:05:59 +02:00
|
|
|
project(Runtimes C CXX ASM)
|
2016-06-24 00:07:21 +02:00
|
|
|
|
2019-05-30 09:34:39 +02:00
|
|
|
find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
|
|
|
|
|
2016-06-24 00:07:21 +02:00
|
|
|
# Add the root project's CMake modules, and the LLVM build's modules to the
|
|
|
|
# CMake module path.
|
|
|
|
list(INSERT CMAKE_MODULE_PATH 0
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/../cmake"
|
2017-04-13 23:29:03 +02:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules"
|
2016-06-24 00:07:21 +02:00
|
|
|
)
|
|
|
|
|
2016-08-30 23:29:21 +02:00
|
|
|
# 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.
|
2017-11-27 23:31:11 +01:00
|
|
|
get_compiler_rt_path(compiler_rt_path)
|
2016-08-30 23:29:21 +02:00
|
|
|
if(compiler_rt_path)
|
|
|
|
list(REMOVE_ITEM runtimes ${compiler_rt_path})
|
2019-04-23 01:31:39 +02:00
|
|
|
if(NOT DEFINED LLVM_BUILD_COMPILER_RT OR LLVM_BUILD_COMPILER_RT)
|
2017-08-16 21:13:45 +02:00
|
|
|
list(INSERT runtimes 0 ${compiler_rt_path})
|
|
|
|
endif()
|
2016-08-30 23:29:21 +02:00
|
|
|
endif()
|
|
|
|
|
2016-06-24 00:07:21 +02:00
|
|
|
# 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})
|
2016-08-25 19:18:41 +02:00
|
|
|
set(LLVM_RUNTIME_OUTPUT_INTDIR ${LLVM_TOOLS_BINARY_DIR})
|
2016-06-24 00:07:21 +02:00
|
|
|
|
2016-09-15 08:14:13 +02:00
|
|
|
# This variable makes sure that e.g. llvm-lit is found.
|
|
|
|
set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR})
|
2019-02-09 04:06:56 +01:00
|
|
|
set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
|
2016-09-15 08:14:13 +02:00
|
|
|
|
2019-05-30 03:24:31 +02:00
|
|
|
# This variable is used by individual runtimes to locate LLVM files.
|
|
|
|
set(LLVM_PATH ${LLVM_BUILD_MAIN_SRC_DIR})
|
|
|
|
|
2017-03-24 03:21:11 +01:00
|
|
|
if(APPLE)
|
2017-07-12 01:41:15 +02:00
|
|
|
set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
|
2017-03-24 03:21:11 +01:00
|
|
|
endif()
|
|
|
|
|
2017-04-13 23:29:03 +02:00
|
|
|
include(CheckLibraryExists)
|
|
|
|
include(CheckCCompilerFlag)
|
2020-09-29 01:12:48 +02:00
|
|
|
|
|
|
|
# We don't have libc++ (yet)...
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++ -nostdlib++")
|
|
|
|
|
|
|
|
# ...but we need access to libc++ headers for CMake checks to succeed.
|
|
|
|
if (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR AND "libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -isystem ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}/include")
|
|
|
|
endif()
|
2017-04-13 23:29:03 +02:00
|
|
|
|
2018-04-11 07:18:03 +02:00
|
|
|
# Avoid checking whether the compiler is working.
|
|
|
|
set(LLVM_COMPILER_CHECKED ON)
|
2019-02-12 03:25:27 +01:00
|
|
|
|
2018-04-11 07:18:03 +02:00
|
|
|
# Handle common options used by all runtimes.
|
|
|
|
include(AddLLVM)
|
|
|
|
include(HandleLLVMOptions)
|
2019-02-09 04:06:56 +01:00
|
|
|
include(FindPythonInterp)
|
2018-04-11 07:18:03 +02:00
|
|
|
|
2020-10-02 23:16:27 +02:00
|
|
|
# Remove the -nostdlib++ option we've added earlier.
|
|
|
|
string(REPLACE "-nostdlib++" "" CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
2017-04-13 23:29:03 +02:00
|
|
|
|
2019-06-02 04:05:01 +02:00
|
|
|
# Use libtool instead of ar if you are both on an Apple host, and targeting Apple.
|
|
|
|
if(CMAKE_HOST_APPLE AND APPLE)
|
|
|
|
include(UseLibtool)
|
|
|
|
endif()
|
|
|
|
|
2019-02-09 04:06:56 +01:00
|
|
|
# This can be used to detect whether we're in the runtimes build.
|
|
|
|
set(RUNTIMES_BUILD ON)
|
|
|
|
|
2016-06-24 00:07:21 +02:00
|
|
|
foreach(entry ${runtimes})
|
|
|
|
get_filename_component(projName ${entry} NAME)
|
|
|
|
|
|
|
|
# TODO: Clean this up as part of an interface standardization
|
|
|
|
string(REPLACE "-" "_" canon_name ${projName})
|
|
|
|
string(TOUPPER ${canon_name} canon_name)
|
|
|
|
|
2020-10-23 15:32:50 +02:00
|
|
|
# The subdirectories need to treat this as standalone builds. D57992 tried
|
|
|
|
# to get rid of this, but the runtimes treat *_STANDALONE_BUILD=OFF as if
|
|
|
|
# llvm & clang are configured in the same CMake, and setup dependencies
|
2019-05-29 20:37:49 +02:00
|
|
|
# against their targets.
|
2020-10-23 15:32:50 +02:00
|
|
|
set(${canon_name}_STANDALONE_BUILD ON)
|
2019-05-29 20:37:49 +02:00
|
|
|
|
2019-05-22 23:08:33 +02:00
|
|
|
if(LLVM_RUNTIMES_LIBDIR_SUBDIR)
|
|
|
|
set(${canon_name}_LIBDIR_SUBDIR "${LLVM_RUNTIMES_LIBDIR_SUBDIR}" CACHE STRING "" FORCE)
|
2018-07-10 21:13:33 +02:00
|
|
|
endif()
|
|
|
|
|
2016-08-19 00:18:11 +02:00
|
|
|
# Setting a variable to let sub-projects detect which other projects
|
|
|
|
# will be included under here.
|
2019-02-09 04:06:56 +01:00
|
|
|
set(HAVE_${canon_name} ON)
|
2017-01-02 21:33:33 +01:00
|
|
|
endforeach()
|
2016-08-19 00:18:11 +02:00
|
|
|
|
2017-01-02 21:33:33 +01:00
|
|
|
# We do this in two loops so that HAVE_* is set for each runtime before the
|
|
|
|
# other runtimes are added.
|
|
|
|
foreach(entry ${runtimes})
|
|
|
|
get_filename_component(projName ${entry} NAME)
|
2017-07-12 01:41:15 +02:00
|
|
|
|
2016-08-25 19:18:41 +02:00
|
|
|
# Between each sub-project we want to cache and clear the LIT properties
|
|
|
|
set_property(GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
|
|
|
|
set_property(GLOBAL PROPERTY LLVM_LIT_PARAMS)
|
|
|
|
set_property(GLOBAL PROPERTY LLVM_LIT_DEPENDS)
|
|
|
|
set_property(GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
|
|
|
|
|
2017-11-27 23:31:11 +01:00
|
|
|
add_subdirectory(${entry} ${projName})
|
2016-08-25 19:18:41 +02:00
|
|
|
|
|
|
|
get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
|
|
|
|
get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS)
|
|
|
|
get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS)
|
|
|
|
get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
|
|
|
|
|
|
|
|
list(APPEND RUNTIMES_LIT_TESTSUITES ${LLVM_LIT_TESTSUITES})
|
|
|
|
list(APPEND RUNTIMES_LIT_PARAMS ${LLVM_LIT_PARAMS})
|
|
|
|
list(APPEND RUNTIMES_LIT_DEPENDS ${LLVM_LIT_DEPENDS})
|
|
|
|
list(APPEND RUNTIMES_LIT_EXTRA_ARGS ${LLVM_LIT_EXTRA_ARGS})
|
2016-06-24 00:07:21 +02:00
|
|
|
endforeach()
|
|
|
|
|
2016-08-25 22:49:51 +02:00
|
|
|
if(LLVM_INCLUDE_TESTS)
|
|
|
|
# Add a global check rule now that all subdirectories have been traversed
|
|
|
|
# and we know the total set of lit testsuites.
|
2017-07-14 02:35:21 +02:00
|
|
|
|
2016-08-25 22:49:51 +02:00
|
|
|
add_lit_target(check-runtimes
|
|
|
|
"Running all regression tests"
|
|
|
|
${RUNTIMES_LIT_TESTSUITES}
|
|
|
|
PARAMS ${RUNTIMES_LIT_PARAMS}
|
|
|
|
DEPENDS ${RUNTIMES_LIT_DEPENDS}
|
|
|
|
ARGS ${RUNTIMES_LIT_EXTRA_ARGS}
|
|
|
|
)
|
2016-08-26 22:08:57 +02:00
|
|
|
add_custom_target(runtimes-test-depends DEPENDS ${RUNTIMES_LIT_DEPENDS})
|
2016-08-25 22:49:51 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
get_property(SUB_COMPONENTS GLOBAL PROPERTY SUB_COMPONENTS)
|
2016-08-27 02:19:51 +02:00
|
|
|
if(SUB_COMPONENTS)
|
|
|
|
list(REMOVE_DUPLICATES SUB_COMPONENTS)
|
|
|
|
foreach(component ${SUB_COMPONENTS})
|
|
|
|
if(NOT TARGET ${component})
|
|
|
|
message(SEND_ERROR "Missing target for runtime component ${component}!")
|
|
|
|
continue()
|
|
|
|
endif()
|
2017-07-12 01:41:15 +02:00
|
|
|
|
|
|
|
if(TARGET check-${component})
|
|
|
|
list(APPEND SUB_CHECK_TARGETS check-${component})
|
2016-08-27 02:19:51 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(TARGET install-${component})
|
|
|
|
list(APPEND SUB_INSTALL_TARGETS install-${component})
|
|
|
|
endif()
|
2017-12-08 20:42:46 +01:00
|
|
|
if(TARGET install-${component}-stripped)
|
|
|
|
list(APPEND SUB_INSTALL_TARGETS install-${component}-stripped)
|
|
|
|
endif()
|
2016-08-27 02:19:51 +02:00
|
|
|
endforeach()
|
|
|
|
|
2017-07-12 01:41:15 +02:00
|
|
|
if(LLVM_RUNTIMES_TARGET)
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
|
|
|
|
${LLVM_BINARY_DIR}/runtimes/${LLVM_RUNTIMES_TARGET}/Components.cmake)
|
|
|
|
else()
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
|
|
|
|
${LLVM_BINARY_DIR}/runtimes/Components.cmake)
|
|
|
|
endif()
|
2016-08-27 02:19:51 +02:00
|
|
|
endif()
|
2016-08-25 19:18:41 +02:00
|
|
|
|
2016-06-24 00:07:21 +02:00
|
|
|
else() # if this is included from LLVM's CMake
|
|
|
|
include(LLVMExternalProjectUtils)
|
|
|
|
|
2017-03-23 23:40:10 +01:00
|
|
|
if(NOT LLVM_BUILD_RUNTIMES)
|
|
|
|
set(EXTRA_ARGS EXCLUDE_FROM_ALL)
|
|
|
|
endif()
|
|
|
|
|
[runtimes] Allow LLVM_BUILTIN_TARGETS to include Darwin
We have two ways of using the runtimes build setup to build the
builtins. You can either have an empty LLVM_BUILTIN_TARGETS (or have it
include the "default" target), in which case builtin_default_target is
called to set up the default target, or you can have actual triples in
LLVM_BUILTIN_TARGETS, in which case builtin_register_target is called
for each triple. builtin_default_target lets you build the builtins for
Darwin (assuming your default triple is Darwin); builtin_register_target
does not.
I don't understand the reason for this distinction. The Darwin builtins
build is special in that a single CMake configure handles building the
builtins for multiple platforms (e.g. macOS, iPhoneSimulator, and iOS)
and architectures (e.g. arm64, armv7, and x86_64). Consequently, if you
specify multiple Darwin triples in LLVM_BUILTIN_TARGETS, expecting each
configure to only build for that particular triple, it won't work.
However, if you specify a *single* x86_64-apple-darwin triple in
LLVM_BUILTIN_TARGETS, that single configure will build the builtins for
all Darwin targets, exactly the same way that the default target would.
The only difference between the configuration for the default target and
the x86_64-apple-darwin triple is that the latter runs the configuration
with `-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON`, but that makes no
difference for Apple targets (none of the CMake codepaths which have
different behavior based on that variable are run for Apple targets).
I tested this by running two builtins builds on my Mac, one with the
default target and one with the x86_64-apple-darwin19.5.0 target (which
is the default target triple for my clang). The only relevant
CMakeCache.txt difference was the following, and as discussed above, it
has no effect on the actual build for Apple targets:
```
-//Default triple for which compiler-rt runtimes will be built.
-COMPILER_RT_DEFAULT_TARGET_TRIPLE:STRING=x86_64-apple-darwin19.5.0
+//No help, variable specified on the command line.
+COMPILER_RT_DEFAULT_TARGET_ONLY:UNINITIALIZED=ON
```
Furthermore, when I add the `-D` flag to compiler-rt's libtool
invocations, the libraries produced by the two builds are *identical*.
If anything, I would expect builtin_register_target to complain if you
tried specifying a triple for a particular Apple platform triple (e.g.
macosx), since that's the scenario in which it won't work as you want.
The generic darwin triple should be fine though, as best as I can tell.
I'm happy to add the error for specific Apple platform triples, either
in this diff or in a follow-up.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D86313
2020-08-20 21:18:15 +02:00
|
|
|
function(check_apple_target triple builtin_or_runtime)
|
|
|
|
set(error "\
|
|
|
|
compiler-rt for Darwin builds for all platforms and architectures using a \
|
|
|
|
single configuration. Specify only a single darwin triple (e.g. x86_64-apple-darwin) \
|
|
|
|
in your targets list (and not a triple for a specific platform such as macos). \
|
|
|
|
You can use variables such as COMPILER_RT_ENABLE_IOS and DARWIN_ios_ARCHS to \
|
|
|
|
control the specific platforms and architectures to build.")
|
|
|
|
|
|
|
|
set(seen_property ${builtin_or_runtime}_darwin_triple_seen)
|
|
|
|
string(REPLACE "-" ";" triple_components ${triple})
|
|
|
|
foreach(component ${triple_components})
|
|
|
|
string(TOLOWER "${component}" component_lower)
|
|
|
|
if(component_lower MATCHES "^darwin")
|
|
|
|
get_property(darwin_triple_seen GLOBAL PROPERTY ${seen_property})
|
|
|
|
if(darwin_triple_seen)
|
|
|
|
message(FATAL_ERROR "${error}")
|
|
|
|
endif()
|
|
|
|
set_property(GLOBAL PROPERTY ${seen_property} YES)
|
|
|
|
if(NOT RUNTIMES_BUILD_ALLOW_DARWIN)
|
|
|
|
message(FATAL_ERROR "\
|
|
|
|
${error} Set RUNTIMES_BUILD_ALLOW_DARWIN to allow a single darwin triple.")
|
|
|
|
endif()
|
|
|
|
elseif(component_lower MATCHES "^ios|^macos|^tvos|^watchos")
|
|
|
|
message(FATAL_ERROR "${error}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
2017-11-27 23:31:11 +01:00
|
|
|
function(builtin_default_target compiler_rt_path)
|
2019-02-21 00:06:10 +01:00
|
|
|
cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
|
|
|
|
|
2020-09-04 22:44:40 +02:00
|
|
|
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON)
|
|
|
|
# AIX should fold 32-bit & 64-bit arch libraries into a single archive.
|
|
|
|
if (TARGET_TRIPLE MATCHES "aix")
|
|
|
|
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF)
|
|
|
|
endif()
|
|
|
|
|
2017-09-09 00:26:50 +02:00
|
|
|
llvm_ExternalProject_Add(builtins
|
2017-11-27 23:31:11 +01:00
|
|
|
${compiler_rt_path}/lib/builtins
|
2019-02-21 00:06:10 +01:00
|
|
|
DEPENDS ${ARG_DEPENDS}
|
2017-09-09 00:26:50 +02:00
|
|
|
CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
|
|
|
|
-DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
|
2018-06-28 05:11:52 +02:00
|
|
|
-DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TRIPLE}
|
2020-09-04 22:44:40 +02:00
|
|
|
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
|
2017-09-09 00:26:50 +02:00
|
|
|
-DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
|
|
|
|
-DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE}
|
2017-11-15 00:47:20 +01:00
|
|
|
-DCMAKE_C_COMPILER_WORKS=ON
|
|
|
|
-DCMAKE_ASM_COMPILER_WORKS=ON
|
2020-06-15 12:05:13 +02:00
|
|
|
${BUILTINS_CMAKE_ARGS}
|
2017-09-09 00:26:50 +02:00
|
|
|
PASSTHROUGH_PREFIXES COMPILER_RT
|
|
|
|
USE_TOOLCHAIN
|
|
|
|
${EXTRA_ARGS})
|
|
|
|
endfunction()
|
|
|
|
|
2017-11-27 23:31:11 +01:00
|
|
|
function(builtin_register_target compiler_rt_path target)
|
2019-02-21 00:06:10 +01:00
|
|
|
cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
|
|
|
|
|
[runtimes] Allow LLVM_BUILTIN_TARGETS to include Darwin
We have two ways of using the runtimes build setup to build the
builtins. You can either have an empty LLVM_BUILTIN_TARGETS (or have it
include the "default" target), in which case builtin_default_target is
called to set up the default target, or you can have actual triples in
LLVM_BUILTIN_TARGETS, in which case builtin_register_target is called
for each triple. builtin_default_target lets you build the builtins for
Darwin (assuming your default triple is Darwin); builtin_register_target
does not.
I don't understand the reason for this distinction. The Darwin builtins
build is special in that a single CMake configure handles building the
builtins for multiple platforms (e.g. macOS, iPhoneSimulator, and iOS)
and architectures (e.g. arm64, armv7, and x86_64). Consequently, if you
specify multiple Darwin triples in LLVM_BUILTIN_TARGETS, expecting each
configure to only build for that particular triple, it won't work.
However, if you specify a *single* x86_64-apple-darwin triple in
LLVM_BUILTIN_TARGETS, that single configure will build the builtins for
all Darwin targets, exactly the same way that the default target would.
The only difference between the configuration for the default target and
the x86_64-apple-darwin triple is that the latter runs the configuration
with `-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON`, but that makes no
difference for Apple targets (none of the CMake codepaths which have
different behavior based on that variable are run for Apple targets).
I tested this by running two builtins builds on my Mac, one with the
default target and one with the x86_64-apple-darwin19.5.0 target (which
is the default target triple for my clang). The only relevant
CMakeCache.txt difference was the following, and as discussed above, it
has no effect on the actual build for Apple targets:
```
-//Default triple for which compiler-rt runtimes will be built.
-COMPILER_RT_DEFAULT_TARGET_TRIPLE:STRING=x86_64-apple-darwin19.5.0
+//No help, variable specified on the command line.
+COMPILER_RT_DEFAULT_TARGET_ONLY:UNINITIALIZED=ON
```
Furthermore, when I add the `-D` flag to compiler-rt's libtool
invocations, the libraries produced by the two builds are *identical*.
If anything, I would expect builtin_register_target to complain if you
tried specifying a triple for a particular Apple platform triple (e.g.
macosx), since that's the scenario in which it won't work as you want.
The generic darwin triple should be fine though, as best as I can tell.
I'm happy to add the error for specific Apple platform triples, either
in this diff or in a follow-up.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D86313
2020-08-20 21:18:15 +02:00
|
|
|
check_apple_target(${target} builtin)
|
2017-09-09 00:26:50 +02:00
|
|
|
|
|
|
|
get_cmake_property(variableNames VARIABLES)
|
|
|
|
foreach(variableName ${variableNames})
|
2019-04-23 01:31:39 +02:00
|
|
|
string(FIND "${variableName}" "BUILTINS_${target}" out)
|
|
|
|
if("${out}" EQUAL 0)
|
2017-09-09 00:26:50 +02:00
|
|
|
string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
|
2020-01-28 02:04:21 +01:00
|
|
|
string(REPLACE ";" "|" new_value "${${variableName}}")
|
|
|
|
list(APPEND ${target}_extra_args "-D${new_name}=${new_value}")
|
2017-09-09 00:26:50 +02:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
llvm_ExternalProject_Add(builtins-${target}
|
2017-11-27 23:31:11 +01:00
|
|
|
${compiler_rt_path}/lib/builtins
|
2019-02-21 00:06:10 +01:00
|
|
|
DEPENDS ${ARG_DEPENDS}
|
2017-09-09 00:26:50 +02:00
|
|
|
CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
|
|
|
|
-DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
|
2018-06-28 05:11:52 +02:00
|
|
|
-DLLVM_DEFAULT_TARGET_TRIPLE=${target}
|
|
|
|
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
|
2017-09-09 00:26:50 +02:00
|
|
|
-DCMAKE_C_COMPILER_TARGET=${target}
|
|
|
|
-DCMAKE_ASM_COMPILER_TARGET=${target}
|
2017-11-15 00:47:20 +01:00
|
|
|
-DCMAKE_C_COMPILER_WORKS=ON
|
|
|
|
-DCMAKE_ASM_COMPILER_WORKS=ON
|
|
|
|
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
|
2017-09-09 00:26:50 +02:00
|
|
|
${${target}_extra_args}
|
|
|
|
USE_TOOLCHAIN
|
|
|
|
${EXTRA_ARGS})
|
|
|
|
endfunction()
|
|
|
|
|
2016-06-24 00:07:21 +02:00
|
|
|
# If compiler-rt is present we need to build the builtin libraries first. This
|
|
|
|
# is required because the other runtimes need the builtin libraries present
|
|
|
|
# before the just-built compiler can pass the configuration tests.
|
2017-11-27 23:31:11 +01:00
|
|
|
get_compiler_rt_path(compiler_rt_path)
|
|
|
|
if(compiler_rt_path)
|
2017-03-24 03:21:11 +01:00
|
|
|
if(NOT LLVM_BUILTIN_TARGETS)
|
2019-02-21 00:06:10 +01:00
|
|
|
builtin_default_target(${compiler_rt_path}
|
[build] Rename clang-headers to clang-resource-headers
Summary:
The current install-clang-headers target installs clang's resource
directory headers. This is different from the install-llvm-headers
target, which installs LLVM's API headers. We want to introduce the
corresponding target to clang, and the natural name for that new target
would be install-clang-headers. Rename the existing target to
install-clang-resource-headers to free up the install-clang-headers name
for the new target, following the discussion on cfe-dev [1].
I didn't find any bots on zorg referencing install-clang-headers. I'll
send out another PSA to cfe-dev to accompany this rename.
[1] http://lists.llvm.org/pipermail/cfe-dev/2019-February/061365.html
Reviewers: beanz, phosek, tstellar, rnk, dim, serge-sans-paille
Subscribers: mgorny, javed.absar, jdoerfert, #sanitizers, openmp-commits, lldb-commits, cfe-commits, llvm-commits
Tags: #clang, #sanitizers, #lldb, #openmp, #llvm
Differential Revision: https://reviews.llvm.org/D58791
llvm-svn: 355340
2019-03-04 22:19:53 +01:00
|
|
|
DEPENDS clang-resource-headers)
|
2016-12-13 00:15:10 +01:00
|
|
|
else()
|
2017-09-09 00:26:50 +02:00
|
|
|
if("default" IN_LIST LLVM_BUILTIN_TARGETS)
|
2019-02-21 00:06:10 +01:00
|
|
|
builtin_default_target(${compiler_rt_path}
|
[build] Rename clang-headers to clang-resource-headers
Summary:
The current install-clang-headers target installs clang's resource
directory headers. This is different from the install-llvm-headers
target, which installs LLVM's API headers. We want to introduce the
corresponding target to clang, and the natural name for that new target
would be install-clang-headers. Rename the existing target to
install-clang-resource-headers to free up the install-clang-headers name
for the new target, following the discussion on cfe-dev [1].
I didn't find any bots on zorg referencing install-clang-headers. I'll
send out another PSA to cfe-dev to accompany this rename.
[1] http://lists.llvm.org/pipermail/cfe-dev/2019-February/061365.html
Reviewers: beanz, phosek, tstellar, rnk, dim, serge-sans-paille
Subscribers: mgorny, javed.absar, jdoerfert, #sanitizers, openmp-commits, lldb-commits, cfe-commits, llvm-commits
Tags: #clang, #sanitizers, #lldb, #openmp, #llvm
Differential Revision: https://reviews.llvm.org/D58791
llvm-svn: 355340
2019-03-04 22:19:53 +01:00
|
|
|
DEPENDS clang-resource-headers)
|
2017-09-09 00:26:50 +02:00
|
|
|
list(REMOVE_ITEM LLVM_BUILTIN_TARGETS "default")
|
|
|
|
else()
|
|
|
|
add_custom_target(builtins)
|
|
|
|
add_custom_target(install-builtins)
|
2017-12-08 20:42:46 +01:00
|
|
|
add_custom_target(install-builtins-stripped)
|
2017-09-09 00:26:50 +02:00
|
|
|
endif()
|
|
|
|
|
2016-12-13 00:15:10 +01:00
|
|
|
foreach(target ${LLVM_BUILTIN_TARGETS})
|
2019-02-21 00:06:10 +01:00
|
|
|
builtin_register_target(${compiler_rt_path} ${target}
|
[build] Rename clang-headers to clang-resource-headers
Summary:
The current install-clang-headers target installs clang's resource
directory headers. This is different from the install-llvm-headers
target, which installs LLVM's API headers. We want to introduce the
corresponding target to clang, and the natural name for that new target
would be install-clang-headers. Rename the existing target to
install-clang-resource-headers to free up the install-clang-headers name
for the new target, following the discussion on cfe-dev [1].
I didn't find any bots on zorg referencing install-clang-headers. I'll
send out another PSA to cfe-dev to accompany this rename.
[1] http://lists.llvm.org/pipermail/cfe-dev/2019-February/061365.html
Reviewers: beanz, phosek, tstellar, rnk, dim, serge-sans-paille
Subscribers: mgorny, javed.absar, jdoerfert, #sanitizers, openmp-commits, lldb-commits, cfe-commits, llvm-commits
Tags: #clang, #sanitizers, #lldb, #openmp, #llvm
Differential Revision: https://reviews.llvm.org/D58791
llvm-svn: 355340
2019-03-04 22:19:53 +01:00
|
|
|
DEPENDS clang-resource-headers)
|
2017-07-12 01:41:15 +02:00
|
|
|
|
2016-12-13 00:15:10 +01:00
|
|
|
add_dependencies(builtins builtins-${target})
|
2017-06-02 21:38:11 +02:00
|
|
|
add_dependencies(install-builtins install-builtins-${target})
|
2017-12-08 20:42:46 +01:00
|
|
|
add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
|
2016-12-13 00:15:10 +01:00
|
|
|
endforeach()
|
|
|
|
endif()
|
2016-06-24 00:07:21 +02:00
|
|
|
set(deps builtins)
|
2016-10-19 23:50:25 +02:00
|
|
|
# We don't need to depend on the builtins if we're building instrumented
|
|
|
|
# because the next stage will use the same compiler used to build this stage.
|
|
|
|
if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
|
|
|
|
add_dependencies(clang-bootstrap-deps builtins)
|
|
|
|
endif()
|
2016-06-24 00:07:21 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# We create a list the names of all the runtime projects in all uppercase and
|
|
|
|
# with dashes turned to underscores. This gives us the CMake variable prefixes
|
|
|
|
# for all variables that will apply to runtimes.
|
|
|
|
foreach(entry ${runtimes})
|
|
|
|
get_filename_component(projName ${entry} NAME)
|
|
|
|
string(REPLACE "-" "_" canon_name ${projName})
|
|
|
|
string(TOUPPER ${canon_name} canon_name)
|
|
|
|
list(APPEND prefixes ${canon_name})
|
2020-12-21 00:39:19 +01:00
|
|
|
if (${canon_name} STREQUAL "OPENMP")
|
|
|
|
list(APPEND prefixes "LIBOMP" "LIBOMPTARGET")
|
|
|
|
endif()
|
2020-03-06 23:38:07 +01:00
|
|
|
# Many compiler-rt options start with SANITIZER_ rather than COMPILER_RT_,
|
|
|
|
# so when compiler-rt is enabled, consider both.
|
|
|
|
if(canon_name STREQUAL "COMPILER_RT")
|
|
|
|
list(APPEND prefixes SANITIZER)
|
|
|
|
endif()
|
2016-08-18 23:47:18 +02:00
|
|
|
|
|
|
|
string(FIND ${projName} "lib" LIB_IDX)
|
|
|
|
if(LIB_IDX EQUAL 0)
|
|
|
|
string(SUBSTRING ${projName} 3 -1 projName)
|
|
|
|
endif()
|
|
|
|
list(APPEND runtime_names ${projName})
|
2016-06-24 00:07:21 +02:00
|
|
|
endforeach()
|
|
|
|
|
2019-03-09 02:26:55 +01:00
|
|
|
if(LLVM_RUNTIME_BUILD_ID_LINK_TARGETS)
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/llvm-strip-link.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/llvm-strip-link
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2017-11-16 22:28:54 +01:00
|
|
|
function(runtime_default_target)
|
2019-02-21 00:06:10 +01:00
|
|
|
cmake_parse_arguments(ARG "" "" "DEPENDS;PREFIXES" ${ARGN})
|
2017-11-16 22:28:54 +01:00
|
|
|
|
2017-09-09 00:26:50 +02:00
|
|
|
include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL)
|
2019-06-11 02:25:57 +02:00
|
|
|
set(SUB_CHECK_TARGETS ${SUB_CHECK_TARGETS} PARENT_SCOPE)
|
2017-09-09 00:26:50 +02:00
|
|
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
|
|
|
|
|
|
|
|
foreach(runtime_name ${runtime_names})
|
|
|
|
list(APPEND extra_targets
|
|
|
|
${runtime_name}
|
2017-12-08 20:42:46 +01:00
|
|
|
install-${runtime_name}
|
|
|
|
install-${runtime_name}-stripped)
|
2017-09-09 00:26:50 +02:00
|
|
|
if(LLVM_INCLUDE_TESTS)
|
|
|
|
list(APPEND test_targets check-${runtime_name})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2018-05-17 18:58:44 +02:00
|
|
|
foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
|
|
|
|
if(NOT ${component} IN_LIST SUB_COMPONENTS)
|
|
|
|
list(APPEND extra_targets ${component} install-${component} install-${component}-stripped)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2017-09-09 00:26:50 +02:00
|
|
|
|
|
|
|
if(LLVM_INCLUDE_TESTS)
|
|
|
|
list(APPEND test_targets runtimes-test-depends check-runtimes)
|
|
|
|
endif()
|
|
|
|
|
2020-09-04 22:44:40 +02:00
|
|
|
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON)
|
|
|
|
# AIX should fold 32-bit & 64-bit arch libraries into a single archive.
|
|
|
|
if (TARGET_TRIPLE MATCHES "aix")
|
|
|
|
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF)
|
|
|
|
endif()
|
|
|
|
|
2017-09-09 00:26:50 +02:00
|
|
|
llvm_ExternalProject_Add(runtimes
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
2020-09-29 01:12:48 +02:00
|
|
|
DEPENDS ${ARG_DEPENDS}
|
2017-09-09 00:26:50 +02:00
|
|
|
# Builtins were built separately above
|
|
|
|
CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
|
|
|
|
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
|
2018-06-28 05:11:52 +02:00
|
|
|
-DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TRIPLE}
|
2019-05-31 03:34:51 +02:00
|
|
|
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
|
2020-09-04 22:44:40 +02:00
|
|
|
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
|
2018-01-09 00:50:59 +01:00
|
|
|
-DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
|
|
|
|
-DCMAKE_CXX_COMPILER_TARGET=${TARGET_TRIPLE}
|
|
|
|
-DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE}
|
2017-11-15 00:47:20 +01:00
|
|
|
-DCMAKE_C_COMPILER_WORKS=ON
|
|
|
|
-DCMAKE_CXX_COMPILER_WORKS=ON
|
|
|
|
-DCMAKE_ASM_COMPILER_WORKS=ON
|
2020-06-15 12:05:13 +02:00
|
|
|
${RUNTIMES_CMAKE_ARGS}
|
2017-11-27 23:31:11 +01:00
|
|
|
PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
|
|
|
|
${ARG_PREFIXES}
|
2017-09-09 00:26:50 +02:00
|
|
|
EXTRA_TARGETS ${extra_targets}
|
|
|
|
${test_targets}
|
|
|
|
${SUB_COMPONENTS}
|
|
|
|
${SUB_CHECK_TARGETS}
|
|
|
|
${SUB_INSTALL_TARGETS}
|
|
|
|
USE_TOOLCHAIN
|
|
|
|
${EXTRA_ARGS})
|
|
|
|
endfunction()
|
|
|
|
|
2017-07-12 01:41:15 +02:00
|
|
|
# runtime_register_target(target)
|
|
|
|
# Utility function to register external runtime target.
|
2017-11-16 22:28:54 +01:00
|
|
|
function(runtime_register_target name target)
|
2020-07-15 04:24:22 +02:00
|
|
|
cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS" ${ARGN})
|
2017-09-09 00:26:50 +02:00
|
|
|
include(${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake OPTIONAL)
|
|
|
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake)
|
2017-08-16 21:13:45 +02:00
|
|
|
|
[runtimes] Allow LLVM_BUILTIN_TARGETS to include Darwin
We have two ways of using the runtimes build setup to build the
builtins. You can either have an empty LLVM_BUILTIN_TARGETS (or have it
include the "default" target), in which case builtin_default_target is
called to set up the default target, or you can have actual triples in
LLVM_BUILTIN_TARGETS, in which case builtin_register_target is called
for each triple. builtin_default_target lets you build the builtins for
Darwin (assuming your default triple is Darwin); builtin_register_target
does not.
I don't understand the reason for this distinction. The Darwin builtins
build is special in that a single CMake configure handles building the
builtins for multiple platforms (e.g. macOS, iPhoneSimulator, and iOS)
and architectures (e.g. arm64, armv7, and x86_64). Consequently, if you
specify multiple Darwin triples in LLVM_BUILTIN_TARGETS, expecting each
configure to only build for that particular triple, it won't work.
However, if you specify a *single* x86_64-apple-darwin triple in
LLVM_BUILTIN_TARGETS, that single configure will build the builtins for
all Darwin targets, exactly the same way that the default target would.
The only difference between the configuration for the default target and
the x86_64-apple-darwin triple is that the latter runs the configuration
with `-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON`, but that makes no
difference for Apple targets (none of the CMake codepaths which have
different behavior based on that variable are run for Apple targets).
I tested this by running two builtins builds on my Mac, one with the
default target and one with the x86_64-apple-darwin19.5.0 target (which
is the default target triple for my clang). The only relevant
CMakeCache.txt difference was the following, and as discussed above, it
has no effect on the actual build for Apple targets:
```
-//Default triple for which compiler-rt runtimes will be built.
-COMPILER_RT_DEFAULT_TARGET_TRIPLE:STRING=x86_64-apple-darwin19.5.0
+//No help, variable specified on the command line.
+COMPILER_RT_DEFAULT_TARGET_ONLY:UNINITIALIZED=ON
```
Furthermore, when I add the `-D` flag to compiler-rt's libtool
invocations, the libraries produced by the two builds are *identical*.
If anything, I would expect builtin_register_target to complain if you
tried specifying a triple for a particular Apple platform triple (e.g.
macosx), since that's the scenario in which it won't work as you want.
The generic darwin triple should be fine though, as best as I can tell.
I'm happy to add the error for specific Apple platform triples, either
in this diff or in a follow-up.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D86313
2020-08-20 21:18:15 +02:00
|
|
|
check_apple_target(${target} runtime)
|
|
|
|
|
2019-02-21 00:06:10 +01:00
|
|
|
set(${name}_deps ${ARG_DEPENDS})
|
2017-08-16 21:13:45 +02:00
|
|
|
if(NOT name STREQUAL target)
|
|
|
|
list(APPEND ${name}_deps runtimes-${target})
|
2017-07-12 01:41:15 +02:00
|
|
|
endif()
|
2016-08-25 19:18:41 +02:00
|
|
|
|
|
|
|
foreach(runtime_name ${runtime_names})
|
2018-06-27 05:14:41 +02:00
|
|
|
set(${runtime_name}-${name} ${runtime_name})
|
|
|
|
set(install-${runtime_name}-${name} install-${runtime_name})
|
|
|
|
set(install-${runtime_name}-${name}-stripped install-${runtime_name}-stripped)
|
|
|
|
list(APPEND ${name}_extra_targets ${runtime_name}-${name} install-${runtime_name}-${name} install-${runtime_name}-${name}-stripped)
|
2017-07-10 21:23:28 +02:00
|
|
|
if(LLVM_INCLUDE_TESTS)
|
2018-06-27 05:14:41 +02:00
|
|
|
set(check-${runtime_name}-${name} check-${runtime_name} )
|
|
|
|
list(APPEND ${name}_test_targets check-${runtime_name}-${name})
|
2017-07-10 21:23:28 +02:00
|
|
|
endif()
|
2016-08-25 19:18:41 +02:00
|
|
|
endforeach()
|
|
|
|
|
2017-09-02 04:28:03 +02:00
|
|
|
foreach(target_name IN LISTS SUB_COMPONENTS SUB_INSTALL_TARGETS)
|
2018-06-27 05:14:41 +02:00
|
|
|
set(${target_name}-${name} ${target_name})
|
|
|
|
list(APPEND ${name}_extra_targets ${target_name}-${name})
|
2017-07-12 01:41:15 +02:00
|
|
|
endforeach()
|
|
|
|
|
2018-05-17 18:58:44 +02:00
|
|
|
foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
|
2019-02-16 04:57:35 +01:00
|
|
|
set(${component}-${name} ${component})
|
2020-01-23 07:16:28 +01:00
|
|
|
set(install-${component}-${name} install-${component})
|
2020-01-23 07:28:14 +01:00
|
|
|
set(install-${component}-${name}-stripped install-${component}-stripped)
|
|
|
|
list(APPEND ${name}_extra_targets ${component}-${name} install-${component}-${name} install-${component}-${name}-stripped)
|
2018-05-17 18:58:44 +02:00
|
|
|
endforeach()
|
|
|
|
|
2016-08-26 22:08:57 +02:00
|
|
|
if(LLVM_INCLUDE_TESTS)
|
2018-06-27 05:14:41 +02:00
|
|
|
set(runtimes-test-depends-${name} runtimes-test-depends)
|
|
|
|
set(check-runtimes-${name} check-runtimes)
|
|
|
|
list(APPEND ${name}_test_targets runtimes-test-depends-${name} check-runtimes-${name})
|
2017-08-16 21:13:45 +02:00
|
|
|
foreach(target_name IN LISTS SUB_CHECK_TARGETS)
|
2018-06-27 05:14:41 +02:00
|
|
|
set(${target_name}-${name} ${target_name})
|
|
|
|
list(APPEND ${name}_test_targets ${target_name}-${name})
|
|
|
|
list(APPEND test_targets ${target_name}-${name})
|
2016-08-26 22:34:11 +02:00
|
|
|
endforeach()
|
2017-07-12 01:41:15 +02:00
|
|
|
set(test_targets "${test_targets}" PARENT_SCOPE)
|
2016-08-26 22:08:57 +02:00
|
|
|
endif()
|
|
|
|
|
2020-07-15 04:24:22 +02:00
|
|
|
set(${name}_extra_args ${ARG_CMAKE_ARGS})
|
2017-07-12 01:41:15 +02:00
|
|
|
get_cmake_property(variableNames VARIABLES)
|
|
|
|
foreach(variableName ${variableNames})
|
2020-01-18 00:16:34 +01:00
|
|
|
string(FIND "${variableName}" "RUNTIMES_${target}_" out)
|
2019-04-23 01:31:39 +02:00
|
|
|
if("${out}" EQUAL 0)
|
2020-01-18 00:16:34 +01:00
|
|
|
string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
|
2020-01-28 02:04:21 +01:00
|
|
|
string(REPLACE ";" "|" new_value "${${variableName}}")
|
|
|
|
list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
|
2019-04-23 01:31:39 +02:00
|
|
|
endif()
|
2020-01-18 00:16:34 +01:00
|
|
|
endforeach()
|
2020-06-10 16:18:30 +02:00
|
|
|
if(NOT "${name}" STREQUAL "${target}")
|
|
|
|
foreach(variableName ${variableNames})
|
|
|
|
string(FIND "${variableName}" "RUNTIMES_${name}_" out)
|
|
|
|
if("${out}" EQUAL 0)
|
|
|
|
string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
|
|
|
|
string(REPLACE ";" "|" new_value "${${variableName}}")
|
|
|
|
list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2017-07-12 01:41:15 +02:00
|
|
|
|
2020-01-29 22:40:36 +01:00
|
|
|
if(NOT RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES AND NOT RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES)
|
2020-01-29 21:16:40 +01:00
|
|
|
string(REPLACE ";" "|" LLVM_ENABLE_RUNTIMES_PASSTHROUGH "${LLVM_ENABLE_RUNTIMES}")
|
|
|
|
list(APPEND ${name}_extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH})
|
|
|
|
endif()
|
|
|
|
|
2019-03-09 02:26:55 +01:00
|
|
|
if(target IN_LIST LLVM_RUNTIME_BUILD_ID_LINK_TARGETS)
|
|
|
|
list(APPEND EXTRA_ARGS STRIP_TOOL ${CMAKE_CURRENT_BINARY_DIR}/llvm-strip-link)
|
|
|
|
endif()
|
|
|
|
|
2017-08-16 21:13:45 +02:00
|
|
|
llvm_ExternalProject_Add(runtimes-${name}
|
2016-06-24 00:07:21 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
2020-09-29 01:12:48 +02:00
|
|
|
DEPENDS ${${name}_deps}
|
2016-06-24 00:07:21 +02:00
|
|
|
# Builtins were built separately above
|
|
|
|
CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
|
2016-08-26 22:08:57 +02:00
|
|
|
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
|
2018-06-28 05:11:52 +02:00
|
|
|
-DLLVM_DEFAULT_TARGET_TRIPLE=${target}
|
2019-05-31 03:34:51 +02:00
|
|
|
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
|
2018-06-28 05:11:52 +02:00
|
|
|
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
|
2017-07-12 01:41:15 +02:00
|
|
|
-DCMAKE_C_COMPILER_TARGET=${target}
|
|
|
|
-DCMAKE_CXX_COMPILER_TARGET=${target}
|
|
|
|
-DCMAKE_ASM_COMPILER_TARGET=${target}
|
|
|
|
-DCMAKE_C_COMPILER_WORKS=ON
|
|
|
|
-DCMAKE_CXX_COMPILER_WORKS=ON
|
|
|
|
-DCMAKE_ASM_COMPILER_WORKS=ON
|
|
|
|
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
|
2017-09-09 00:26:50 +02:00
|
|
|
-DLLVM_RUNTIMES_TARGET=${name}
|
2017-08-16 21:13:45 +02:00
|
|
|
${${name}_extra_args}
|
|
|
|
EXTRA_TARGETS ${${name}_extra_targets}
|
|
|
|
${${name}_test_targets}
|
2017-03-23 23:40:10 +01:00
|
|
|
USE_TOOLCHAIN
|
|
|
|
${EXTRA_ARGS})
|
2017-07-12 01:41:15 +02:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
if(runtimes)
|
|
|
|
# Create a runtimes target that uses this file as its top-level CMake file.
|
|
|
|
# The runtimes target is a configuration of all the runtime libraries
|
|
|
|
# together in a single CMake invocaiton.
|
|
|
|
if(NOT LLVM_RUNTIME_TARGETS)
|
2017-11-16 22:28:54 +01:00
|
|
|
runtime_default_target(
|
2019-02-21 00:06:10 +01:00
|
|
|
DEPENDS ${deps}
|
|
|
|
PREFIXES ${prefixes})
|
2019-06-11 02:25:57 +02:00
|
|
|
set(test_targets check-runtimes)
|
2017-09-09 00:26:50 +02:00
|
|
|
else()
|
|
|
|
if("default" IN_LIST LLVM_RUNTIME_TARGETS)
|
2017-11-16 22:28:54 +01:00
|
|
|
runtime_default_target(
|
2019-02-21 00:06:10 +01:00
|
|
|
DEPENDS ${deps}
|
2017-11-16 22:28:54 +01:00
|
|
|
PREFIXES ${prefixes})
|
2017-09-09 00:26:50 +02:00
|
|
|
list(REMOVE_ITEM LLVM_RUNTIME_TARGETS "default")
|
|
|
|
else()
|
|
|
|
add_custom_target(runtimes)
|
|
|
|
add_custom_target(runtimes-configure)
|
|
|
|
add_custom_target(install-runtimes)
|
2017-12-08 20:42:46 +01:00
|
|
|
add_custom_target(install-runtimes-stripped)
|
2017-07-12 01:41:15 +02:00
|
|
|
if(LLVM_INCLUDE_TESTS)
|
2017-09-09 00:26:50 +02:00
|
|
|
add_custom_target(check-runtimes)
|
|
|
|
add_custom_target(runtimes-test-depends)
|
|
|
|
set(test_targets "")
|
2017-07-12 01:41:15 +02:00
|
|
|
endif()
|
2020-02-12 03:24:57 +01:00
|
|
|
foreach(runtime_name ${runtime_names})
|
|
|
|
add_custom_target(${runtime_name})
|
|
|
|
add_custom_target(install-${runtime_name})
|
|
|
|
add_custom_target(install-${runtime_name}-stripped)
|
|
|
|
endforeach()
|
2018-05-17 18:58:44 +02:00
|
|
|
if(LLVM_RUNTIME_DISTRIBUTION_COMPONENTS)
|
|
|
|
foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
|
|
|
|
add_custom_target(${component})
|
|
|
|
add_custom_target(install-${component})
|
2020-01-23 07:28:14 +01:00
|
|
|
add_custom_target(install-${component}-stripped)
|
2018-05-17 18:58:44 +02:00
|
|
|
endforeach()
|
|
|
|
endif()
|
2017-07-12 01:41:15 +02:00
|
|
|
endif()
|
|
|
|
|
2017-08-16 21:13:45 +02:00
|
|
|
foreach(name ${LLVM_RUNTIME_TARGETS})
|
2018-06-27 05:35:53 +02:00
|
|
|
runtime_register_target(${name} ${name}
|
2019-02-21 00:06:10 +01:00
|
|
|
DEPENDS ${deps})
|
2017-07-12 01:41:15 +02:00
|
|
|
|
2017-08-16 21:13:45 +02:00
|
|
|
add_dependencies(runtimes runtimes-${name})
|
|
|
|
add_dependencies(runtimes-configure runtimes-${name}-configure)
|
|
|
|
add_dependencies(install-runtimes install-runtimes-${name})
|
2017-12-08 20:42:46 +01:00
|
|
|
add_dependencies(install-runtimes-stripped install-runtimes-${name}-stripped)
|
2017-07-12 01:41:15 +02:00
|
|
|
if(LLVM_INCLUDE_TESTS)
|
2017-08-16 21:13:45 +02:00
|
|
|
add_dependencies(check-runtimes check-runtimes-${name})
|
|
|
|
add_dependencies(runtimes-test-depends runtimes-test-depends-${name})
|
2017-07-12 01:41:15 +02:00
|
|
|
endif()
|
2020-02-12 03:24:57 +01:00
|
|
|
foreach(runtime_name ${runtime_names})
|
|
|
|
add_dependencies(${runtime_name} ${runtime_name}-${name})
|
|
|
|
add_dependencies(install-${runtime_name} install-${runtime_name}-${name})
|
|
|
|
add_dependencies(install-${runtime_name}-stripped install-${runtime_name}-${name}-stripped)
|
|
|
|
endforeach()
|
2017-07-12 01:41:15 +02:00
|
|
|
endforeach()
|
2018-06-27 05:35:53 +02:00
|
|
|
|
2019-04-23 01:31:39 +02:00
|
|
|
foreach(multilib ${LLVM_RUNTIME_MULTILIBS})
|
|
|
|
foreach(name ${LLVM_RUNTIME_MULTILIB_${multilib}_TARGETS})
|
|
|
|
runtime_register_target(${name}+${multilib} ${name}
|
2019-02-21 00:06:10 +01:00
|
|
|
DEPENDS runtimes-${name}
|
2019-04-23 01:31:39 +02:00
|
|
|
CMAKE_ARGS -DLLVM_RUNTIMES_PREFIX=${name}/
|
2019-05-22 23:08:33 +02:00
|
|
|
-DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib})
|
2019-04-23 01:31:39 +02:00
|
|
|
add_dependencies(runtimes runtimes-${name}+${multilib})
|
|
|
|
add_dependencies(runtimes-configure runtimes-${name}+${multilib}-configure)
|
|
|
|
add_dependencies(install-runtimes install-runtimes-${name}+${multilib})
|
|
|
|
add_dependencies(install-runtimes-stripped install-runtimes-${name}+${multilib}-stripped)
|
2020-02-12 03:24:57 +01:00
|
|
|
foreach(runtime_name ${runtime_names})
|
|
|
|
add_dependencies(${runtime_name} ${runtime_name}-${name}+${multilib})
|
|
|
|
add_dependencies(install-${runtime_name} install-${runtime_name}-${name}+${multilib})
|
|
|
|
add_dependencies(install-${runtime_name}-stripped install-${runtime_name}-${name}+${multilib}-stripped)
|
|
|
|
endforeach()
|
2018-06-27 05:35:53 +02:00
|
|
|
endforeach()
|
|
|
|
endforeach()
|
2017-07-12 01:41:15 +02:00
|
|
|
endif()
|
|
|
|
|
2016-10-19 23:50:25 +02:00
|
|
|
if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
|
[llvm/runtimes] Add runtimes as a dependency of clang-bootstrap-deps
Summary: With the new LLVM_ENABLE_RUNTIMES option introduced in https://reviews.llvm.org/D40233, compiler-rt can now be included as a runtime. Since compiler-rt is needed for PGO, runtimes needs to be included as a dependency of clang-bootstrap-deps when building the stage1 compiler.
Reviewers: beanz, phosek, compnerd, smeenai, plotfi, xiaobai
Reviewed By: phosek
Subscribers: smeenai, beanz, phosek, mgorny, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71430
2019-12-17 01:08:07 +01:00
|
|
|
# TODO: This is a hack needed because the libcxx headers are copied into the
|
|
|
|
# build directory during configuration. Without that step the clang in the
|
|
|
|
# build directory cannot find the C++ headers in certain configurations.
|
|
|
|
# I need to build a mechanism for runtime projects to provide CMake code
|
|
|
|
# that executes at LLVM configuration time to handle this case.
|
2016-10-19 23:50:25 +02:00
|
|
|
add_dependencies(clang-bootstrap-deps runtimes-configure)
|
[llvm/runtimes] Add runtimes as a dependency of clang-bootstrap-deps
Summary: With the new LLVM_ENABLE_RUNTIMES option introduced in https://reviews.llvm.org/D40233, compiler-rt can now be included as a runtime. Since compiler-rt is needed for PGO, runtimes needs to be included as a dependency of clang-bootstrap-deps when building the stage1 compiler.
Reviewers: beanz, phosek, compnerd, smeenai, plotfi, xiaobai
Reviewed By: phosek
Subscribers: smeenai, beanz, phosek, mgorny, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71430
2019-12-17 01:08:07 +01:00
|
|
|
# We need to add the runtimes as a dependency because compiler-rt can be
|
|
|
|
# built as part of runtimes and we need the profile runtime for PGO
|
|
|
|
add_dependencies(clang-bootstrap-deps runtimes)
|
2016-10-19 23:50:25 +02:00
|
|
|
endif()
|
|
|
|
|
2016-08-26 22:08:57 +02:00
|
|
|
if(LLVM_INCLUDE_TESTS)
|
2016-09-01 20:26:01 +02:00
|
|
|
set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_DEPENDS runtimes-test-depends)
|
|
|
|
set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-runtimes)
|
2017-07-10 21:23:28 +02:00
|
|
|
|
|
|
|
set(RUNTIMES_TEST_DEPENDS
|
|
|
|
FileCheck
|
|
|
|
count
|
|
|
|
llvm-nm
|
|
|
|
llvm-objdump
|
|
|
|
llvm-xray
|
|
|
|
not
|
|
|
|
obj2yaml
|
|
|
|
sancov
|
|
|
|
sanstats
|
2019-05-22 23:42:06 +02:00
|
|
|
gtest_main
|
|
|
|
gtest
|
2017-07-10 21:23:28 +02:00
|
|
|
)
|
2017-07-12 01:41:15 +02:00
|
|
|
foreach(target ${test_targets} ${SUB_CHECK_TARGETS})
|
2017-07-10 21:23:28 +02:00
|
|
|
add_dependencies(${target} ${RUNTIMES_TEST_DEPENDS})
|
|
|
|
endforeach()
|
2016-08-26 22:08:57 +02:00
|
|
|
endif()
|
2016-06-24 00:07:21 +02:00
|
|
|
endif()
|
|
|
|
endif()
|