Commit Graph

52 Commits

Author SHA1 Message Date
Petr Hosek ce0ea76f40 [CMake] Enable ARM target in Fuchsia toolchain
This is still used by some users of Fuchsia toolchain. Also include
llc and opt which is useful for development and testing.

Differential Revision: https://reviews.llvm.org/D32231

llvm-svn: 300917
2017-04-20 23:06:53 +00:00
Petr Hosek 60f54ac8c5 [CMake] Support building Fuchsia toolchain on Darwin
This is already supported on Linux but on Darwin it requires some
extra flags.

Differential Revision: https://reviews.llvm.org/D30958

llvm-svn: 300257
2017-04-13 21:09:42 +00:00
Michal Gorny 5ef8bf7369 [cmake] Support Gentoo install for z3
Add the 'z3' subdirectory to the list of possible path suffixes for
libz3 header search. The z3 headers are installed in /usr/include/z3
on Gentoo.

Differential Revision: https://reviews.llvm.org/D31756

llvm-svn: 299813
2017-04-08 14:38:06 +00:00
Dominic Chen 08f943c563 [analyzer] Add new Z3 constraint manager backend
Summary: Implement new Z3 constraint manager backend.

Reviewers: zaks.anna, dcoughlin, NoQ, xazax.hun

Subscribers: mgorny, cfe-commits

Differential Revision: https://reviews.llvm.org/D28952

llvm-svn: 299463
2017-04-04 19:52:25 +00:00
Guillaume Papin d2a64aa854 [CMake] fix CLANG_INCLUDE_DIRS CMake export
Summary:
This change should fixes the export of CLANG_INCLUDE_DIRS variable in ClangConfig.cmake.

Unlike for the other variables, CLANG_INSTALL_PREFIX wasn't escaped meaning CLANG_INCLUDE_DIRS
resulting in the path "/include" instead of "${CLANG_INSTALL_PREFIX}/include".

Reviewers: beanz

Subscribers: mgorny

Differential Revision: https://reviews.llvm.org/D30911

llvm-svn: 298424
2017-03-21 19:17:53 +00:00
Mehdi Amini 7103b2ecfd Add a cmake cache file for a stage-2 build with ThinLTO
This is intended to be targetted by a Green Dragon stage-2 bot
I'm bringing up currently. WIP.

llvm-svn: 297351
2017-03-09 01:18:31 +00:00
Petr Hosek 367ad73aff [CMake] Add Fuchsia toolchain CMake cache files
These cache files can be used to build Fuchsia toolchain. They also
demonstrate the use of multi-target builtins build.

Differential Revision: https://reviews.llvm.org/D26654

llvm-svn: 295480
2017-02-17 19:28:54 +00:00
Chris Bieneman c574297de6 [CMake] Add CLANG_INCLUDE_DIRS to CMake exports
This patch adds setting CLANG_INCLUDE_DIRS in the generated CMake package configuration files.

llvm-svn: 294207
2017-02-06 18:17:23 +00:00
Michal Gorny f103c0d7fd [cmake] Hint find_package() to prefer LLVM installed alongside clang
Include a path hint for find_package() in ClangConfig.cmake to ensure
that CMake prefers LLVM installed alongside clang over the default
search path.

If two versions of LLVM are installed in the system, and one of them is
in PATH, CMake's find_package() magic prefers the CMake directory
alongside that install by default. Adding a relative hint makes it
possible to prioritize to the install from which find_package() is
called.

If you want to build e.g. LLDB against another install of LLVM, you can
pass LLVM_CONFIG override. In this case, LLDB queries the prefix from
llvm-config and uses the CMake files located there. However, when
including ClangConfig, the implicit find_package() nevertheless prefers
PATH-found LLVM over the one used previously by LLDB, and two versions
of LLVMConfig end up being loaded.

This could be fixed on LLDB end up by explicitly forcing custom package
search location. However, it seems simpler and safer to add a hint to
ClangConfig than to track every usage of ClangConfig.

