2012-06-21 09:30:21 +08:00
|
|
|
set( LLVM_LINK_COMPONENTS
|
|
|
|
${LLVM_TARGETS_TO_BUILD}
|
2013-12-10 20:40:37 +08:00
|
|
|
Analysis
|
2014-07-01 10:42:02 +08:00
|
|
|
CodeGen
|
2013-12-10 20:40:37 +08:00
|
|
|
Core
|
|
|
|
IPO
|
2018-04-24 16:40:44 +08:00
|
|
|
AggressiveInstCombine
|
2013-12-10 20:40:37 +08:00
|
|
|
InstCombine
|
|
|
|
Instrumentation
|
|
|
|
MC
|
|
|
|
MCParser
|
|
|
|
ObjCARCOpts
|
|
|
|
Option
|
|
|
|
ScalarOpts
|
|
|
|
Support
|
|
|
|
TransformUtils
|
|
|
|
Vectorize
|
2012-06-21 09:30:21 +08:00
|
|
|
)
|
|
|
|
|
2014-03-11 01:00:46 +08:00
|
|
|
option(CLANG_PLUGIN_SUPPORT "Build clang with plugin support" ON)
|
2014-03-08 09:19:37 +08:00
|
|
|
|
|
|
|
# Support plugins. This must be before add_clang_executable as it reads
|
|
|
|
# LLVM_NO_DEAD_STRIP.
|
2014-03-11 01:00:46 +08:00
|
|
|
if(CLANG_PLUGIN_SUPPORT)
|
2014-03-08 09:19:37 +08:00
|
|
|
set(LLVM_NO_DEAD_STRIP 1)
|
|
|
|
endif()
|
2014-03-08 08:41:53 +08:00
|
|
|
|
2016-11-20 05:14:59 +08:00
|
|
|
if(NOT CLANG_BUILT_STANDALONE)
|
|
|
|
set(tablegen_deps intrinsics_gen)
|
|
|
|
endif()
|
|
|
|
|
2016-01-20 06:41:51 +08:00
|
|
|
add_clang_tool(clang
|
2012-06-21 09:30:21 +08:00
|
|
|
driver.cpp
|
|
|
|
cc1_main.cpp
|
|
|
|
cc1as_main.cpp
|
2018-04-07 08:03:27 +08:00
|
|
|
cc1gen_reproducer_main.cpp
|
2016-11-19 07:31:16 +08:00
|
|
|
|
|
|
|
DEPENDS
|
2016-11-20 05:14:59 +08:00
|
|
|
${tablegen_deps}
|
2012-06-21 09:30:21 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(clang
|
[CMake] Use PRIVATE in target_link_libraries for executables
We currently use target_link_libraries without an explicit scope
specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
Dependencies added in this way apply to both the target and its
dependencies, i.e. they become part of the executable's link interface
and are transitive.
Transitive dependencies generally don't make sense for executables,
since you wouldn't normally be linking against an executable. This also
causes issues for generating install export files when using
LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
library dependencies, which are currently added as interface
dependencies. If clang is in the distribution components but the LLVM
libraries it depends on aren't (which is a perfectly legitimate use case
if the LLVM libraries are being built static and there are therefore no
run-time dependencies on them), CMake will complain about the LLVM
libraries not being in export set when attempting to generate the
install export file for clang. This is reasonable behavior on CMake's
part, and the right thing is for LLVM's build system to explicitly use
PRIVATE dependencies for executables.
Unfortunately, CMake doesn't allow you to mix and match the keyword and
non-keyword target_link_libraries signatures for a single target; i.e.,
if a single call to target_link_libraries for a particular target uses
one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
also be updated to use those keywords. This means we must do this change
in a single shot. I also fully expect to have missed some instances; I
tested by enabling all the projects in the monorepo (except dragonegg),
and configuring both with and without shared libraries, on both Darwin
and Linux, but I'm planning to rely on the buildbots for other
configurations (since it should be pretty easy to fix those).
Even after this change, we still have a lot of target_link_libraries
calls that don't specify a scope keyword, mostly for shared libraries.
I'm thinking about addressing those in a follow-up, but that's a
separate change IMO.
Differential Revision: https://reviews.llvm.org/D40823
llvm-svn: 319840
2017-12-06 05:49:56 +08:00
|
|
|
PRIVATE
|
2011-02-12 07:46:38 +08:00
|
|
|
clangBasic
|
2015-07-08 10:06:21 +08:00
|
|
|
clangCodeGen
|
2011-02-12 07:46:38 +08:00
|
|
|
clangDriver
|
|
|
|
clangFrontend
|
2013-12-10 20:40:37 +08:00
|
|
|
clangFrontendTool
|
2018-12-12 16:02:18 +08:00
|
|
|
clangSerialization
|
2009-03-24 10:52:57 +08:00
|
|
|
)
|
|
|
|
|
2015-07-05 18:16:24 +08:00
|
|
|
if(WIN32 AND NOT CYGWIN)
|
|
|
|
# Prevent versioning if the buildhost is targeting for Win32.
|
|
|
|
else()
|
|
|
|
set_target_properties(clang PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION})
|
|
|
|
endif()
|
2014-03-08 09:19:37 +08:00
|
|
|
|
|
|
|
# Support plugins.
|
2014-03-11 01:00:46 +08:00
|
|
|
if(CLANG_PLUGIN_SUPPORT)
|
2015-03-20 01:45:12 +08:00
|
|
|
export_executable_symbols(clang)
|
2014-03-08 09:19:37 +08:00
|
|
|
endif()
|
2011-02-26 03:24:02 +08:00
|
|
|
|
[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-05 05:19:53 +08:00
|
|
|
add_dependencies(clang clang-resource-headers)
|
2012-07-21 00:40:09 +08:00
|
|
|
|
2015-09-19 05:15:54 +08:00
|
|
|
if(NOT CLANG_LINKS_TO_CREATE)
|
2016-10-03 03:28:57 +08:00
|
|
|
set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
|
2015-09-19 05:15:54 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(link ${CLANG_LINKS_TO_CREATE})
|
|
|
|
add_clang_symlink(${link} clang)
|
|
|
|
endforeach()
|
2013-08-20 15:09:51 +08:00
|
|
|
|
|
|
|
# Configure plist creation for OS X.
|
|
|
|
set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name")
|
2017-01-10 01:06:24 +08:00
|
|
|
if (APPLE)
|
2013-08-20 15:09:51 +08:00
|
|
|
if (CLANG_VENDOR)
|
|
|
|
set(TOOL_INFO_NAME "${CLANG_VENDOR} clang")
|
|
|
|
else()
|
|
|
|
set(TOOL_INFO_NAME "clang")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(TOOL_INFO_UTI "${CLANG_VENDOR_UTI}")
|
|
|
|
set(TOOL_INFO_VERSION "${CLANG_VERSION}")
|
2016-11-19 03:20:39 +08:00
|
|
|
set(TOOL_INFO_BUILD_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
|
2017-01-10 01:06:24 +08:00
|
|
|
|
2013-08-20 15:09:51 +08:00
|
|
|
set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
|
|
|
|
target_link_libraries(clang
|
[CMake] Use PRIVATE in target_link_libraries for executables
We currently use target_link_libraries without an explicit scope
specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
Dependencies added in this way apply to both the target and its
dependencies, i.e. they become part of the executable's link interface
and are transitive.
Transitive dependencies generally don't make sense for executables,
since you wouldn't normally be linking against an executable. This also
causes issues for generating install export files when using
LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
library dependencies, which are currently added as interface
dependencies. If clang is in the distribution components but the LLVM
libraries it depends on aren't (which is a perfectly legitimate use case
if the LLVM libraries are being built static and there are therefore no
run-time dependencies on them), CMake will complain about the LLVM
libraries not being in export set when attempting to generate the
install export file for clang. This is reasonable behavior on CMake's
part, and the right thing is for LLVM's build system to explicitly use
PRIVATE dependencies for executables.
Unfortunately, CMake doesn't allow you to mix and match the keyword and
non-keyword target_link_libraries signatures for a single target; i.e.,
if a single call to target_link_libraries for a particular target uses
one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
also be updated to use those keywords. This means we must do this change
in a single shot. I also fully expect to have missed some instances; I
tested by enabling all the projects in the monorepo (except dragonegg),
and configuring both with and without shared libraries, on both Darwin
and Linux, but I'm planning to rely on the buildbots for other
configurations (since it should be pretty easy to fix those).
Even after this change, we still have a lot of target_link_libraries
calls that don't specify a scope keyword, mostly for shared libraries.
I'm thinking about addressing those in a follow-up, but that's a
separate change IMO.
Differential Revision: https://reviews.llvm.org/D40823
llvm-svn: 319840
2017-12-06 05:49:56 +08:00
|
|
|
PRIVATE
|
2013-08-20 15:09:51 +08:00
|
|
|
"-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
|
|
|
|
configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
|
2017-01-10 01:06:24 +08:00
|
|
|
|
2013-08-20 15:09:51 +08:00
|
|
|
set(TOOL_INFO_UTI)
|
|
|
|
set(TOOL_INFO_NAME)
|
|
|
|
set(TOOL_INFO_VERSION)
|
|
|
|
set(TOOL_INFO_BUILD_VERSION)
|
|
|
|
endif()
|
2013-08-20 15:41:18 +08:00
|
|
|
|
2018-06-02 09:22:39 +08:00
|
|
|
if(CLANG_ORDER_FILE AND
|
2018-06-15 07:26:33 +08:00
|
|
|
(LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
|
2018-06-02 08:49:54 +08:00
|
|
|
include(CheckLinkerFlag)
|
2016-04-09 06:48:18 +08:00
|
|
|
|
2018-06-15 07:26:33 +08:00
|
|
|
if (LLVM_LINKER_IS_LD64)
|
2017-01-10 01:06:24 +08:00
|
|
|
set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
|
2018-06-02 09:22:39 +08:00
|
|
|
elseif (LLVM_LINKER_IS_GOLD)
|
2017-01-10 01:06:24 +08:00
|
|
|
set(LINKER_ORDER_FILE_OPTION "-Wl,--section-ordering-file,${CLANG_ORDER_FILE}")
|
2018-06-02 09:22:39 +08:00
|
|
|
elseif (LLVM_LINKER_IS_LLD)
|
|
|
|
set(LINKER_ORDER_FILE_OPTION "-Wl,--symbol-ordering-file,${CLANG_ORDER_FILE}")
|
2017-01-10 01:06:24 +08:00
|
|
|
endif()
|
|
|
|
|
2016-04-09 06:48:18 +08:00
|
|
|
# This is a test to ensure the actual order file works with the linker.
|
2017-01-10 01:06:24 +08:00
|
|
|
check_linker_flag(${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
|
2016-08-11 08:19:51 +08:00
|
|
|
|
|
|
|
# Passing an empty order file disables some linker layout optimizations.
|
|
|
|
# To work around this and enable workflows for re-linking when the order file
|
|
|
|
# changes we check during configuration if the file is empty, and make it a
|
|
|
|
# configuration dependency.
|
|
|
|
file(READ ${CLANG_ORDER_FILE} ORDER_FILE LIMIT 20)
|
|
|
|
if("${ORDER_FILE}" STREQUAL "\n")
|
|
|
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CLANG_ORDER_FILE})
|
|
|
|
elseif(LINKER_ORDER_FILE_WORKS)
|
2017-12-07 04:05:42 +08:00
|
|
|
target_link_libraries(clang PRIVATE ${LINKER_ORDER_FILE_OPTION})
|
2016-04-09 06:48:18 +08:00
|
|
|
set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE})
|
|
|
|
endif()
|
2013-08-20 15:41:18 +08:00
|
|
|
endif()
|
|
|
|
|
2014-03-14 12:04:27 +08:00
|
|
|
if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
|
[CMake] Use PRIVATE in target_link_libraries for executables
We currently use target_link_libraries without an explicit scope
specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
Dependencies added in this way apply to both the target and its
dependencies, i.e. they become part of the executable's link interface
and are transitive.
Transitive dependencies generally don't make sense for executables,
since you wouldn't normally be linking against an executable. This also
causes issues for generating install export files when using
LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
library dependencies, which are currently added as interface
dependencies. If clang is in the distribution components but the LLVM
libraries it depends on aren't (which is a perfectly legitimate use case
if the LLVM libraries are being built static and there are therefore no
run-time dependencies on them), CMake will complain about the LLVM
libraries not being in export set when attempting to generate the
install export file for clang. This is reasonable behavior on CMake's
part, and the right thing is for LLVM's build system to explicitly use
PRIVATE dependencies for executables.
Unfortunately, CMake doesn't allow you to mix and match the keyword and
non-keyword target_link_libraries signatures for a single target; i.e.,
if a single call to target_link_libraries for a particular target uses
one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
also be updated to use those keywords. This means we must do this change
in a single shot. I also fully expect to have missed some instances; I
tested by enabling all the projects in the monorepo (except dragonegg),
and configuring both with and without shared libraries, on both Darwin
and Linux, but I'm planning to rely on the buildbots for other
configurations (since it should be pretty easy to fix those).
Even after this change, we still have a lot of target_link_libraries
calls that don't specify a scope keyword, mostly for shared libraries.
I'm thinking about addressing those in a follow-up, but that's a
separate change IMO.
Differential Revision: https://reviews.llvm.org/D40823
llvm-svn: 319840
2017-12-06 05:49:56 +08:00
|
|
|
target_link_libraries(clang PRIVATE Polly)
|
2014-03-14 12:04:27 +08:00
|
|
|
endif(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
|