Commit Graph

306 Commits

Author SHA1 Message Date
NAKAMURA Takumi 3cc0d4e058 clang/CMakeLists.txt: Rework r294954 -- use file(TO_CMAKE_PATH).
llvm-svn: 295592
2017-02-19 03:17:31 +00:00
NAKAMURA Takumi a1c0f60722 Fix r291495 -- Normalize LLVM_CMAKE_PATH in clang standalone build.
CMake handles paths with slashes. It caused cmake/install failure on msbuild.exe.

Note, Other llvm-config-oriented variables have been normalized since they are stored in the cache attributed with PATH.

llvm-svn: 294954
2017-02-13 14:59:53 +00:00
Michal Gorny 638ac70a92 [test] Port clang tests to canonicalized booleans
Use the new llvm_canonicalize_cmake_booleans() function to canonicalize
booleans for lit tests. Replace the duplicate ENABLE_CLANG* variables
used to hold canonicalized values with in-place canonicalization. Use
implicit logic in Python code to avoid overrelying on exact 0/1 values.

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

llvm-svn: 293052
2017-01-25 13:11:45 +00:00
Petr Hosek 0320314249 [CMake] Separate LLVM_ENABLE_LTO and LLVM_ENABLE_LLD
These two are independent: it's possible to use LLD without LTO,
and it's possible to do LTO build without LLD.

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

llvm-svn: 292343
2017-01-18 05:41:17 +00:00
Michal Gorny 8c5c7ffb8d [cmake] Obtain LLVM_CMAKE_PATH from llvm-config
Use the new --cmakedir option to obtain LLVM_CMAKE_PATH straight from
llvm-config instead of reconstructing it locally.

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