Differential Revision: https://reviews.llvm.org/D29304

llvm-svn: 293632
2017-01-31 14:15:40 +00:00
Justin Bogner 5ca4d5f5fe cmake: Don't try to install exports if there aren't any
When using LLVM_DISTRIBUTION_COMPONENTS, it's possible for clang's
export list to be empty. If this happens the install(EXPORTS) command
will fail, but since there isn't anything to install anyway we really
just want to skip it.

llvm-svn: 286210
2016-11-08 05:02:33 +00:00
Justin Bogner 66b326bc55 cmake: Support exports correctly with LLVM_DISTRIBUTION_COMPONENTS
We need to apply the same export logic in clang as in llvm for
LLVM_DISTRIBUTION_COMPONENTS, or the clang exports will be invalid
when we use this config.

This makes using distribution components without setting
LLVM_TOOLCHAIN_ONLY=On work correctly.

llvm-svn: 286181
2016-11-07 23:46:05 +00:00
Chris Bieneman 7e0f03ecf2 [CMake] Adding example distribution CMake cache files
These cache file are provided as an example of how to set up simple multi-stage CMake builds. I have a batch of documentation updates for LLVM.org which reference these files.

llvm-svn: 285206
2016-10-26 15:41:38 +00:00
Michael Gottesman 66cc2d5210 [cmake] Follow LLVM's lead in creating exported tool targets for clang tools.
This is needed by downstream projects such as swift to get proper cmake
dependency information for LLVM/Clang targets.

A few months ago I added support for exporting this information for Clang
libraries. In order to be incremental, I did not add support for exporting clang
tools as well at that time. Now such support is needed, so I am committing this
incremental code.

llvm-svn: 284658
2016-10-19 22:46:06 +00:00
Chris Bieneman ebe8b83fbc [CMake] Support thin LTO in PGO CMake cache
This allows you to set PGO_INSTRUMENT_LTO=Thin and have it work correctly.

llvm-svn: 284646
2016-10-19 21:12:04 +00:00
Chris Bieneman 981618da53 [CMake] Adding toolchain targets to PGO and Apple CMake caches
The Xcode toolchain targets are useful on OS X hosts because you can construct and install multiple toolchians that can be used seamlessly.

llvm-svn: 278987
2016-08-17 21:51:38 +00:00
Chris Bieneman a1aa4069d9 [CMake] Workflow improvements to PGO generation
This patch adds a few new convenience options used by the PGO CMake cache to setup options on bootstrap stages. The new options are:

PGO_INSTRUMENT_LTO - Builds the instrumented and final builds with LTO
PGO_BUILD_CONFIGURATION - Accepts a CMake cache script that can be used for complex configuration of the stage2-instrumented and stage2 builds.

The patch also includes a fix for bootstrap dependencies so that the instrumented LTO tools don't get used when building the final stage, and it adds distribution targets to the passthrough.

llvm-svn: 278862
2016-08-16 22:16:29 +00:00
Chris Bieneman 31cc8b3887 [CMake] [Apple Cache] Set CLANG_VENDOR_UTI for Apple builds
This is just a minor update to the Apple packaging configuration.

llvm-svn: 278849
2016-08-16 20:44:58 +00:00
Chris Bieneman bba9ee3b76 [CMake] Apple stage1 doesn't need to set libcxx options
LibCXX settings are configured in stage2 so we don't need them here.

llvm-svn: 278729
2016-08-15 20:15:22 +00:00
Michael Gottesman eb396a6cbf Add CLANG_BUILD_TOOLS as a clang counterpart for LLVM_BUILD_TOOLS
LLVM_BUILD_TOOLS is a boolean variable that controls whether or not generated
targets for llvm tools are built by the "all" target. CLANG_BUILD_TOOLS is an
analogous variable for clang targets.

This is useful functionality for selectively disabling the building of clang
targets by default to speed up builds.

