2020-04-22 23:15:05 +08:00
|
|
|
cmake_minimum_required(VERSION 3.13.4)
|
2016-03-29 02:24:22 +08:00
|
|
|
|
|
|
|
# If we are not building as a part of LLVM, build Clang as an
|
|
|
|
# standalone project, using LLVM as an external library:
|
|
|
|
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
|
|
|
|
project(Clang)
|
|
|
|
|
2020-07-11 00:33:54 +08:00
|
|
|
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS NO)
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
# Rely on llvm-config.
|
|
|
|
set(CONFIG_OUTPUT)
|
|
|
|
if(LLVM_CONFIG)
|
CMake: Deprecate using llvm-config to detect llvm installation
Summary:
clang currently uses llvm-config to determine the installation paths
for llvm's headers and binaries. clang is also using LLVM's cmake
files to determine other information about the LLVM build, like
LLVM_LIBDIR_SUFFIX, LLVM_VERSION_*, etc. Since the installation
paths are also available via the cmake files, we can simplify the code
by only relying on information from cmake about the LLVM install and
dropping the use of llvm-config altogether.
In addition to simplifying the code, the cmake files have more
accurate information about the llvm installation paths. llvm-config
assumes that the lib, bin, and cmake directories are always located
in the same place relative to the path of the llvm-config executable.
This can be wrong if a user decides to install headers, binaries
or libraries to a non-standard location: e.g. static libraries
installed to /usr/lib/llvm6.0/
This patch takes the first step towards dropping llvm-config by
removing the automatic detection of llvm-config (users can still
manually supply a path to llvm-config by passing
-DLLVM_CONFIG=/usr/bin/llvm-config to cmake) and adding a
deprecation warning when users try to use this option.
Reviewers: chandlerc, beanz, mgorny, chapuni
Subscribers: mehdi_amini, dexonsmith, cfe-commits
Differential Revision: https://reviews.llvm.org/D51714
llvm-svn: 346732
2018-11-13 11:42:46 +08:00
|
|
|
set (LLVM_CONFIG_FOUND 1)
|
2016-03-29 02:24:22 +08:00
|
|
|
message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
|
CMake: Deprecate using llvm-config to detect llvm installation
Summary:
clang currently uses llvm-config to determine the installation paths
for llvm's headers and binaries. clang is also using LLVM's cmake
files to determine other information about the LLVM build, like
LLVM_LIBDIR_SUFFIX, LLVM_VERSION_*, etc. Since the installation
paths are also available via the cmake files, we can simplify the code
by only relying on information from cmake about the LLVM install and
dropping the use of llvm-config altogether.
In addition to simplifying the code, the cmake files have more
accurate information about the llvm installation paths. llvm-config
assumes that the lib, bin, and cmake directories are always located
in the same place relative to the path of the llvm-config executable.
This can be wrong if a user decides to install headers, binaries
or libraries to a non-standard location: e.g. static libraries
installed to /usr/lib/llvm6.0/
This patch takes the first step towards dropping llvm-config by
removing the automatic detection of llvm-config (users can still
manually supply a path to llvm-config by passing
-DLLVM_CONFIG=/usr/bin/llvm-config to cmake) and adding a
deprecation warning when users try to use this option.
Reviewers: chandlerc, beanz, mgorny, chapuni
Subscribers: mehdi_amini, dexonsmith, cfe-commits
Differential Revision: https://reviews.llvm.org/D51714
llvm-svn: 346732
2018-11-13 11:42:46 +08:00
|
|
|
message(DEPRECATION "Using llvm-config to detect the LLVM installation is \
|
|
|
|
deprecated. The installed cmake files should be used \
|
|
|
|
instead. CMake should be able to detect your LLVM install \
|
|
|
|
automatically, but you can also use LLVM_DIR to specify \
|
|
|
|
the path containing LLVMConfig.cmake.")
|
2016-03-29 02:24:22 +08:00
|
|
|
set(CONFIG_COMMAND ${LLVM_CONFIG}
|
|
|
|
"--assertion-mode"
|
|
|
|
"--bindir"
|
|
|
|
"--libdir"
|
|
|
|
"--includedir"
|
|
|
|
"--prefix"
|
2017-01-10 07:06:39 +08:00
|
|
|
"--src-root"
|
|
|
|
"--cmakedir")
|
2016-03-29 02:24:22 +08:00
|
|
|
execute_process(
|
|
|
|
COMMAND ${CONFIG_COMMAND}
|
|
|
|
RESULT_VARIABLE HAD_ERROR
|
|
|
|
OUTPUT_VARIABLE CONFIG_OUTPUT
|
|
|
|
)
|
|
|
|
if(NOT HAD_ERROR)
|
|
|
|
string(REGEX REPLACE
|
|
|
|
"[ \t]*[\r\n]+[ \t]*" ";"
|
|
|
|
CONFIG_OUTPUT ${CONFIG_OUTPUT})
|
|
|
|
else()
|
|
|
|
string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
|
|
|
|
message(STATUS "${CONFIG_COMMAND_STR}")
|
|
|
|
message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
|
|
|
|
endif()
|
CMake: Deprecate using llvm-config to detect llvm installation
Summary:
clang currently uses llvm-config to determine the installation paths
for llvm's headers and binaries. clang is also using LLVM's cmake
files to determine other information about the LLVM build, like
LLVM_LIBDIR_SUFFIX, LLVM_VERSION_*, etc. Since the installation
paths are also available via the cmake files, we can simplify the code
by only relying on information from cmake about the LLVM install and
dropping the use of llvm-config altogether.
In addition to simplifying the code, the cmake files have more
accurate information about the llvm installation paths. llvm-config
assumes that the lib, bin, and cmake directories are always located
in the same place relative to the path of the llvm-config executable.
This can be wrong if a user decides to install headers, binaries
or libraries to a non-standard location: e.g. static libraries
installed to /usr/lib/llvm6.0/
This patch takes the first step towards dropping llvm-config by
removing the automatic detection of llvm-config (users can still
manually supply a path to llvm-config by passing
-DLLVM_CONFIG=/usr/bin/llvm-config to cmake) and adding a
deprecation warning when users try to use this option.
Reviewers: chandlerc, beanz, mgorny, chapuni
Subscribers: mehdi_amini, dexonsmith, cfe-commits
Differential Revision: https://reviews.llvm.org/D51714
llvm-svn: 346732
2018-11-13 11:42:46 +08:00
|
|
|
|
|
|
|
list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS)
|
|
|
|
list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
|
|
|
|
list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
|
|
|
|
list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
|
|
|
|
list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
|
|
|
|
list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
|
|
|
|
list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH)
|
|
|
|
|
|
|
|
# Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes.
|
|
|
|
# CMake assumes slashes as PATH.
|
|
|
|
file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} LLVM_CMAKE_PATH)
|
2016-03-29 02:24:22 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
if(NOT MSVC_IDE)
|
|
|
|
set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
|
|
|
|
CACHE BOOL "Enable assertions")
|
|
|
|
# Assertions should follow llvm-config's.
|
|
|
|
mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
|
|
|
|
endif()
|
|
|
|
|
CMake: Deprecate using llvm-config to detect llvm installation
Summary:
clang currently uses llvm-config to determine the installation paths
for llvm's headers and binaries. clang is also using LLVM's cmake
files to determine other information about the LLVM build, like
LLVM_LIBDIR_SUFFIX, LLVM_VERSION_*, etc. Since the installation
paths are also available via the cmake files, we can simplify the code
by only relying on information from cmake about the LLVM install and
dropping the use of llvm-config altogether.
In addition to simplifying the code, the cmake files have more
accurate information about the llvm installation paths. llvm-config
assumes that the lib, bin, and cmake directories are always located
in the same place relative to the path of the llvm-config executable.
This can be wrong if a user decides to install headers, binaries
or libraries to a non-standard location: e.g. static libraries
installed to /usr/lib/llvm6.0/
This patch takes the first step towards dropping llvm-config by
removing the automatic detection of llvm-config (users can still
manually supply a path to llvm-config by passing
-DLLVM_CONFIG=/usr/bin/llvm-config to cmake) and adding a
deprecation warning when users try to use this option.
Reviewers: chandlerc, beanz, mgorny, chapuni
Subscribers: mehdi_amini, dexonsmith, cfe-commits
Differential Revision: https://reviews.llvm.org/D51714
llvm-svn: 346732
2018-11-13 11:42:46 +08:00
|
|
|
find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_PATH}")
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
|
|
|
|
|
|
|
|
# We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
|
|
|
|
# LLVM_CONFIG.
|
|
|
|
if (NOT LLVM_CONFIG_FOUND)
|
|
|
|
# Pull values from LLVMConfig.cmake. We can drop this once the llvm-config
|
|
|
|
# path is removed.
|
|
|
|
set(TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR})
|
|
|
|
set(LIBRARY_DIR ${LLVM_LIBRARY_DIR})
|
|
|
|
set(INCLUDE_DIR ${LLVM_INCLUDE_DIR})
|
|
|
|
set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
|
2019-02-20 09:11:05 +08:00
|
|
|
# The LLVM_CMAKE_PATH variable is set when doing non-standalone builds and
|
|
|
|
# used in this project, so we need to make sure we set this value.
|
|
|
|
# FIXME: LLVM_CMAKE_DIR comes from LLVMConfig.cmake. We should rename
|
|
|
|
# LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project.
|
|
|
|
set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR})
|
CMake: Deprecate using llvm-config to detect llvm installation
Summary:
clang currently uses llvm-config to determine the installation paths
for llvm's headers and binaries. clang is also using LLVM's cmake
files to determine other information about the LLVM build, like
LLVM_LIBDIR_SUFFIX, LLVM_VERSION_*, etc. Since the installation
paths are also available via the cmake files, we can simplify the code
by only relying on information from cmake about the LLVM install and
dropping the use of llvm-config altogether.
In addition to simplifying the code, the cmake files have more
accurate information about the llvm installation paths. llvm-config
assumes that the lib, bin, and cmake directories are always located
in the same place relative to the path of the llvm-config executable.
This can be wrong if a user decides to install headers, binaries
or libraries to a non-standard location: e.g. static libraries
installed to /usr/lib/llvm6.0/
This patch takes the first step towards dropping llvm-config by
removing the automatic detection of llvm-config (users can still
manually supply a path to llvm-config by passing
-DLLVM_CONFIG=/usr/bin/llvm-config to cmake) and adding a
deprecation warning when users try to use this option.
Reviewers: chandlerc, beanz, mgorny, chapuni
Subscribers: mehdi_amini, dexonsmith, cfe-commits
Differential Revision: https://reviews.llvm.org/D51714
llvm-svn: 346732
2018-11-13 11:42:46 +08:00
|
|
|
endif()
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
|
|
|
|
set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
|
|
|
|
set(LLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
|
|
|
|
set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
|
|
|
|
set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
|
|
|
|
|
|
|
|
find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
# They are used as destination of target generators.
|
|
|
|
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
|
|
|
|
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
|
|
|
|
if(WIN32 OR CYGWIN)
|
|
|
|
# DLL platform -- put DLLs into bin.
|
|
|
|
set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
|
|
|
|
else()
|
|
|
|
set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(LLVM_INSTALL_TOOLCHAIN_ONLY
|
|
|
|
"Only include toolchain files in the 'install' target." OFF)
|
|
|
|
|
|
|
|
option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN
|
|
|
|
"Set to ON to force using an old, unsupported host toolchain." OFF)
|
|
|
|
option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
|
2018-11-29 22:57:14 +08:00
|
|
|
option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON)
|
2016-03-29 02:24:22 +08:00
|
|
|
|
|
|
|
include(AddLLVM)
|
|
|
|
include(TableGen)
|
|
|
|
include(HandleLLVMOptions)
|
|
|
|
include(VersionFromVCS)
|
2019-10-08 02:14:56 +08:00
|
|
|
include(LLVMDistributionSupport)
|
2016-03-29 02:24:22 +08:00
|
|
|
|
|
|
|
set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
|
2020-07-31 06:11:40 +08:00
|
|
|
set(BUG_REPORT_URL "${LLVM_PACKAGE_BUGREPORT}" CACHE STRING
|
|
|
|
"Default URL where bug reports are to be submitted.")
|
2016-03-29 02:24:22 +08:00
|
|
|
|
|
|
|
if (NOT DEFINED LLVM_INCLUDE_TESTS)
|
|
|
|
set(LLVM_INCLUDE_TESTS ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include_directories("${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}")
|
|
|
|
link_directories("${LLVM_LIBRARY_DIR}")
|
|
|
|
|
|
|
|
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
|
|
|
|
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
|
|
|
|
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
|
|
|
|
|
|
|
|
if(LLVM_INCLUDE_TESTS)
|
2021-01-30 04:03:32 +08:00
|
|
|
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
2016-03-29 02:24:22 +08:00
|
|
|
|
|
|
|
# Check prebuilt llvm/utils.
|
|
|
|
if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
|
|
|
|
AND EXISTS ${LLVM_TOOLS_BINARY_DIR}/count${CMAKE_EXECUTABLE_SUFFIX}
|
|
|
|
AND EXISTS ${LLVM_TOOLS_BINARY_DIR}/not${CMAKE_EXECUTABLE_SUFFIX})
|
|
|
|
set(LLVM_UTILS_PROVIDED ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
|
2016-10-19 01:07:30 +08:00
|
|
|
# Note: path not really used, except for checking if lit was found
|
2016-03-29 02:24:22 +08:00
|
|
|
set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
|
2017-11-18 06:21:23 +08:00
|
|
|
if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)
|
|
|
|
add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit utils/llvm-lit)
|
|
|
|
endif()
|
2016-03-29 02:24:22 +08:00
|
|
|
if(NOT LLVM_UTILS_PROVIDED)
|
|
|
|
add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/FileCheck utils/FileCheck)
|
|
|
|
add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/count utils/count)
|
|
|
|
add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/not utils/not)
|
|
|
|
set(LLVM_UTILS_PROVIDED ON)
|
|
|
|
set(CLANG_TEST_DEPS FileCheck count not)
|
|
|
|
endif()
|
|
|
|
set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest)
|
|
|
|
if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h
|
|
|
|
AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}
|
|
|
|
AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt)
|
|
|
|
add_subdirectory(${UNITTEST_DIR} utils/unittest)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
# Seek installed Lit.
|
2016-10-19 01:07:30 +08:00
|
|
|
find_program(LLVM_LIT
|
|
|
|
NAMES llvm-lit lit.py lit
|
|
|
|
PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit"
|
|
|
|
DOC "Path to lit.py")
|
2016-03-29 02:24:22 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(LLVM_LIT)
|
|
|
|
# Define the default arguments to use with 'lit', and an option for the user
|
|
|
|
# to override.
|
|
|
|
set(LIT_ARGS_DEFAULT "-sv")
|
|
|
|
if (MSVC OR XCODE)
|
|
|
|
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
|
|
|
|
endif()
|
|
|
|
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
|
|
|
|
|
|
|
|
# On Win32 hosts, provide an option to specify the path to the GnuWin32 tools.
|
|
|
|
if( WIN32 AND NOT CYGWIN )
|
|
|
|
set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(LLVM_INCLUDE_TESTS OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set( CLANG_BUILT_STANDALONE 1 )
|
|
|
|
set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}")
|
|
|
|
else()
|
|
|
|
set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}")
|
|
|
|
endif()
|
|
|
|
|
2016-07-10 05:58:40 +08:00
|
|
|
# Make sure that our source directory is on the current cmake module path so that
|
|
|
|
# we can include cmake files from this directory.
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
|
|
|
|
2018-11-29 22:57:14 +08:00
|
|
|
if(LLVM_ENABLE_LIBXML2)
|
|
|
|
# Don't look for libxml if we're using MSan, since uninstrumented third party
|
|
|
|
# code may call MSan interceptors like strlen, leading to false positives.
|
|
|
|
if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
|
|
|
|
set (LIBXML2_FOUND 0)
|
|
|
|
find_package(LibXml2 2.5.3 QUIET)
|
|
|
|
if (LIBXML2_FOUND)
|
|
|
|
set(CLANG_HAVE_LIBXML 1)
|
|
|
|
endif()
|
2017-09-02 11:53:42 +08:00
|
|
|
endif()
|
2016-03-29 02:24:22 +08:00
|
|
|
endif()
|
|
|
|
|
2016-08-24 04:07:07 +08:00
|
|
|
include(CheckIncludeFile)
|
|
|
|
check_include_file(sys/resource.h CLANG_HAVE_RLIMITS)
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
set(CLANG_RESOURCE_DIR "" CACHE STRING
|
|
|
|
"Relative directory from the Clang binary to its resource files.")
|
|
|
|
|
|
|
|
set(C_INCLUDE_DIRS "" CACHE STRING
|
|
|
|
"Colon separated list of directories clang will search for headers.")
|
|
|
|
|
|
|
|
set(GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." )
|
2020-03-20 06:20:49 +08:00
|
|
|
set(DEFAULT_SYSROOT "" CACHE STRING
|
2016-03-29 02:24:22 +08:00
|
|
|
"Default <path> to all compiler invocations for --sysroot=<path>." )
|
|
|
|
|
2016-06-04 01:26:16 +08:00
|
|
|
set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
|
|
|
|
|
2020-08-03 14:05:50 +08:00
|
|
|
set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL
|
2016-06-21 07:54:44 +08:00
|
|
|
"enable x86 relax relocations by default")
|
|
|
|
|
[Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation
With this patch, the clang tool will now call the -cc1 invocation directly inside the same process. Previously, the -cc1 invocation was creating, and waiting for, a new process.
This patch therefore reduces the number of created processes during a build, thus it reduces build times on platforms where process creation can be costly (Windows) and/or impacted by a antivirus.
It also makes debugging a bit easier, as there's no need to attach to the secondary -cc1 process anymore, breakpoints will be hit inside the same process.
Crashes or signaling inside the -cc1 invocation will have the same side-effect as before, and will be reported through the same means.
This behavior can be controlled at compile-time through the CLANG_SPAWN_CC1 cmake flag, which defaults to OFF. Setting it to ON will revert to the previous behavior, where any -cc1 invocation will create/fork a secondary process.
At run-time, it is also possible to tweak the CLANG_SPAWN_CC1 environment variable. Setting it and will override the compile-time setting. A value of 0 calls -cc1 inside the calling process; a value of 1 will create a secondary process, as before.
Differential Revision: https://reviews.llvm.org/D69825
2020-01-13 23:40:04 +08:00
|
|
|
set(CLANG_SPAWN_CC1 OFF CACHE BOOL
|
|
|
|
"Whether clang should use a new process for the CC1 invocation")
|
|
|
|
|
2018-03-07 05:26:28 +08:00
|
|
|
# TODO: verify the values against LangStandards.def?
|
|
|
|
set(CLANG_DEFAULT_STD_C "" CACHE STRING
|
|
|
|
"Default standard to use for C/ObjC code (IDENT from LangStandards.def, empty for platform default)")
|
|
|
|
set(CLANG_DEFAULT_STD_CXX "" CACHE STRING
|
|
|
|
"Default standard to use for C++/ObjC++ code (IDENT from LangStandards.def, empty for platform default)")
|
|
|
|
|
2016-12-15 00:46:50 +08:00
|
|
|
set(CLANG_DEFAULT_LINKER "" CACHE STRING
|
|
|
|
"Default linker to use (linker name or absolute path, empty for platform default)")
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
|
2016-07-27 16:15:54 +08:00
|
|
|
"Default C++ stdlib to use (\"libstdc++\" or \"libc++\", empty for platform default")
|
2016-03-29 02:24:22 +08:00
|
|
|
if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR
|
|
|
|
CLANG_DEFAULT_CXX_STDLIB STREQUAL "libstdc++" OR
|
|
|
|
CLANG_DEFAULT_CXX_STDLIB STREQUAL "libc++"))
|
2016-07-25 16:04:26 +08:00
|
|
|
message(WARNING "Resetting default C++ stdlib to use platform default")
|
2016-07-27 16:15:54 +08:00
|
|
|
set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
|
|
|
|
"Default C++ stdlib to use (\"libstdc++\" or \"libc++\", empty for platform default" FORCE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CLANG_DEFAULT_RTLIB "" CACHE STRING
|
|
|
|
"Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)")
|
|
|
|
if (NOT(CLANG_DEFAULT_RTLIB STREQUAL "" OR
|
|
|
|
CLANG_DEFAULT_RTLIB STREQUAL "libgcc" OR
|
|
|
|
CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt"))
|
|
|
|
message(WARNING "Resetting default rtlib to use platform default")
|
|
|
|
set(CLANG_DEFAULT_RTLIB "" CACHE STRING
|
|
|
|
"Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)" FORCE)
|
2016-03-29 02:24:22 +08:00
|
|
|
endif()
|
|
|
|
|
2019-03-20 04:01:59 +08:00
|
|
|
set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
|
|
|
|
"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty to match runtime library.)")
|
|
|
|
if (CLANG_DEFAULT_UNWINDLIB STREQUAL "")
|
|
|
|
if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc")
|
|
|
|
set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE)
|
|
|
|
elseif (CLANG_DEFAULT_RTLIBS STREQUAL "libunwind")
|
|
|
|
set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-03-26 00:38:48 +08:00
|
|
|
if (NOT(CLANG_DEFAULT_UNWINDLIB STREQUAL "" OR
|
|
|
|
CLANG_DEFAULT_UNWINDLIB STREQUAL "none" OR
|
2019-03-20 04:01:59 +08:00
|
|
|
CLANG_DEFAULT_UNWINDLIB STREQUAL "libgcc" OR
|
|
|
|
CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind"))
|
|
|
|
message(WARNING "Resetting default unwindlib to use platform default")
|
|
|
|
set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
|
|
|
|
"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty for none)" FORCE)
|
|
|
|
endif()
|
|
|
|
|
2017-11-11 09:15:41 +08:00
|
|
|
set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING
|
|
|
|
"Default objcopy executable to use.")
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
|
|
|
|
"Default OpenMP runtime used by -fopenmp.")
|
|
|
|
|
2017-12-08 04:27:31 +08:00
|
|
|
# OpenMP offloading requires at least sm_35 because we use shuffle instructions
|
|
|
|
# to generate efficient code for reductions and the atomicMax instruction on
|
|
|
|
# 64-bit integers in the implementation of conditional lastprivate.
|
2020-10-08 04:40:47 +08:00
|
|
|
set(CUDA_ARCH_FLAGS "sm_35")
|
|
|
|
|
|
|
|
# Try to find the highest Nvidia GPU architecture the system supports
|
|
|
|
if (NOT DEFINED CLANG_OPENMP_NVPTX_DEFAULT_ARCH)
|
|
|
|
find_package(CUDA QUIET)
|
|
|
|
if (CUDA_FOUND)
|
|
|
|
cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(CUDA_ARCH_FLAGS ${CLANG_OPENMP_NVPTX_DEFAULT_ARCH})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
string(REGEX MATCH "sm_([0-9]+)" CUDA_ARCH_MATCH ${CUDA_ARCH_FLAGS})
|
|
|
|
if (NOT DEFINED CUDA_ARCH_MATCH OR "${CMAKE_MATCH_1}" LESS 35)
|
2017-12-08 04:27:31 +08:00
|
|
|
set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
|
2017-10-17 21:37:36 +08:00
|
|
|
"Default architecture for OpenMP offloading to Nvidia GPUs." FORCE)
|
2020-10-08 04:40:47 +08:00
|
|
|
message(WARNING "Resetting default architecture for OpenMP offloading to Nvidia GPUs to sm_35")
|
|
|
|
else()
|
|
|
|
set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH ${CUDA_ARCH_MATCH} CACHE STRING
|
|
|
|
"Default architecture for OpenMP offloading to Nvidia GPUs.")
|
2017-10-17 21:37:36 +08:00
|
|
|
endif()
|
|
|
|
|
2020-03-31 02:11:35 +08:00
|
|
|
set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch")
|
2020-03-30 20:20:48 +08:00
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING
|
|
|
|
"Vendor-specific text for showing with version information.")
|
|
|
|
|
|
|
|
set(CLANG_REPOSITORY_STRING "" CACHE STRING
|
|
|
|
"Vendor-specific text for showing the repository the source is taken from.")
|
|
|
|
|
|
|
|
if(CLANG_REPOSITORY_STRING)
|
|
|
|
add_definitions(-DCLANG_REPOSITORY_STRING="${CLANG_REPOSITORY_STRING}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CLANG_VENDOR_UTI "org.llvm.clang" CACHE STRING
|
|
|
|
"Vendor-specific uti.")
|
|
|
|
|
2018-08-21 06:50:18 +08:00
|
|
|
set(CLANG_PYTHON_BINDINGS_VERSIONS "" CACHE STRING
|
|
|
|
"Python versions to install libclang python bindings for")
|
|
|
|
|
2019-07-04 06:45:55 +08:00
|
|
|
set(CLANG_LINK_CLANG_DYLIB ${LLVM_LINK_LLVM_DYLIB} CACHE BOOL
|
2019-07-12 05:42:55 +08:00
|
|
|
"Link tools against libclang-cpp.so")
|
2019-07-04 06:45:55 +08:00
|
|
|
|
|
|
|
if (NOT LLVM_LINK_LLVM_DYLIB AND CLANG_LINK_CLANG_DYLIB)
|
|
|
|
message(FATAL_ERROR "Cannot set CLANG_LINK_CLANG_DYLIB=ON when "
|
|
|
|
"LLVM_LINK_LLVM_DYLIB=OFF")
|
|
|
|
endif()
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
# The libdir suffix must exactly match whatever LLVM's configuration used.
|
|
|
|
set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}")
|
|
|
|
|
|
|
|
set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
|
|
|
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
|
2018-08-31 07:41:03 +08:00
|
|
|
message(FATAL_ERROR "In-source builds are not allowed. "
|
|
|
|
"Please create a directory and run cmake "
|
2016-03-29 02:24:22 +08:00
|
|
|
"from there, passing the path to this source directory as the last argument. "
|
|
|
|
"This process created the file `CMakeCache.txt' and the directory "
|
|
|
|
"`CMakeFiles'. Please delete them.")
|
|
|
|
endif()
|
|
|
|
|
2016-09-21 03:09:21 +08:00
|
|
|
# If CLANG_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
|
|
|
|
if(NOT DEFINED CLANG_VERSION_MAJOR)
|
|
|
|
set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
|
|
|
|
endif()
|
|
|
|
if(NOT DEFINED CLANG_VERSION_MINOR)
|
|
|
|
set(CLANG_VERSION_MINOR ${LLVM_VERSION_MINOR})
|
|
|
|
endif()
|
|
|
|
if(NOT DEFINED CLANG_VERSION_PATCHLEVEL)
|
|
|
|
set(CLANG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH})
|
|
|
|
endif()
|
Simplify Clang's version number configuration in CMake.
Currently, the Clang version is computed as follows:
1. LLVM defines major, minor, and patch versions, all statically set. Today,
these are 4, 0, and 0, respectively.
2. The static version numbers are combined into PACKAGE_VERSION along with a
suffix, so the result today looks like "4.0.0svn".
3. Clang extracts CLANG_VERSION from PACKAGE_VERSION using a regexp. The regexp
allows the patch level to omitted, and drops any non-digit trailing values.
Today, this result looks like "4.0.0".
4. CLANG_VERSION is then split further into CLANG_VERSION_MAJOR and
CLANG_VERSION_MINOR. Today, these resolve to 4 and 0, respectively.
5. If CLANG_VERSION matches a regexp with three version components, then
CLANG_VERSION_PATCHLEVEL is extracted and the CLANG_HAS_VERSION_PATCHLEVEL
variable is set to 1. Today, these values are 0 and 1, respectively.
6. The CLANG_VERSION_* variables (and CLANG_HAS_VERSION_PATCHLEVEL) are
configured into [llvm/tools/clang/]include/clang/Basic/Version.inc
verbatim by CMake.
7. In [llvm/tools/clang/]include/clang/Basic/Version.h, macros are defined
conditionally, based on CLANG_HAS_VERSION_PATCHLEVEL, to compute
CLANG_VERSION_STRING as either a two- or three-level version number. Today,
this value is "4.0.0", because despite the patchlevel being 0, it was
matched by regexp and is thus "HAS"ed by the preprocessor. This string is
then used wherever Clang's "version" is needed [*].
[*] Including, notably, by compiler-rt, for computing its installation path.
This change collapses steps 2-5 by defaulting Clang to use LLVM's (non-string)
version components for the Clang version (see [*] for why not PACKAGE_VERSION),
and collapses steps 6 and 7 by simply writing CLANG_VERSION_STRING into
Version.inc. The Clang version today always uses the patchlevel form, so the
collapsed Version.inc does not have logic for a version without a patch level.
Historically speaking, this technique began with the VER file in r82085 (which
survives in the form of the regexp in #3). The major, minor, and patchlevel
versions were introduced by r106863 (which remains in #4-6). The VER file itself
was deleted in favor of the LLVM version number in r106914. On the LLVM side,
the individual LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR, and PACKAGE_VERSION
weren't introduced for nearly two more years, until r150405.
llvm-svn: 281666
2016-09-16 06:12:26 +08:00
|
|
|
# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX.
|
|
|
|
set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}")
|
2016-03-29 02:24:22 +08:00
|
|
|
message(STATUS "Clang version: ${CLANG_VERSION}")
|
|
|
|
|
|
|
|
# Configure the Version.inc file.
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include/clang/Basic/Version.inc.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/include/clang/Basic/Version.inc)
|
|
|
|
|
|
|
|
# Add appropriate flags for GCC
|
|
|
|
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual")
|
|
|
|
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
# Enable -pedantic for Clang even if it's not enabled for LLVM.
|
|
|
|
if (NOT LLVM_ENABLE_PEDANTIC)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
check_cxx_compiler_flag("-Werror -Wnested-anon-types" CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
|
|
|
|
if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG )
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
|
|
|
|
endif()
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
# Determine HOST_LINK_VERSION on Darwin.
|
|
|
|
set(HOST_LINK_VERSION)
|
|
|
|
if (APPLE)
|
|
|
|
set(LD_V_OUTPUT)
|
|
|
|
execute_process(
|
|
|
|
COMMAND sh -c "${CMAKE_LINKER} -v 2>&1 | head -1"
|
|
|
|
RESULT_VARIABLE HAD_ERROR
|
|
|
|
OUTPUT_VARIABLE LD_V_OUTPUT
|
|
|
|
)
|
2020-08-06 05:03:12 +08:00
|
|
|
if (HAD_ERROR)
|
2016-03-29 02:24:22 +08:00
|
|
|
message(FATAL_ERROR "${CMAKE_LINKER} failed with status ${HAD_ERROR}")
|
|
|
|
endif()
|
2020-08-06 05:03:12 +08:00
|
|
|
if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
|
|
|
|
string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
|
|
|
|
elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*")
|
|
|
|
string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
|
|
|
|
endif()
|
|
|
|
message(STATUS "Host linker version: ${HOST_LINK_VERSION}")
|
2016-03-29 02:24:22 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
include(CMakeParseArguments)
|
2016-07-10 05:58:40 +08:00
|
|
|
include(AddClang)
|
2016-03-29 02:24:22 +08:00
|
|
|
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
|
|
|
|
include_directories(BEFORE
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/include
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
|
|
)
|
|
|
|
|
|
|
|
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
|
|
install(DIRECTORY include/clang include/clang-c
|
|
|
|
DESTINATION include
|
2019-03-12 02:53:57 +08:00
|
|
|
COMPONENT clang-headers
|
2016-03-29 02:24:22 +08:00
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.def"
|
|
|
|
PATTERN "*.h"
|
|
|
|
PATTERN "config.h" EXCLUDE
|
|
|
|
)
|
|
|
|
|
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang
|
|
|
|
DESTINATION include
|
2019-03-12 02:53:57 +08:00
|
|
|
COMPONENT clang-headers
|
2016-03-29 02:24:22 +08:00
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "CMakeFiles" EXCLUDE
|
|
|
|
PATTERN "*.inc"
|
|
|
|
PATTERN "*.h"
|
|
|
|
)
|
2017-05-24 02:39:08 +08:00
|
|
|
|
2019-03-12 02:53:57 +08:00
|
|
|
# Installing the headers needs to depend on generating any public
|
|
|
|
# tablegen'd headers.
|
|
|
|
add_custom_target(clang-headers DEPENDS clang-tablegen-targets)
|
|
|
|
set_target_properties(clang-headers PROPERTIES FOLDER "Misc")
|
|
|
|
if(NOT LLVM_ENABLE_IDE)
|
|
|
|
add_llvm_install_targets(install-clang-headers
|
|
|
|
DEPENDS clang-headers
|
|
|
|
COMPONENT clang-headers)
|
|
|
|
endif()
|
|
|
|
|
2019-10-04 13:43:20 +08:00
|
|
|
add_custom_target(bash-autocomplete DEPENDS utils/bash-autocomplete.sh)
|
2017-05-24 02:39:08 +08:00
|
|
|
install(PROGRAMS utils/bash-autocomplete.sh
|
2019-10-04 13:43:20 +08:00
|
|
|
DESTINATION share/clang
|
|
|
|
COMPONENT bash-autocomplete)
|
|
|
|
if(NOT LLVM_ENABLE_IDE)
|
|
|
|
add_llvm_install_targets(install-bash-autocomplete
|
|
|
|
DEPENDS bash-autocomplete
|
|
|
|
COMPONENT bash-autocomplete)
|
|
|
|
endif()
|
2016-03-29 02:24:22 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions( -D_GNU_SOURCE )
|
|
|
|
|
2016-07-10 09:44:00 +08:00
|
|
|
option(CLANG_BUILD_TOOLS
|
|
|
|
"Build the Clang tools. If OFF, just generate build targets." ON)
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
option(CLANG_ENABLE_ARCMT "Build ARCMT." ON)
|
2020-09-04 07:37:29 +08:00
|
|
|
option(CLANG_ENABLE_STATIC_ANALYZER
|
|
|
|
"Include static analyzer in clang binary." ON)
|
2016-03-29 02:24:22 +08:00
|
|
|
|
[analyzer] Improved cmake configuration for Z3
Summary:
Enhanced support for Z3 in the cmake configuration of clang; now it is possible to specify any arbitrary Z3 install prefix (CLANG_ANALYZER_Z3_PREFIX) to cmake with lib (or bin) and include folders. Before the patch only in cmake default locations
were searched (https://cmake.org/cmake/help/v3.4/command/find_path.html).
Specifying any CLANG_ANALYZER_Z3_PREFIX will force also CLANG_ANALYZER_BUILD_Z3 to ON.
Removed also Z3 4.5 version requirement since it was not checked, and now Clang works with Z3 4.7
Reviewers: NoQ, george.karpenkov, mikhail.ramalho
Reviewed By: george.karpenkov
Subscribers: rnkovacs, NoQ, esteffin, george.karpenkov, delcypher, ddcc, mgorny, xazax.hun, szepet, a.sidorin, Szelethus
Tags: #clang
Differential Revision: https://reviews.llvm.org/D50818
llvm-svn: 344464
2018-10-14 03:45:48 +08:00
|
|
|
option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
|
|
|
|
|
2021-02-04 16:49:59 +08:00
|
|
|
option(CLANG_ROUND_TRIP_CC1_ARGS "Round-trip command line arguments in -cc1." OFF)
|
|
|
|
|
2019-03-26 01:47:45 +08:00
|
|
|
if(NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT)
|
[analyzer] Improved cmake configuration for Z3
Summary:
Enhanced support for Z3 in the cmake configuration of clang; now it is possible to specify any arbitrary Z3 install prefix (CLANG_ANALYZER_Z3_PREFIX) to cmake with lib (or bin) and include folders. Before the patch only in cmake default locations
were searched (https://cmake.org/cmake/help/v3.4/command/find_path.html).
Specifying any CLANG_ANALYZER_Z3_PREFIX will force also CLANG_ANALYZER_BUILD_Z3 to ON.
Removed also Z3 4.5 version requirement since it was not checked, and now Clang works with Z3 4.7
Reviewers: NoQ, george.karpenkov, mikhail.ramalho
Reviewed By: george.karpenkov
Subscribers: rnkovacs, NoQ, esteffin, george.karpenkov, delcypher, ddcc, mgorny, xazax.hun, szepet, a.sidorin, Szelethus
Tags: #clang
Differential Revision: https://reviews.llvm.org/D50818
llvm-svn: 344464
2018-10-14 03:45:48 +08:00
|
|
|
message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
|
2016-03-29 02:24:22 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CLANG_ENABLE_ARCMT)
|
2017-07-18 16:55:03 +08:00
|
|
|
set(CLANG_ENABLE_OBJC_REWRITER ON)
|
2016-03-29 02:24:22 +08:00
|
|
|
endif()
|
|
|
|
|
2021-02-04 16:49:59 +08:00
|
|
|
if (CLANG_ROUND_TRIP_CC1_ARGS)
|
|
|
|
add_definitions(-DCLANG_ROUND_TRIP_CC1_ARGS=ON)
|
|
|
|
endif()
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
# Clang version information
|
|
|
|
set(CLANG_EXECUTABLE_VERSION
|
Rename clang link from clang-X.Y to clang-X
Summary:
As we are only doing X.0.Z releases (not using the minor version), there is no need to keep -X.Y in the version.
So, instead, I propose the following:
Instead of having clang-7.0 in bin/, we will have clang-7
Since also matches was gcc is doing.
Reviewers: tstellar, dlj, dim, hans
Reviewed By: dim, hans
Subscribers: dim, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D41808
llvm-svn: 328769
2018-03-29 18:05:46 +08:00
|
|
|
"${CLANG_VERSION_MAJOR}" CACHE STRING
|
|
|
|
"Major version number that will be appended to the clang executable name")
|
2016-03-29 02:24:22 +08:00
|
|
|
set(LIBCLANG_LIBRARY_VERSION
|
Rename clang link from clang-X.Y to clang-X
Summary:
As we are only doing X.0.Z releases (not using the minor version), there is no need to keep -X.Y in the version.
So, instead, I propose the following:
Instead of having clang-7.0 in bin/, we will have clang-7
Since also matches was gcc is doing.
Reviewers: tstellar, dlj, dim, hans
Reviewed By: dim, hans
Subscribers: dim, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D41808
llvm-svn: 328769
2018-03-29 18:05:46 +08:00
|
|
|
"${CLANG_VERSION_MAJOR}" CACHE STRING
|
|
|
|
"Major version number that will be appended to the libclang library")
|
2016-03-29 02:24:22 +08:00
|
|
|
mark_as_advanced(CLANG_EXECUTABLE_VERSION LIBCLANG_LIBRARY_VERSION)
|
|
|
|
|
|
|
|
option(CLANG_INCLUDE_TESTS
|
|
|
|
"Generate build targets for the Clang unit tests."
|
|
|
|
${LLVM_INCLUDE_TESTS})
|
|
|
|
|
|
|
|
add_subdirectory(utils/TableGen)
|
|
|
|
|
|
|
|
add_subdirectory(include)
|
|
|
|
|
|
|
|
# All targets below may depend on all tablegen'd files.
|
|
|
|
get_property(CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS)
|
Fix missing build dependency on omp_gen.
Summary:
`include/llvm/Frontend/OpenMP/CMakeLists.txt` creates a new target
called `omp_gen` which builds the generated include file `OMP.h.inc`.
This target must therefore be a dependency of every compilation step
whose transitive #include dependencies contain `OMP.h.inc`, or else
it's possible for builds to fail if Ninja (or make or whatever)
schedules that compilation step before building `OMP.h.inc` at all.
A few of those dependencies are currently missing, which leads to
intermittent build failures, depending on the order that Ninja (or
whatever) happens to schedule its commands. As far as I can see,
compiles in `clang/lib/CodeGen`, `clang/lib/Frontend`, and
`clang/examples` all depend transitivily on `OMP.h.inc` (usually via
`clang/AST/AST.h`), but don't have the formal dependency in the ninja
graph.
Adding `omp_gen` to the dependencies of `clang-tablegen-targets` seems
to be the way to get the missing dependency into the `clang/examples`
subdirectory. This also fixes the other two clang subdirectories, as
far as I can see.
Reviewers: clementval, thakis, chandlerc, jdoerfert
Reviewed By: clementval
Subscribers: cfe-commits, jdenny, mgorny, sstefan1, llvm-commits
Tags: #llvm, #clang
Differential Revision: https://reviews.llvm.org/D82659
2020-07-02 16:16:13 +08:00
|
|
|
add_custom_target(clang-tablegen-targets
|
|
|
|
DEPENDS
|
|
|
|
omp_gen
|
|
|
|
${CLANG_TABLEGEN_TARGETS})
|
2017-11-05 04:06:49 +08:00
|
|
|
set_target_properties(clang-tablegen-targets PROPERTIES FOLDER "Misc")
|
2017-07-28 23:33:47 +08:00
|
|
|
list(APPEND LLVM_COMMON_DEPENDS clang-tablegen-targets)
|
2016-03-29 02:24:22 +08:00
|
|
|
|
2017-07-23 13:09:44 +08:00
|
|
|
# Force target to be built as soon as possible. Clang modules builds depend
|
|
|
|
# header-wise on it as they ship all headers from the umbrella folders. Building
|
|
|
|
# an entire module might include header, which depends on intrinsics_gen.
|
2020-07-18 07:43:05 +08:00
|
|
|
if(LLVM_ENABLE_MODULES)
|
2017-07-23 13:09:44 +08:00
|
|
|
list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
|
|
|
|
endif()
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
add_subdirectory(lib)
|
|
|
|
add_subdirectory(tools)
|
|
|
|
add_subdirectory(runtime)
|
|
|
|
|
|
|
|
option(CLANG_BUILD_EXAMPLES "Build CLANG example programs by default." OFF)
|
|
|
|
add_subdirectory(examples)
|
|
|
|
|
2016-12-31 13:25:52 +08:00
|
|
|
if(APPLE)
|
|
|
|
# this line is needed as a cleanup to ensure that any CMakeCaches with the old
|
|
|
|
# default value get updated to the new default.
|
|
|
|
if(CLANG_ORDER_FILE STREQUAL "")
|
|
|
|
unset(CLANG_ORDER_FILE CACHE)
|
|
|
|
unset(CLANG_ORDER_FILE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH
|
|
|
|
"Order file to use when compiling clang in order to improve startup time (Darwin Only - requires ld64).")
|
|
|
|
|
|
|
|
if(NOT EXISTS ${CLANG_ORDER_FILE})
|
|
|
|
string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START)
|
|
|
|
if(PATH_START EQUAL 0)
|
|
|
|
file(WRITE ${CLANG_ORDER_FILE} "\n")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not exist.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
if( CLANG_INCLUDE_TESTS )
|
|
|
|
if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h)
|
|
|
|
add_subdirectory(unittests)
|
|
|
|
list(APPEND CLANG_TEST_DEPS ClangUnitTests)
|
|
|
|
list(APPEND CLANG_TEST_PARAMS
|
|
|
|
clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/test/Unit/lit.site.cfg
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
add_subdirectory(test)
|
2018-10-12 00:32:54 +08:00
|
|
|
add_subdirectory(bindings/python/tests)
|
2016-03-29 02:24:22 +08:00
|
|
|
|
|
|
|
if(CLANG_BUILT_STANDALONE)
|
|
|
|
# Add a global check rule now that all subdirectories have been traversed
|
|
|
|
# and we know the total set of lit testsuites.
|
|
|
|
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)
|
2018-10-12 00:32:54 +08:00
|
|
|
get_property(LLVM_ADDITIONAL_TEST_TARGETS
|
|
|
|
GLOBAL PROPERTY LLVM_ADDITIONAL_TEST_TARGETS)
|
2016-03-29 02:24:22 +08:00
|
|
|
add_lit_target(check-all
|
|
|
|
"Running all regression tests"
|
|
|
|
${LLVM_LIT_TESTSUITES}
|
|
|
|
PARAMS ${LLVM_LIT_PARAMS}
|
2018-10-12 00:32:54 +08:00
|
|
|
DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS}
|
2016-03-29 02:24:22 +08:00
|
|
|
ARGS ${LLVM_LIT_EXTRA_ARGS}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
add_subdirectory(utils/perf-training)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(CLANG_INCLUDE_DOCS "Generate build targets for the Clang docs."
|
|
|
|
${LLVM_INCLUDE_DOCS})
|
|
|
|
if( CLANG_INCLUDE_DOCS )
|
|
|
|
add_subdirectory(docs)
|
|
|
|
endif()
|
|
|
|
|
2019-02-15 23:59:04 +08:00
|
|
|
# Custom target to install all clang libraries.
|
|
|
|
add_custom_target(clang-libraries)
|
|
|
|
set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
|
|
|
|
|
2019-02-21 07:08:43 +08:00
|
|
|
if(NOT LLVM_ENABLE_IDE)
|
2019-02-15 23:59:04 +08:00
|
|
|
add_llvm_install_targets(install-clang-libraries
|
|
|
|
DEPENDS clang-libraries
|
|
|
|
COMPONENT clang-libraries)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_LIBS)
|
|
|
|
if(CLANG_LIBS)
|
|
|
|
list(REMOVE_DUPLICATES CLANG_LIBS)
|
|
|
|
foreach(lib ${CLANG_LIBS})
|
|
|
|
add_dependencies(clang-libraries ${lib})
|
2019-02-21 07:08:43 +08:00
|
|
|
if(NOT LLVM_ENABLE_IDE)
|
2019-02-15 23:59:04 +08:00
|
|
|
add_dependencies(install-clang-libraries install-${lib})
|
2020-03-21 09:42:09 +08:00
|
|
|
add_dependencies(install-clang-libraries-stripped install-${lib}-stripped)
|
2019-02-15 23:59:04 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2016-06-30 04:22:44 +08:00
|
|
|
add_subdirectory(cmake/modules)
|
2016-03-29 02:24:22 +08:00
|
|
|
|
2016-07-26 02:54:30 +08:00
|
|
|
if(CLANG_STAGE)
|
|
|
|
message(STATUS "Setting current clang stage to: ${CLANG_STAGE}")
|
|
|
|
endif()
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
if (CLANG_ENABLE_BOOTSTRAP)
|
|
|
|
include(ExternalProject)
|
|
|
|
|
2016-10-20 05:18:48 +08:00
|
|
|
add_custom_target(clang-bootstrap-deps DEPENDS clang)
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
if(NOT CLANG_STAGE)
|
|
|
|
set(CLANG_STAGE stage1)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
string(REGEX MATCH "stage([0-9]*)" MATCHED_STAGE "${CLANG_STAGE}")
|
|
|
|
if(MATCHED_STAGE)
|
|
|
|
if(NOT LLVM_BUILD_INSTRUMENTED)
|
|
|
|
math(EXPR STAGE_NUM "${CMAKE_MATCH_1} + 1")
|
|
|
|
set(NEXT_CLANG_STAGE stage${STAGE_NUM})
|
|
|
|
else()
|
|
|
|
set(NEXT_CLANG_STAGE stage${CMAKE_MATCH_1})
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(NEXT_CLANG_STAGE bootstrap)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED)
|
|
|
|
set(NEXT_CLANG_STAGE ${NEXT_CLANG_STAGE}-instrumented)
|
|
|
|
endif()
|
|
|
|
message(STATUS "Setting next clang stage to: ${NEXT_CLANG_STAGE}")
|
2017-11-11 09:15:41 +08:00
|
|
|
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
|
|
|
|
set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
|
|
|
|
|
2017-01-18 13:41:17 +08:00
|
|
|
if(BOOTSTRAP_LLVM_ENABLE_LLD)
|
|
|
|
add_dependencies(clang-bootstrap-deps lld)
|
|
|
|
endif()
|
|
|
|
|
2016-11-17 07:59:06 +08:00
|
|
|
# If the next stage is LTO we need to depend on LTO and possibly lld or LLVMgold
|
2016-10-20 05:18:48 +08:00
|
|
|
if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT LLVM_BUILD_INSTRUMENTED)
|
2016-03-29 02:24:22 +08:00
|
|
|
if(APPLE)
|
2016-11-17 07:59:06 +08:00
|
|
|
add_dependencies(clang-bootstrap-deps LTO)
|
2016-04-28 02:52:48 +08:00
|
|
|
# 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.
|
2016-07-26 07:48:14 +08:00
|
|
|
# However if System Integrity Protection is enabled the DYLD variables
|
|
|
|
# will be scrubbed from the environment of any base system commands. This
|
|
|
|
# includes /bin/sh, which ninja uses when executing build commands. To
|
|
|
|
# work around the envar being filtered away we pass it in as a CMake
|
|
|
|
# variable, and have LLVM's CMake append the envar to the archiver calls.
|
|
|
|
set(LTO_LIBRARY -DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib
|
|
|
|
-DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR})
|
2016-03-29 02:24:22 +08:00
|
|
|
elseif(NOT WIN32)
|
2016-11-17 07:59:06 +08:00
|
|
|
add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib)
|
2017-01-18 13:41:17 +08:00
|
|
|
if(NOT BOOTSTRAP_LLVM_ENABLE_LLD AND LLVM_BINUTILS_INCDIR)
|
2016-11-17 07:59:06 +08:00
|
|
|
add_dependencies(clang-bootstrap-deps LLVMgold)
|
|
|
|
endif()
|
2018-11-16 12:46:48 +08:00
|
|
|
set(${CLANG_STAGE}_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
|
|
|
|
set(${CLANG_STAGE}_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
|
2016-03-29 02:24:22 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-06-12 04:59:31 +08:00
|
|
|
if(CLANG_BOOTSTRAP_EXTRA_DEPS)
|
|
|
|
add_dependencies(clang-bootstrap-deps ${CLANG_BOOTSTRAP_EXTRA_DEPS})
|
|
|
|
endif()
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
add_custom_target(${NEXT_CLANG_STAGE}-clear
|
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-cleared
|
|
|
|
)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-cleared
|
2016-10-20 05:18:48 +08:00
|
|
|
DEPENDS clang-bootstrap-deps
|
2016-03-29 02:24:22 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${STAMP_DIR}
|
|
|
|
COMMENT "Clobberring ${NEXT_CLANG_STAGE} build and stamp directories"
|
|
|
|
)
|
|
|
|
|
|
|
|
if(CMAKE_VERBOSE_MAKEFILE)
|
|
|
|
set(verbose -DCMAKE_VERBOSE_MAKEFILE=On)
|
|
|
|
endif()
|
|
|
|
|
2016-07-26 02:54:30 +08:00
|
|
|
set(_BOOTSTRAP_DEFAULT_PASSTHROUGH
|
2016-03-29 02:24:22 +08:00
|
|
|
PACKAGE_VERSION
|
2016-10-18 08:50:20 +08:00
|
|
|
PACKAGE_VENDOR
|
2016-03-29 02:24:22 +08:00
|
|
|
LLVM_VERSION_MAJOR
|
|
|
|
LLVM_VERSION_MINOR
|
|
|
|
LLVM_VERSION_PATCH
|
2016-09-22 04:43:43 +08:00
|
|
|
CLANG_VERSION_MAJOR
|
|
|
|
CLANG_VERSION_MINOR
|
|
|
|
CLANG_VERSION_PATCHLEVEL
|
2020-05-29 15:13:08 +08:00
|
|
|
CLANG_VENDOR
|
2016-03-29 02:24:22 +08:00
|
|
|
LLVM_VERSION_SUFFIX
|
|
|
|
LLVM_BINUTILS_INCDIR
|
|
|
|
CLANG_REPOSITORY_STRING
|
2019-03-07 04:36:00 +08:00
|
|
|
CMAKE_C_COMPILER_LAUNCHER
|
|
|
|
CMAKE_CXX_COMPILER_LAUNCHER
|
2016-10-18 08:50:20 +08:00
|
|
|
CMAKE_MAKE_PROGRAM
|
2017-11-29 08:34:46 +08:00
|
|
|
CMAKE_OSX_ARCHITECTURES
|
|
|
|
LLVM_ENABLE_PROJECTS
|
|
|
|
LLVM_ENABLE_RUNTIMES)
|
2016-03-29 02:24:22 +08:00
|
|
|
|
2018-06-29 02:35:25 +08:00
|
|
|
# We don't need to depend on compiler-rt/libcxx if we're building instrumented
|
2016-10-20 05:18:48 +08:00
|
|
|
# because the next stage will use the same compiler used to build this stage.
|
2018-06-29 02:35:25 +08:00
|
|
|
if(NOT LLVM_BUILD_INSTRUMENTED)
|
|
|
|
if(TARGET compiler-rt)
|
|
|
|
add_dependencies(clang-bootstrap-deps compiler-rt)
|
|
|
|
endif()
|
|
|
|
if(TARGET cxx-headers)
|
|
|
|
add_dependencies(clang-bootstrap-deps cxx-headers)
|
|
|
|
endif()
|
2016-03-29 02:24:22 +08:00
|
|
|
endif()
|
|
|
|
|
2017-05-11 21:19:24 +08:00
|
|
|
set(C_COMPILER "clang")
|
|
|
|
set(CXX_COMPILER "clang++")
|
|
|
|
if(WIN32)
|
|
|
|
set(C_COMPILER "clang-cl.exe")
|
|
|
|
set(CXX_COMPILER "clang-cl.exe")
|
|
|
|
endif()
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
set(COMPILER_OPTIONS
|
2017-05-11 21:19:24 +08:00
|
|
|
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${CXX_COMPILER}
|
|
|
|
-DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${C_COMPILER}
|
2018-01-20 02:31:12 +08:00
|
|
|
-DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${C_COMPILER}
|
|
|
|
-DCMAKE_ASM_COMPILER_ID=Clang)
|
2016-03-29 02:24:22 +08:00
|
|
|
|
2020-05-29 19:14:51 +08:00
|
|
|
# cmake requires CMAKE_LINKER to be specified if the compiler is MSVC-like,
|
|
|
|
# otherwise it defaults the linker to be link.exe.
|
|
|
|
if(BOOTSTRAP_LLVM_ENABLE_LLD)
|
|
|
|
if((WIN32 AND NOT BOOTSTRAP_CMAKE_SYSTEM_NAME) OR BOOTSTRAP_CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
set(${CLANG_STAGE}_LINKER -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/lld-link${CMAKE_EXECUTABLE_SUFFIX})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-11-16 12:46:48 +08:00
|
|
|
if(BOOTSTRAP_CMAKE_SYSTEM_NAME)
|
|
|
|
set(${CLANG_STAGE}_CONFIG -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config)
|
|
|
|
set(${CLANG_STAGE}_TABLEGEN
|
|
|
|
-DLLVM_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-tblgen
|
|
|
|
-DCLANG_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-tblgen)
|
|
|
|
if(BOOTSTRAP_CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
if(BOOTSTRAP_LLVM_ENABLE_LLD)
|
|
|
|
set(${CLANG_STAGE}_LINKER -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/ld.lld)
|
|
|
|
endif()
|
|
|
|
if(NOT BOOTSTRAP_LLVM_ENABLE_LTO)
|
|
|
|
add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib)
|
|
|
|
set(${CLANG_STAGE}_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
|
|
|
|
set(${CLANG_STAGE}_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
|
|
|
|
endif()
|
|
|
|
add_dependencies(clang-bootstrap-deps llvm-objcopy llvm-strip)
|
|
|
|
set(${CLANG_STAGE}_OBJCOPY -DCMAKE_OBJCOPY=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-objcopy)
|
|
|
|
set(${CLANG_STAGE}_STRIP -DCMAKE_STRIP=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-strip)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-03-29 02:24:22 +08:00
|
|
|
if(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED)
|
2016-10-20 05:18:48 +08:00
|
|
|
add_dependencies(clang-bootstrap-deps llvm-profdata)
|
2016-03-29 02:24:22 +08:00
|
|
|
set(PGO_OPT -DLLVM_PROFDATA=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-profdata)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(LLVM_BUILD_INSTRUMENTED)
|
2016-10-20 05:18:48 +08:00
|
|
|
add_dependencies(clang-bootstrap-deps generate-profdata)
|
2016-03-29 02:24:22 +08:00
|
|
|
set(PGO_OPT -DLLVM_PROFDATA_FILE=${CMAKE_CURRENT_BINARY_DIR}/utils/perf-training/clang.profdata)
|
2016-08-17 06:16:29 +08:00
|
|
|
# Use the current tools for LTO instead of the instrumented ones
|
|
|
|
list(APPEND _BOOTSTRAP_DEFAULT_PASSTHROUGH
|
|
|
|
CMAKE_CXX_COMPILER
|
|
|
|
CMAKE_C_COMPILER
|
|
|
|
CMAKE_ASM_COMPILER
|
|
|
|
CMAKE_AR
|
|
|
|
CMAKE_RANLIB
|
|
|
|
DARWIN_LTO_LIBRARY
|
|
|
|
DYLD_LIBRARY_PATH)
|
|
|
|
|
|
|
|
set(COMPILER_OPTIONS)
|
|
|
|
set(LTO_LIBRARY)
|
|
|
|
set(LTO_AR)
|
|
|
|
set(LTO_RANLIB)
|
2016-03-29 02:24:22 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Find all variables that start with BOOTSTRAP_ and populate a variable with
|
|
|
|
# them.
|
|
|
|
get_cmake_property(variableNames VARIABLES)
|
|
|
|
foreach(variableName ${variableNames})
|
|
|
|
if(variableName MATCHES "^BOOTSTRAP_")
|
|
|
|
string(SUBSTRING ${variableName} 10 -1 varName)
|
2017-12-05 08:15:20 +08:00
|
|
|
string(REPLACE ";" "|" value "${${variableName}}")
|
2016-03-29 02:24:22 +08:00
|
|
|
list(APPEND PASSTHROUGH_VARIABLES
|
|
|
|
-D${varName}=${value})
|
|
|
|
endif()
|
|
|
|
if(${variableName} AND variableName MATCHES "LLVM_EXTERNAL_.*_SOURCE_DIR")
|
|
|
|
list(APPEND PASSTHROUGH_VARIABLES
|
|
|
|
-D${variableName}=${${variableName}})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# Populate the passthrough variables
|
2016-07-26 02:54:30 +08:00
|
|
|
foreach(variableName ${CLANG_BOOTSTRAP_PASSTHROUGH} ${_BOOTSTRAP_DEFAULT_PASSTHROUGH})
|
2016-09-22 07:24:15 +08:00
|
|
|
if(DEFINED ${variableName})
|
2016-09-22 08:18:12 +08:00
|
|
|
if("${${variableName}}" STREQUAL "")
|
|
|
|
set(value "")
|
|
|
|
else()
|
2017-12-05 08:15:20 +08:00
|
|
|
string(REPLACE ";" "|" value "${${variableName}}")
|
2016-09-22 08:18:12 +08:00
|
|
|
endif()
|
2016-03-29 02:24:22 +08:00
|
|
|
list(APPEND PASSTHROUGH_VARIABLES
|
|
|
|
-D${variableName}=${value})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
ExternalProject_Add(${NEXT_CLANG_STAGE}
|
2016-10-20 05:18:48 +08:00
|
|
|
DEPENDS clang-bootstrap-deps
|
2016-03-29 02:24:22 +08:00
|
|
|
PREFIX ${NEXT_CLANG_STAGE}
|
|
|
|
SOURCE_DIR ${CMAKE_SOURCE_DIR}
|
|
|
|
STAMP_DIR ${STAMP_DIR}
|
|
|
|
BINARY_DIR ${BINARY_DIR}
|
2016-06-10 06:38:42 +08:00
|
|
|
EXCLUDE_FROM_ALL 1
|
2016-03-29 02:24:22 +08:00
|
|
|
CMAKE_ARGS
|
|
|
|
# We shouldn't need to set this here, but INSTALL_DIR doesn't
|
|
|
|
# seem to work, so instead I'm passing this through
|
|
|
|
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
|
|
|
|
${PASSTHROUGH_VARIABLES}
|
2019-12-14 11:04:36 +08:00
|
|
|
${CLANG_BOOTSTRAP_CMAKE_ARGS}
|
2016-03-29 02:24:22 +08:00
|
|
|
-DCLANG_STAGE=${NEXT_CLANG_STAGE}
|
|
|
|
${COMPILER_OPTIONS}
|
2018-11-16 12:46:48 +08:00
|
|
|
${${CLANG_STAGE}_CONFIG}
|
|
|
|
${${CLANG_STAGE}_TABLEGEN}
|
|
|
|
${LTO_LIBRARY} ${verbose} ${PGO_OPT}
|
|
|
|
${${CLANG_STAGE}_LINKER}
|
|
|
|
${${CLANG_STAGE}_AR}
|
|
|
|
${${CLANG_STAGE}_RANLIB}
|
|
|
|
${${CLANG_STAGE}_OBJCOPY}
|
|
|
|
${${CLANG_STAGE}_STRIP}
|
2016-03-29 02:24:22 +08:00
|
|
|
INSTALL_COMMAND ""
|
|
|
|
STEP_TARGETS configure build
|
2016-06-10 06:38:42 +08:00
|
|
|
USES_TERMINAL_CONFIGURE 1
|
|
|
|
USES_TERMINAL_BUILD 1
|
|
|
|
USES_TERMINAL_INSTALL 1
|
2017-12-05 08:15:20 +08:00
|
|
|
LIST_SEPARATOR |
|
2016-03-29 02:24:22 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# 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
|
2016-07-26 07:48:14 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target install
|
2016-03-29 02:24:22 +08:00
|
|
|
COMMENT "Performing install step for '${NEXT_CLANG_STAGE}'"
|
|
|
|
DEPENDEES build
|
2016-06-10 06:38:42 +08:00
|
|
|
USES_TERMINAL 1
|
2016-03-29 02:24:22 +08:00
|
|
|
)
|
|
|
|
ExternalProject_Add_StepTargets(${NEXT_CLANG_STAGE} really-install)
|
|
|
|
add_custom_target(${NEXT_CLANG_STAGE}-install DEPENDS ${NEXT_CLANG_STAGE}-really-install)
|
|
|
|
|
|
|
|
if(NOT CLANG_BOOTSTRAP_TARGETS)
|
|
|
|
set(CLANG_BOOTSTRAP_TARGETS check-llvm check-clang check-all)
|
|
|
|
endif()
|
|
|
|
foreach(target ${CLANG_BOOTSTRAP_TARGETS})
|
|
|
|
# exclude from main target
|
|
|
|
set_target_properties(${NEXT_CLANG_STAGE} PROPERTIES _EP_${target}_EXCLUDE_FROM_MAIN On)
|
|
|
|
|
|
|
|
ExternalProject_Add_Step(${NEXT_CLANG_STAGE} ${target}
|
2016-07-26 07:48:14 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target ${target}
|
2016-03-29 02:24:22 +08:00
|
|
|
COMMENT "Performing ${target} for '${NEXT_CLANG_STAGE}'"
|
|
|
|
DEPENDEES configure
|
2016-06-10 06:38:42 +08:00
|
|
|
USES_TERMINAL 1
|
2016-03-29 02:24:22 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
if(target MATCHES "^stage[0-9]*")
|
|
|
|
add_custom_target(${target} DEPENDS ${NEXT_CLANG_STAGE}-${target})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
ExternalProject_Add_StepTargets(${NEXT_CLANG_STAGE} ${target})
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
|
|
|
|
add_subdirectory(utils/ClangVisualizers)
|
|
|
|
endif()
|
2018-06-22 05:45:24 +08:00
|
|
|
add_subdirectory(utils/hmaptool)
|
2017-04-05 03:52:25 +08:00
|
|
|
|
2019-10-08 02:14:56 +08:00
|
|
|
if(CLANG_BUILT_STANDALONE)
|
|
|
|
llvm_distribution_add_targets()
|
2020-02-16 16:31:16 +08:00
|
|
|
process_llvm_pass_plugins()
|
2019-10-08 02:14:56 +08:00
|
|
|
endif()
|
|
|
|
|
2017-04-05 03:52:25 +08:00
|
|
|
configure_file(
|
|
|
|
${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
|
|
|
|
${CLANG_BINARY_DIR}/include/clang/Config/config.h)
|