llvm-svn: 291495
2017-01-09 23:06:39 +00:00
Alexander Shaposhnikov fd7afa73b6 [clang] Fix clean build of generate-order-file
This diff fixes the clean build of the target generate-order-file.
In llvm/tools/clang/CMakeLists.txt 
add_subdirectory(utils/perf-training) should go after the block where 
the value of the variable CLANG_ORDER_FILE is set - otherwise 
(tested with cmake's version 3.6.2) the arguments of perf-helper.py gen-order-file
will be ill-formed (CLANG_ORDER_FILE will be empty).

Differential revision: https://reviews.llvm.org/D28153

llvm-svn: 290781
2016-12-31 05:25:52 +00:00
Petr Hosek fe2c2b082f [Driver] Allow setting the default linker during build
This change allows setting the default linker used by the Clang
driver when configuring the build.

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

llvm-svn: 289668
2016-12-14 16:46:50 +00:00
Petr Hosek 8e07a88bfa [CMake] Support lld with LTO bootstrap
lld has LTO support, if requested we should add a dependency on lld
rather than LLVMgold when doing LTO bootstrap build.

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

llvm-svn: 287179
2016-11-16 23:59:06 +00:00
Chris Bieneman 76a2e60e59 [CMake] Add clang-bootstrap-deps target
Having this target allows other parts of the build system to add to the bootstrap dependencies without needing to be defined before the bootstrap targets are created.

This will specifically be used connect the builtins build from the LLVM runtimes directory as a dependency of the next build stage.

llvm-svn: 284648
2016-10-19 21:18:48 +00:00
Michal Gorny da6d2b8315 [cmake] Update lit search to match the one in LLVM
Update the lit search logic to support all names supported in LLVM
(since r283029). The search order (i.e. PATHS vs HINTS) does no really
matter since the established path is not used, except for determining
whether lit is available.

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

llvm-svn: 284496
2016-10-18 17:07:30 +00:00
Chris Bieneman b137053189 [CMake] Add a few default passthrough variables for bootstrap builds
This just passes through a few missing CMake variables for multi-stage builds.

llvm-svn: 284443
2016-10-18 00:50:20 +00:00
Chris Bieneman 725acc4d85 [CMake] More robust handling for bootstrap variables
Checking defined isn't good enough we also need to handle defined to empty string.

llvm-svn: 282125
2016-09-22 00:18:12 +00:00
Chris Bieneman 43a601d1ec [CMake] Check if passthrough variables are defined
Checking if they evaluate to true cases prevents passing values that evaluate to false cases. Instead we should check if the variables are defined.

llvm-svn: 282122
2016-09-21 23:24:15 +00:00
Chris Bieneman 2c4d54f326 [CMake] Pass CLANG_VERSION_* variables into later stages
When supporting overriding clang versions we also need to pass those through to the next stage so they remain overridden.

llvm-svn: 282109
2016-09-21 20:43:43 +00:00
Chris Bieneman ebfc680685 [CMake] Support overriding CLANG_VERSION_*
As with how we handle LLVM_VERSION_* variables we should support
overriding clang version variables.

llvm-svn: 282003
2016-09-20 19:09:21 +00:00
David L. Jones 2f7545228d 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-15 22:12:26 +00:00
Chris Bieneman a6b39ab66c driver: Support checking for rlimits via cmake (when bootstrapping)
Summary:
Add a cmake check for sys/resource.h and replace the __has_include() check with its result, in order to make it possible to use rlimits when building with compilers not supporting __has_include() -- i.e. when bootstrapping.

// Please also re-apply dfcd52eb1d8e5d322404b40414cb7331c7380a8c (llvm-config.h fix)

Patch by: Michał Górny

Reviewers: rsmith, beanz

Subscribers: cfe-commits

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

llvm-svn: 279559
2016-08-23 20:07:07 +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
Jonas Hahnfeld d196fa524f Support setting default value for -rtlib at build time
This patch introduces a new cmake variable: CLANG_DEFAULT_RTLIB, thru
which we can specify a default value for -rtlib (libgcc or
compiler-rt) at build time, just like how we set the default C++
stdlib thru CLANG_DEFAULT_CXX_STDLIB.

With these two options, we can configure clang to build binaries on
Linux that have no runtime dependence on any gcc libs (libstdc++ or
libgcc_s).

Patch by Lei Zhang!

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

llvm-svn: 276848
2016-07-27 08:15:54 +00:00
Chris Bieneman d052efc332 [CMake] Pass DYLD_LIBRARY_PATH as CMake variable instead of as envar
On OS X 10.11 System Integrity Protection prevents the DYLD environment variables from being set on system binaries. To work around this r276710 accepts DYLD_LIBRARY_PATH as a CMake variable and sets it directly on the archiver commands.

To make this work with bootstrapping we need to set DYLD_LIBRARY_PATH to the current stage's library directory and pass that into the next stage's configuration.

llvm-svn: 276711
2016-07-25 23:48:14 +00:00
Chris Bieneman c486541fea [CMake] Cleaning up some CMake warnings
In Bootstrap builds Clang logs some warnings. These are caused because Clang passes CLANG_STAGE and BOOTSTRAP_DEFAULT_PASSTHROUGH into the next stage's configuration.

BOOTSTRAP_DEFAULT_PASSTHROUGH shouldn't be passed, so it is renamed to _BOOTSTRAP_DEFAULT_PASSTHROUGH, to prevent passthrough.

CLANG_STAGE should be passed, so I've changed the code to log it if it is set outside the if(CLANG_ENABLE_BOOTSTRAP) block. This makes the variable always used, so the warning goes away.

llvm-svn: 276674
2016-07-25 18:54:30 +00:00
Jonas Hahnfeld ebf866213c Update description for CLANG_DEFAULT_CXX_STDLIB and add comment. NFC
We agreed to call it "platform default" instead of "architecture default".
(see D17286)

llvm-svn: 276618
2016-07-25 08:04:26 +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 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 38238a4f56 [CMake] Remove CLANG_APPEND_VC_REV option
I added this option in r257827 to try and add compatibility with autoconf. At the time I misunderstood the problem.

Our CMake automatically generates the SVN revision information and generates a build action to update it so builds don't need to be re-configured on SCM update (which is a better solution than we had in autoconf).

The problem I was actually seeing was isolated cases where SVN revision information isn't available because the repository structures have been removed. This happens in some automated testing systems.

This patch allows SVN_REVISION to be overridden if the build configuration could not find the SCM repository structures, and removes the code from my original patch because it is unnecessary.

llvm-svn: 273714
2016-06-24 20:21:12 +00:00
Rafael Espindola 557679f42b Add a ENABLE_X86_RELAX_RELOCATIONS cmake option.
This corresponds to binutils' --enable-x86-relax-relocations.

llvm-svn: 273224
2016-06-20 23:54:44 +00:00
Chris Bieneman f325b8c71b [CMake] Cleaning up CMake version checks in ExternalProject calls
Now that we're on CMake 3.4.3 all the ExternalProject features we use are supported everywhere, so we don't need the version checks anymore.

llvm-svn: 272324
2016-06-09 22:38:42 +00:00
Chris Bieneman 04e8a21876 [CMake] Version is aways greater than 3
We don't need any checks for this code anymore. Since CMake version is always greater than 3 we can always generate the exports file.

llvm-svn: 272323
2016-06-09 22:38:40 +00:00
Chris Bieneman 28cdb677ed [CMake] Cleaning up CMake feature gating on 2.8.12
CMake 2.8.12 introduced interface libraries and some related policies. This removes the conditional block because we're now past 2.8.12.

llvm-svn: 272312
2016-06-09 21:29:55 +00:00
Chris Bieneman 1ddbb6be8a Revert "[CMake] Fix an issue building out-of-tree introduced in r272200"
This reverts r272275. This actually wasn't the right way to fix the problem. The correct solution is in r272279.

Applying the fix to LLVM as done in r272279, means this fix will get picked up by all projects building out of tree using LLVM's CMake modules. As opposed to the fix I had in r272275, which would require each project to change.

llvm-svn: 272280
2016-06-09 17:24:16 +00:00
Chris Bieneman ecdbb765fa [CMake] Fix an issue building out-of-tree introduced in r272200
The out-of-tree build needs to read LLVM_TOOLS_INSTALL_DIR out of TOOLS_BINARY_DIR because LLVM_TOOLS_INSTALL_DIR is used by AddLLVM.cmake

llvm-svn: 272275
2016-06-09 16:21:10 +00:00
Rafael Espindola 5ed89d4a01 Don't pass --build-id to ld by default.
We now have a cmake option to change the default: ENABLE_LINKER_BUILD_ID.

The reason is that build-id is fairly expensive, so we shouldn't impose
it in the regular edit/build cycle.

This is similar to gcc, that has an off by default --enable-linker-build-id
option.

llvm-svn: 271692
2016-06-03 17:26:16 +00:00
Chris Bieneman f8ebfc4b65 [CMake] Update to requiring CMake 3.4.3
Summary:
This is as per the discussions on developer lists:

http://lists.llvm.org/pipermail/llvm-dev/2016-April/098780.html
http://lists.llvm.org/pipermail/llvm-dev/2016-May/100058.html

Subscribers: cfe-commits

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

llvm-svn: 271326
2016-05-31 20:21:38 +00:00
Chris Bieneman 31046054a8 [CMake] On Darwin bootstrap LTO builds set DYLD_LIBRARY_PATH instead of using llvm-ar
llvm-ar isn't really supported for Darwin, instead the host tools will load libLTO, so we can use the just-built libLTO.

This actually makes Darwin bootstrap builds a little faster because you don't need to build llvm-ar before starting the next stage.

llvm-svn: 267756
2016-04-27 18:52:48 +00:00
Chris Bieneman 834a40b463 [Perf-Training] Reworked workflow improvements for order-file generation
This is re-landing r260742. I've reworked the conditionals so that it only hits when targeting Apple platforms with ld64.

Original Summary:
With this change generating clang order files using dtrace uses the following workflow:

cmake <whatever options you want>

ninja generate-order-file

ninja clang

This patch works by setting a default path to the order file (which can be overridden by the user). If the order file doesn't exist during configuration CMake will create an empty one.

CMake then ties up the dependencies between the clang link job and the order file, and generate-order-file overwrites CLANG_ORDER_FILE with the new order file.

llvm-svn: 265864
2016-04-08 22:48:18 +00:00
Mike Spertus e9f15b4b9f Convert to Unix line endings due to previous commit error.
llvm-svn: 264610
2016-03-28 18:24:22 +00:00
Mike Spertus 6601a4420b Use VS2015 Project Support for Natvis to eliminate the need to manually install clang native visualizer
This is the clang equivalent to llvm commit 264601. When using Visual Studio 2015, cmake now puts the native visualizers in llvm.sln, so the developer automatically sees custom visualizations.
Much thanks to ariccio who provided extensive help on this change. (manual installation still needed on VS2013).

llvm-svn: 264603
2016-03-28 18:03:37 +00:00
Chris Bieneman 4ec7f3f47d [CMake] Defaulting CLANG_VENDOR to PACKAGE_VENDOR
LLVM r263566 adds a generic PACKAGE_VENDOR configuration which can be used to specify the vendor for LLVM toolchain tools. This change defaults the CLANG_VENDOR to the PACKAGE_VENDOR so that you don't have to specify both when building a package.

llvm-svn: 263570
2016-03-15 18:25:36 +00:00
Chris Bieneman 0e64cc886b [CMake] Add BINUTILS_INCDIR to the default passthrough list for multi-stage builds
This is needed to build the gold plugin in multi-stage builds.

Patch by Mike Edwards

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

llvm-svn: 262065
2016-02-26 21:04:41 +00:00
Chandler Carruth ce55f56fbc [cmake] Revert r260742 (and r260744) to improve order file support.
This appears to be passing '-Wl,-order_file' to Linux link commands,
which then causes the linker to silently, behind the scenes, write the
output to 'rder_file' instead of somewhere else. Will work with Chris to
figure out the proper support for this, but so far there are numerous
people who can't get Clang to update when they build because of this.

llvm-svn: 261054
2016-02-17 02:13:35 +00:00
Chris Bieneman 595c13771d [CMake] Fixing bots I broke.
llvm-svn: 260744
2016-02-12 21:46:25 +00:00
Chris Bieneman 3878bc4a33 [CMake] Improve the clang order-file generation workflow
Summary:
This commit re-lands r259862. The underlying cause of the build breakage was an incorrectly written capabilities test. In tools/Driver/CMakeLists.txt I was attempting to check if a linker flag worked, the test was passing it to the compiler, not the linker. CMake doesn't have a linker test, so we have a hand-rolled one.

Original Patch Review: http://reviews.llvm.org/D16896

Original Summary:
With this change generating clang order files using dtrace uses the following workflow:

cmake <whatever options you want>

ninja generate-order-file

ninja clang

This patch works by setting a default path to the order file (which can be overridden by the user). If the order file doesn't exist during configuration CMake will create an empty one.

CMake then ties up the dependencies between the clang link job and the order file, and generate-order-file overwrites CLANG_ORDER_FILE with the new order file.

Reviewers: bogner

Subscribers: cfe-commits

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

llvm-svn: 260742
2016-02-12 21:36:55 +00:00
Chris Bieneman 1e8d80e79c [CMake] Pass stage1 tools through to stage2 when building with LTO
This was originally a hacky if(APPLE) block. Now that we have an option for enabling LTO, it is better to properly gate this.

llvm-svn: 260707
2016-02-12 19:06:12 +00:00
Jonas Hahnfeld aae8374004 [CMake] Add option to switch default C++ stdlib
With this option one can optionally override the architecture dependent
default library to use if no -stdlib= is provided on compiler invocation.

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

llvm-svn: 260662
2016-02-12 07:48:37 +00:00
Chris Bieneman b33600fe6b [CMake] Pass LLVM_EXTERNAL_*_SOURCE_DIR variables to subsequent stages
For multi-stage builds we need to pass any overridden source directory variables. Without passing these the subsequent stages won't find the project sources.

llvm-svn: 260341
2016-02-10 01:09:59 +00:00
Chris Bieneman 06d29a2466 [CMake] One more try to make CMake clean up after itself
Seriously... CMake... You're on my list...

llvm-svn: 259873
2016-02-05 03:59:08 +00:00
Chris Bieneman dc76e70b2a Revert "[CMake] Improve the clang order-file generation workflow"
This reverts commit r259862, and attempts to fix builder CMakeCaches.

Will try this again some other time...

Conflicts:

	CMakeLists.txt
	tools/driver/CMakeLists.txt

llvm-svn: 259872
2016-02-05 03:40:37 +00:00
Chris Bieneman 16638f9a2c [CMake] One more try to fix this.
This change will catch any bots that generated the order file that GNU ld doesn't like and delete it before trying to generate one that I think GNU ld will deal with.

llvm-svn: 259871
2016-02-05 03:02:40 +00:00
Chris Bieneman 08d92de3f4 [CMake] Speculative fix for linker error on Linux
I can't reproduce this locally, but I think this may fix it.

llvm-svn: 259870
2016-02-05 02:51:33 +00:00
Chris Bieneman 1681091991 [CMake] Improve the clang order-file generation workflow
Summary:
With this change generating clang order files using dtrace uses the following workflow:

cmake <whatever options you want>

ninja generate-order-file

ninja clang

This patch works by setting a default path to the order file (which can be overridden by the user). If the order file doesn't exist during configuration CMake will create an empty one.

CMake then ties up the dependencies between the clang link job and the order file, and generate-order-file overwrites CLANG_ORDER_FILE with the new order file.

Reviewers: bogner

Subscribers: cfe-commits

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

llvm-svn: 259862
2016-02-05 01:22:03 +00:00
Niels Ole Salscheider 6ecf633f99 Install cmake files to lib/cmake/clang
This is the right location for platform-specific files.

Also, search for LLVM's CMake files in this directory.

llvm-svn: 259822
2016-02-04 20:08:27 +00:00
Chris Bieneman fe4a7b3ccd [CMake] Don't apply Export set to clang tools
I can't apply export to tools without getting some strange CMake spew. The behavior here is a bit unexpected. CMake is complaining about static link dependencies not being in the same export set, which shouldn't matter.

In the short term it is easier to just remove the export set (which was just added in r258209) while I sort this out.

llvm-svn: 258214
2016-01-19 23:01:38 +00:00
Chris Bieneman b6a296ca62 [CMake] Creating add_clang_tool macro to wrap add_clang_executable and generate install actions and targets.
This change brings forward the LLVM convention that "executables" are just runnable binaries, and "tools" are executables that are part of the project's install.

Having this abstraction will allow us to simplify some of the tool CMakeLists files, and it will standardize some of the install behaviors.

llvm-svn: 258209
2016-01-19 22:41:51 +00:00
Chris Bieneman fac5905e55 [CMake] Properly respect the CLANG_APPEND_VC_REV option
Only set -DSVN_REVISION if CLANG_APPEND_VC_REV=On

llvm-svn: 258143
2016-01-19 17:06:12 +00:00
Chris Bieneman 9c92d67b78 [CMake] Move the install logic for libclang's headers into the libclang CMakelists
This makes it so if you disable building libclang you won't install the headers as part of the 'install' target.

llvm-svn: 257828
2016-01-14 22:48:45 +00:00
Chris Bieneman 61266fc955 [CMake] Set SVN_REVISION if CLANG_APPEND_VC_REV=On
This matches autoconf's ability to put clang revisions in the clang --version spew.

llvm-svn: 257827
2016-01-14 22:45:12 +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 c146ea45f5 [CMake] Name the bootstrap stages stage[0-9]
When you start chaining bootstrap stages the CMake-generated targets get unwieldy. This change supports naming the bootstrap targets and creating wrapper targets in the top-level build file.

Without this patch the default target generated for a second stage build was "bootstrap" with it the target is "stage2".

Also with some CMake goop setting CLANG_BOOTSTRAP_TARGETS, you can expose third stage targets as "stage3" instead of "bootstrap-bootstrap"

llvm-svn: 255813
2015-12-16 20:17:07 +00:00
Chris Bieneman 5ac5d61b9c [CMake] If you're building compiler-rt, the bootstrap build should depend on it.
Adding optional dependency for the bootstrap targets on compiler-rt.

llvm-svn: 255801
2015-12-16 18:49:12 +00:00
Chris Bieneman 475f52c93f [CMake] Make CLANG_BOOTSTRAP_TARGETS overridable
This allows exposing a custom list of targets from the next stage build up.

llvm-svn: 255799
2015-12-16 18:45:53 +00:00
Chris Bieneman ae5433907a [CMake] Add support for generating profdata for clang from training files
Summary:
This patch adds support for using LIT to drive generating PGO profile data for clang.

This first pass implementation should work on Linux and Unix based platforms. If you build clang using CMake with LLVM_BUILD_INSTRUMENTED=On the CMake build generates a generate-profdata target that will use the just-built clang to build any test files (see hello_world.cpp as an example). Each test compile will generate profraw files for each clang process. After all tests have run CMake will merge the profraw files using llvm-profdata.

Future opportunities for extension:
* Support for Build->Profile->Build bootstrapping
* Support for linker order file generation using a similar mechanism and the same training data
* Support for Windows

Reviewers: dexonsmith, friss, bogner, cmatthews, vsk, silvas

Subscribers: cfe-commits

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

llvm-svn: 255740
2015-12-16 01:02:44 +00:00
Alexey Bataev 897451d372 [OPENMP] Make -fopenmp to turn on OpenMP support by default, clang part
Patch turns on OpenMP support in clang by default after fixing OpenMP buildbots.
Differential Revision: http://reviews.llvm.org/D13803

llvm-svn: 255223
2015-12-10 05:47:10 +00:00
Chris Bieneman ae88ac200d NFC. Fixing my consistently incorrect spelling.
llvm-svn: 253937
2015-11-23 23:34:13 +00:00
Chris Bieneman 8638714dc7 [CMake] Add support for specifying arguments to the bootstrap build.
This adds support for three types of argument specifications for bootstrap builds:

(1) Arguments prefixed with BOOTSTRAP_* will be passed through with the leading BOOTSTRAP_ removed.
(2) CLANG_BOOTSTRAP_PASSTHROUGH can specify a list of variables to be passed through as they are set.
(3) BOOTSTRAP_DEFAULT_PASSTHROUGH is a list of some default passthrough variables that are always passed through. Those variables include the version string and should only specify variables that are always expected to be the same between the stage1 and stage2

llvm-svn: 253721
2015-11-20 22:09:06 +00:00
Argyrios Kyrtzidis 2cab8eec74 [CMake] If 'INTERNAL_INSTALL_PREFIX' is set, use it for determining the install destination of c-index-test and the libclang headers.
llvm-svn: 253001
2015-11-13 01:46:18 +00:00
Argyrios Kyrtzidis e053d44309 [CMake] Setup an install component for libclang and c-index-test.
Also don't create libclang dylib symlinks on darwin.

llvm-svn: 252836
2015-11-12 00:46:57 +00:00
Chris Bieneman 4e3b36947b [CMake] Support passing CMAKE_VERBOSE_MAKEFILE through to bootstrap builds.
This option enables full verbosity in recursive CMake builds.

llvm-svn: 252523
2015-11-09 22:43:10 +00:00
Chris Bieneman 0eb2d8794e [CMake] Make clang/tools subdirectories controlled via options
Setting CLANG_TOOL_*_BUILD=Off on the CMake command line will disable inclusion of a clang/tools subdirectory.

llvm-svn: 250840
2015-10-20 18:12:12 +00:00
NAKAMURA Takumi 6ae5084f90 [CMake] Always generate and install cmake config files on CMake>=3.0.
Currently, cmake config files are only generated and installed when CLANG_BUILD_STANDALONE set, which means config file will not be generated or installed when clang is built with llvm. This change removes that restriction.

Thanks to Don Hinton <hintonda@gmail.com>

http://reviews.llvm.org/D13453

llvm-svn: 249935
2015-10-10 02:37:30 +00:00
Chris Bieneman 8c2abff17e [CMake] Fixing LTO library path passed into bootstrap builds.
This just fixes a small error in constructing the path to the LTO library.

llvm-svn: 249858
2015-10-09 17:45:44 +00:00
NAKAMURA Takumi 72e03fd917 [CMake] Move CLANG_INCLUDE_TESTS in advance of add_subdirectory(tools).
The target "check-clang-tools" is affected by CLANG_INCLUDE_TESTS but it was undefined in 1st configuration procedure.

llvm-svn: 249283
2015-10-05 02:04:49 +00:00
Chris Bieneman fdbbd25d0d [CMake] Fixing clang bootstrap to use LLVM_RUNTIME_OUTPUT_INTDIR instead of CMAKE_BINARY_DIR.
This should make bootstrap builds work with multi-configuration generators.

llvm-svn: 249115
2015-10-02 00:56:53 +00:00
Chris Bieneman cd53780cd4 [CMake] Refactoring and cleaning up clang symlink generation.
Generation of clang symlinks now uses add_clang_symlink macro which uses add_llvm_symlink. Also the list of symlinks to generate is configurable via CLANG_LINKS_TO_CREATE.

This re-lands r248015, with fixes for clang symlinks to always be generated as part of the clang and install-clang targets.

llvm-svn: 248043
2015-09-18 21:15:54 +00:00
Chris Bieneman f41fe8b6f8 Revert "[CMake] Refactoring and cleaning up clang symlink generation."
This reverts commit r248015, because it broke bots. I'll revise and recommit.

llvm-svn: 248025
2015-09-18 19:59:51 +00:00
Chris Bieneman 8a1030db9f [CMake] Refactoring and cleaning up clang symlink generation.
Generation of clang symlinks now uses add_clang_symlink macro which uses add_llvm_symlink. Also the list of symlinks to generate is configurable via CLANG_LINKS_TO_CREATE.

llvm-svn: 248015
2015-09-18 18:09:15 +00:00
Chris Bieneman 744267765c [CMake] [Darwin] Add support for building bootstrap builds with -flto
When building with LTO the bootstrap builds need to depend on libLTO, llvm-ar, and llvm-ranlib, which all need to be passed into the bootstrap build. This functionality only works on Darwin.

llvm-svn: 247467
2015-09-11 20:42:57 +00:00
Chris Bieneman 7482709974 [CMake] Making the bootstrap-clear target always delete the boostrap build directories.
llvm-svn: 247436
2015-09-11 17:38:38 +00:00
NAKAMURA Takumi cbac61a780 [CMake][Standalone] Detect Python. Python is used for Lit testing.
llvm-svn: 245685
2015-08-21 09:38:46 +00:00
NAKAMURA Takumi cac8b2eb73 Untabify.
llvm-svn: 245684
2015-08-21 09:37:53 +00:00
Chris Bieneman 6511eb5194 [CMake] Simplifying logic for USES_TERMINAL on bootstrap targets.
In CMake variables that haven't been set are evaluated to empty strings, so we don't need to set the variables to empty strings.

llvm-svn: 245604
2015-08-20 20:12:20 +00:00
Chris Bieneman eb0e518923 [CMake] Exclude 'bootstrap' target from 'all' where possible.
EXCLUDE_FROM_ALL in ExternalProject is only available on CMake 3.1 and later.

llvm-svn: 245603
2015-08-20 20:12:18 +00:00
Chris Bieneman c5635a6af7 We shouldn't need to pass -fno-strict-aliasing when building clang with clang.
Summary: The code comments in the Makefile indicate this was put in place to support issues when building clang with GCC. Today clang's strict aliasing works, so we shouldn't pass -fno-strict-aliasing when building with clang.

Reviewers: bogner, echristo

Subscribers: cfe-commits

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

llvm-svn: 245304
2015-08-18 16:15:44 +00:00
Aaron Ballman 3349f89974 The version of libxml2 required by c-index-test must be at least 2.5.3. Considering that this version was released in 2003, you might think the check a bit ridiculous. Unfortunately, GnuWin32 ships with libxml2 2.4.12, which was released in 2001.
This allows us to have GnuWin32 on the PATH on Windows without causing compilation errors.

llvm-svn: 244751
2015-08-12 15:01:15 +00:00
Chris Bieneman 936ff96fae [CMake] Add USES_TERMINAL 1 to ExternalProject_Add_Step calls on 3.3.20150708 and later.
llvm-svn: 244119
2015-08-05 20:46:39 +00:00
Chris Bieneman f2a00e9d2a [CMake] First pass at adding support for clang bootstrap builds to CMake
Summary:
This patch adds a new CLANG_ENABLE_BOOTSTRAP option to CMake which adds targets for building a stage2 bootstrap compiler. The targets are:

bootstrap-configure
bootstrap-build
bootstrap (same as bootstrap-configure and bootstrap-build)
bootstrap-install
bootstrap-check-llvm
bootstrap-check-clang
bootstrap-check-all

If you are using 3.3.20150708 or greater it utilizes the ninja USES_TERMINAL_* settings on the external project so that the output is properly buffered.

Reviewers: bogner, chandlerc

Subscribers: filcab, cfe-commits

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

llvm-svn: 244070
2015-08-05 17:38:12 +00:00
Greg Bedwell 141e8bdfc2 Use Clang version numbers for the Windows VERSIONINFO resource.
When setting the VERSIONINFO resource to embed version information into exe and
DLL files on Windows, override the default LLVM version number values with their
clang equivalents.

llvm-svn: 239617
2015-06-12 16:33:38 +00:00
NAKAMURA Takumi 2d0913cd8d clang/CMakeLists.txt: s/LLVM_INSTALL_PACKAGE_DIR/CLANG_INSTALL_PACKAGE_DIR/ for the standalone configuration.
llvm-svn: 238628
2015-05-29 22:58:05 +00:00
Chris Bieneman 8eb2fc8c4a [CMake] Bug 19462 - Use the INSTALL(EXPORT ...) to export CMake definitions
Summary: This patch moves all the clang library targets into a ClangTargets export list, and installs it using the CMake install(EXPORT...) command.

Reviewers: rnk

Reviewed By: rnk

Subscribers: cfe-commits

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

llvm-svn: 238593
2015-05-29 18:36:20 +00:00
Chandler Carruth 9c6b4f8528 [omp] Re-work Clang's handling of -fopenmp and undo r237769.
This isn't an actual revert of r237769, it just restores the behavior of
the Clang driver prior to it while completely re-implementing how that
behavior works.

This also re-does the work of making the default OpenMP runtime
selectable at CMake (or configure) time to work in the way all of our
other such hooks do (config.h, configure and cmake hooks, etc.).

I've re-implemented how we manage the '-fopenmp' flagset in an important
way. Now, the "default" hook just makes '-fopenmp' equivalent to
'-fopenmp=<default>' rather than a separate special beast. Also, there
is an '-fno-openmp' flag which does the obvious thing. Also, the code is
shared between all the places to select a known OpenMP runtime and act
on it.

Finally, and most significantly, I've taught the driver to inspect the
selected runtime when choosing whether to propagate the '-fopenmp' flag
to the frontend in the CC1 commandline. Without this, it isn't possible
to use Clang with libgomp, even if you were happy with the serial,
boring way in which it worked previously (ignoring all #pragmas but
linking in the library to satisfy direct calls into the runtime).

While I'm here, I've gone ahead and sketched out a path for the future
name of LLVM's OpenMP runtime (libomp) and the legacy support for its
current name (libiomp5) in what seems a more reasonable way.

To re-enable LLVM's OpenMP runtime (which I think should wait until the
normal getting started instructions are a reasonable way for falks to
check out, build, and install Clang with the runtime) all that needs to
change is the default string in the CMakeLists.txt and configure.ac
file. No code changes necessary.