In terms of implementation, I just followed the model of LLVM's implementation
of this functionality.

llvm-svn: 275006
2016-07-10 01:44:00 +00:00
Michael Gottesman ca589ccb02 Move add_clang_* entry points from the main clang CMakeLists.txt to cmake/modules/AddClang.cmake.
This matches how LLVM has its cmake files organized and is cleaner than just
shoving this business logic into the main CMakeLists.txt.

llvm-svn: 274992
2016-07-09 21:58:40 +00:00
Michael Gottesman a1e6c6cabc [cmake] Remove stale comment. NFC.
llvm-svn: 274212
2016-06-30 05:51:18 +00:00
Michael Gottesman 5ba5270eb9 [ClangConfig] Store all of the targets exported in the variable CLANG_EXPORTED_TARGETS.
llvm-svn: 274180
2016-06-29 21:59:23 +00:00
Michael Gottesman ccc31a173e [ClangConfig] Unset some variables after we are done using them to configure ClangConfig.cmake.in files.
This ensures that the values do not bleed over in between computations. It may
make sense in the future to just refactor this code into functions to provide
"true scoping".

llvm-svn: 274179
2016-06-29 21:59:20 +00:00
Michael Gottesman 497e97ffe3 [ClangConfig] Instead of hard coding the ClangTargets location to /ClangTargets.cmake, follow LLVM's example and use a pre-computed cmake variable @CLANG_CONFIG_EXPORTS_FILE@.
This just makes ClangConfig more consistent with LLVMConfig.

llvm-svn: 274178
2016-06-29 21:59:19 +00:00
Michael Gottesman 1b87cd3974 [ClangConfig] Follow LLVM's example and only install Clang{Config,Target}.cmake when LLVM_INSTALL_TOOLCHAIN_ONLY is disabled.
llvm-svn: 274177
2016-06-29 21:59:15 +00:00
Michael Gottesman 905426e606 [cmake] Instead of just copying ClangConfig.cmake, configure it using ClangConfig.cmake.in.
This will allow for cmake to expand variables in ClangConfig.cmake for
downstream users.

llvm-svn: 274176
2016-06-29 21:59:14 +00:00
Michael Gottesman 03c38af109 [ClangConfig] Copy ClangConfig.cmake to ${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR} instead of to ${CLANG_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}.
This is an obvious bug since ClangConfig.cmake looks for ClangTargets.cmake in
${CMAKE_CURRENT_LIST_DIR}. But ClangTargets.cmake is in
${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}, so it will always fail with an
in tree build.

In the case where clang is built out of tree, this is still correct since
CMAKE_BINARY_DIR and CLANG_BINARY_DIR will be the same.

llvm-svn: 274168
2016-06-29 21:12:38 +00:00
Michael Gottesman 3f5275e8ed [ClangConfig] Replace paths with the same value as CLANG_INSTALL_PACKAGE_DIR with a deref of the variable.
llvm-svn: 274158
2016-06-29 20:22:46 +00:00
Michael Gottesman fe9d2d81f6 [cmake] Move creation of ClangTargets and installation of ClangConfig.cmake from ./CMakeLists.txt -> ./cmake/modules/CMakeLists.txt.
This matches LLVM.

llvm-svn: 274157
2016-06-29 20:22:44 +00:00
Chris Bieneman e55838d596 [CMake] [Apple Clang] Enable Compiler-RT tests on stage2 builds
We want to be able to run the compiler-rt tests on stage2 build configurations in CI. This should enable that.

llvm-svn: 274031
2016-06-28 16:32:48 +00:00
Vedant Kumar 400a3f66e2 [cmake] Enable zlib support for Apple stage2 builds
This allows llvm-profdata to interact with profiles containing
compressed name data.

rdar://problem/26122944

llvm-svn: 268947
2016-05-09 18:40:09 +00:00
Chris Bieneman 5239779465 [CMake] Removing LLVM_ENABLE_TIMESTAMPS from the cache files
Since the option was removed in r268670, the cache scripts should stop referring to it.