I also added a test for the driver's behavior around OpenMP since it was
*completely missing* previously. Makes it unsurprising that we got it
wrong.

llvm-svn: 238389
2015-05-28 01:52:38 +00:00
Richard Smith 31d1de2229 [OpenMP] Make default OpenMP library (the one selected with just -fopenmp)
configurable in the CMake build. There shouldn't be any change in default
behavior.

Derived from a patch by Daniel Jasper!

llvm-svn: 237850
2015-05-20 22:48:44 +00:00
Chris Bieneman c3e44c2284 [cmake] Clang's install should install clang/Config/config.h
llvm-svn: 233016
2015-03-23 20:43:21 +00:00
NAKAMURA Takumi b0f54e7909 clang/CMakeLists.txt: Introduce LLVM_SHLIB_OUTPUT_INTDIR also here, or plugins tests might fail.
llvm-svn: 225170
2015-01-05 14:06:14 +00:00
Chandler Carruth fd3cc70ed4 [multilib] Teach Clang's code about multilib by threading
a CLANG_LIBDIR_SUFFIX down from the build system and using that as part
of the default resource dir computation.

Without this, essentially nothing that uses the clang driver works when
building clang with a libdir suffix. This is probably the single biggest
missing piece of support for multilib as without this people could hack
clang to end up installed in the correct location, but it would then
fail to find its own basic resources. I know of at least one distro that
has some variation on this patch to hack around this; hopefully they'll
be able to use the libdir suffix functionality directly as the rest of
these bits land.

This required fixing a copy of the code to compute Clang's resource
directory that is buried inside of the frontend (!!!). It had bitrotted
significantly relative to the driver code. I've made it essentially
a clone of the driver code in order to keep tests (which use cc1
heavily) passing. This copy should probably just be removed and the
frontend taught to always rely on an explicit resource directory from
the driver, but that is a much more invasive change for another day.

I've also updated one test which actually encoded the resource directory
in its checked output to tolerate multilib suffixes.

Note that this relies on a prior LLVM commit to add a stub to the
autoconf build system for this variable.

llvm-svn: 224924
2014-12-29 12:09:08 +00:00
Chandler Carruth 91663e55f6 [cmake] Teach the Clang CMake build to use LLVM_LIBDIR_SUFFIX for its
'lib' directories in the build. This variable is available now both as
part of the normal LLVM build an as part of a standalone build as I've
added it to the LLVMConfig.cmake output.

With this change we should at least put libraries into the multilib
directory correctly. It is the first step in getting Clang to be
reasonably multilib aware.

llvm-svn: 224923
2014-12-29 12:09:03 +00:00
Hans Wennborg cbef69511c CMake: try to actually fix the regexes for setting HOST_LINK_VERSION this time (PR21268)
The regex should not accept an empty version number.

The previous attempt at r223106 failed, and the build was still erroring:

  CMake Error at tools/clang/CMakeLists.txt:269 (string):
    string sub-command REGEX, mode REPLACE regex "[^0-9]*([0-9.]*).*" matched
    an empty string.

llvm-svn: 223333
2014-12-04 01:59:58 +00:00
Hans Wennborg 76abe8ef98 CMake: make the regexes used for setting HOST_LINK_VERSION more forgiving (PR21268)
If the output of 'ld -v' didn't match the regexes, CMake would previously error
with a message like:

  CMake Error at tools/clang/CMakeLists.txt:269 (string):
    string sub-command REGEX, mode REPLACE regex "[^0-9]*([0-9.]*).*" matched
    an empty string.

llvm-svn: 223106
2014-12-02 03:08:38 +00:00
Roman Divacky 09e4972a37 Remove -Wcast-qual as it's inherited from llvm since r221913.
llvm-svn: 221914
2014-11-13 19:47:31 +00:00