llvm-svn: 268685
2016-05-05 21:08:41 +00:00
Chris Bieneman 35de7bcfb7 [CMake][Apple-stage2] Don't link with -fno-pie
On Darwin the default is to build PIC and link PIE. We shouldn't need to override that in the Apple Clang distributions.

llvm-svn: 268642
2016-05-05 16:31:28 +00:00
Chris Bieneman b8f0a4ea33 [CMake] Enable LIBCXX HEADERS in Apple-Stage2.cmake
This enables installing the libcxx headers.

llvm-svn: 268322
2016-05-02 22:43:23 +00:00
Chris Bieneman d5a3b23736 [CMake] Install libcxx-headers as part of the Apple-stage2 distribution
This installs the clang headers as part of the install-distribution target.

llvm-svn: 268320
2016-05-02 22:42:09 +00:00
Chris Bieneman 9920c39aef [CMake] Adding clang-headers to the Apple-stage2 distribution
This installs the clang headers as part of the install-distribution target.

llvm-svn: 268319
2016-05-02 22:38:06 +00:00
Chris Bieneman 35c913dd4c [CMake] Use just-built clang and build iOS support when building stage2
The Apple stage2 build should include compiler-rt iOS libraries and be built with the stage2 compiler. This matches Apple's production clang builds.

llvm-svn: 267584
2016-04-26 18:39:20 +00:00
Chris Bieneman 3eaf5dc052 [Apple Clang] Expose llvm-config from stage2 builds in stage1
This exposes the stage2-llvm-config target though the stage1 build configuration.

llvm-svn: 264125
2016-03-23 01:47:05 +00:00
Chris Bieneman ba83735b2f [CMake] Updating Apple build configurations
This updates Apple build configurations to adapt to r263566 & r263570, which added a PACKAGE_VENDOR variable.

llvm-svn: 263571
2016-03-15 18:27:28 +00:00
Chris Bieneman cc2aded1ff [CMake] Updating Apple Clang CMake caches
This is a big update that gets the public configurations more in line with the ones we're actually using internally to ship Clang in Xcode.

From here forward I expect most of the changes in these files to be incremental as the changes get made internally.

llvm-svn: 263483
2016-03-14 20:23:21 +00:00
Chris Bieneman 33b41961c3 [CMake] Only configure Native target in stage 1, configure all in other stages
This patch causes the 3-stage build pipeline to only build a host compiler in the first stage, and to build all targets for subsequent stages. The host target is determined via the Native target specifier added in r262070.

llvm-svn: 262071
2016-02-26 21:23:59 +00:00
Reid Kleckner a2550e68a5 Add call to find_package to load LLVM dependencies
ClangConfig requires LLVMConfig, so add find_package call in
ClangConfig so find_package(clang REQUIRED CONFIG) will just work.  This
makes it easier for cmake based projects to use clang, e.g., tools using
ClangTooling.

Patch by Don Hinton

Differential Revision: http://reviews.llvm.org/D13622

llvm-svn: 261290
2016-02-19 00:56:56 +00:00
Chris Bieneman 7590a1ee61 [CMake] For multi-stage builds to be deterministic we need to disable timestamps.
Duh! With this change I've verified -O3 builds are deterministic.

llvm-svn: 260350
2016-02-10 02:17:21 +00:00
Chris Bieneman a0a0317dbc [CMake] Fixing the 3-stage cmake cache.
I had hoped this would work from a single cache file, but turns out there is a bug I can't quite figure out relating to passing list arguments to recursive CMake invocations.

This change works around that.

llvm-svn: 260340
2016-02-10 01:09:56 +00:00
Chris Bieneman b79e55577e [CMake] Updating caches README with explanations of useful cache files.
This is in response to silvas' post-commit suggestion.

llvm-svn: 260203
2016-02-09 06:49:08 +00:00
Chris Bieneman 6ced921f8c [CMake] Providing a CMake cache for 3-stage builds
This cache file can be used to generate a 3-stage clang build. You can configure using the following CMake command:

cmake -C <path to clang>/cmake/caches/3-stage.cmake -G Ninja <path to llvm>

You can then run "ninja stage3-clang" to build stage1, stage2 and stage3 clangs.

This is useful for finding non-determinism the compiler by verifying that stage2 and stage3 are identical.

llvm-svn: 260201
2016-02-09 06:01:47 +00:00
Chris Bieneman b2920a779c [CMake] Support a simple case for bootstrap builds to generate PGO data
Summary:
This patch adds support for the clang multi-stage bootstrapping to support PGO profdata generation, and can build a 2 or 3 stage compiler.

With this patch applied you can configure your build directory with the following invocation of CMake:

cmake -G <generator> -C <path_to_clang>/cmake/caches/PGO.cmake <source dir>

After configuration the following additional targets will be generated:

stage2-instrumented:
Builds a stage1 x86 compiler, runtime, and required tools (llvm-config, llvm-profdata) then uses that compiler to build an instrumented stage2 compiler.

stage2-instrumented-generate-profdata:
Depends on "stage2-instrumented" and will use the instrumented compiler to generate profdata based on the training files in <clang>/utils/perf-training

stage2:
Depends on "stage2-instrumented-generate-profdata" and will use the stage1 compiler with the stage2 profdata to build a PGO-optimized compiler.

stage2-check-llvm:
Depends on stage2 and runs check-llvm using the stage3 compiler.

stage2-check-clang:
Depends on stage2 and runs check-clang using the stage3 compiler.

stage2-check-all:
Depends on stage2 and runs check-all using the stage3 compiler.

stage2-test-suite:
Depends on stage2 and runs the test-suite using the stage3 compiler (requires in-tree test-suite).

Reviewers: bogner, silvas, chandlerc

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D15584

llvm-svn: 256873
2016-01-05 23:51:42 +00:00
Chris Bieneman b657449399 Revert "[CMake] Support a simple case for bootstrap builds to generate PGO data"
This reverts commit r256069, which was an unintentional tag along on
another commit.

llvm-svn: 256088
2015-12-19 05:47:50 +00:00
Chris Bieneman a948007062 [CMake] Support a simple case for bootstrap builds to generate PGO data
Summary:
This patch adds support for the clang multi-stage bootstrapping to support PGO profdata generation, and can build a 2 or 3 stage compiler.

With this patch applied you can configure your build directory with the following invocation of CMake:

cmake -G <generator> -C <path_to_clang>/cmake/caches/PGO.cmake <source dir>

After configuration the following additional targets will be generated:

stage2-instrumented:
Builds a stage1 x86 compiler, runtime, and required tools (llvm-config, llvm-profdata) then uses that compiler to build an instrumented stage2 compiler.

stage2-instrumented-generate-profdata:
Depends on "stage2-instrumented" and will use the instrumented compiler to generate profdata based on the training files in <clang>/utils/perf-training

stage2:
Depends on "stage2-instrumented-generate-profdata" and will use the stage1 compiler with the stage2 profdata to build a PGO-optimized compiler.

stage2-check-llvm:
Depends on stage2 and runs check-llvm using the stage3 compiler.

stage2-check-clang:
Depends on stage2 and runs check-clang using the stage3 compiler.

stage2-check-all:
Depends on stage2 and runs check-all using the stage3 compiler.

stage2-test-suite:
Depends on stage2 and runs the test-suite using the stage3 compiler (requires in-tree test-suite).

Reviewers: bogner, silvas, chandlerc

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D15584

llvm-svn: 256069
2015-12-19 00:56:10 +00:00
Chris Bieneman bca3d933ce [CMake] Set CLANG_LINKS_TO_CREATE in Apple-stage2.cmake so that we create cc and c++ links.
llvm-svn: 248016
2015-09-18 18:11:18 +00:00