Commit Graph

404 Commits

Author SHA1 Message Date
Sinan Lin 73593145cb [cmake] do not set execution permission to regular files.
some regular files(e.g. files have no shebang and no execute
bit in source dir) are wrongly assigned an execution permission,
such as scanview.css and ear.c from libscanbuild, which is
unnecessary and introduces warnings in some envs.

Reviewed By: MaskRay, phosek

Differential Revision: https://reviews.llvm.org/D133308
2022-09-07 11:04:12 +08:00
Nikita Popov c04eab8c78 [Flang] Use find_program() to find clang-tblgen
There are two scenarios here:

1. Standalone flang build, where we use an installed clang-tblgen
   binary. We need to use find_package() to find it.
2. Combined build of clang and flang, where we want to use the
   path specified in CLANG_TABLEGEN_EXE during the clang build --
   however, this variable was previously not exported.

The new implementation matches what is done for mlir-tblgen.

Differential Revision: https://reviews.llvm.org/D131475
2022-08-29 11:09:25 +02:00
H. Vetinari 0f28d48566
SONAME introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION
This reverts commit bc39d7bdd4.

rename CLANG_SONAME to LIBCLANG_SOVERSION

[clang][cmake] introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION

Differential Revision: https://reviews.llvm.org/D132486
2022-08-25 08:36:01 +02:00
Carlos Alberto Enciso 6c6c4f6a9b [CMake] Support passing arguments to build tool (bootstrap).
For bootstrap builds (CLANG_ENABLE_BOOTSTRAP=ON) allow
arguments to be passed to the native tool used in CMake
for the stage2 step.

Can be used to pass extra arguments for enhanced versions
of build tools, e.g. distributed build options.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D131665
2022-08-23 05:45:25 +01:00
John Ericson 3adda398ce [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro
Use this instead of `*_LIBDIR_SUFFIX`, from which it is computed.

This gets us ready for D130586, in which `*_LIBDIR_SUFFIX` is
deprecated.

Differential Revision: https://reviews.llvm.org/D132300
2022-08-20 12:52:21 -04:00
John Ericson e941b031d3 Revert "[cmake] Use `CMAKE_INSTALL_LIBDIR` too"
This reverts commit f7a33090a9.

Unfortunately this causes a number of failures that didn't show up in my
local build.
2022-08-18 22:46:32 -04:00
John Ericson f7a33090a9 [cmake] Use `CMAKE_INSTALL_LIBDIR` too
We held off on this before as `LLVM_LIBDIR_SUFFIX` conflicted with it.
Now we return this.

`LLVM_LIBDIR_SUFFIX` is kept as a deprecated way to set
`CMAKE_INSTALL_LIBDIR`. The other `*_LIBDIR_SUFFIX` are just removed
entirely.

I imagine this is too potentially-breaking to make LLVM 15. That's fine.
I have a more minimal version of this in the disto (NixOS) patches for
LLVM 15 (like previous versions). This more expansive version I will
test harder after the release is cut.

Reviewed By: sebastian-ne, ldionne, #libc, #libc_abi

Differential Revision: https://reviews.llvm.org/D130586
2022-08-18 15:33:35 -04:00
Carlos Alberto Enciso 177cbb1c9b [CMake] Explicit bootstrap options override any passthrough ones.
The https://reviews.llvm.org/D53014 added CMAKE_BUILD_TYPE to
the list of BOOTSTRAP_DEFAULT_PASSTHROUGH variables.

The downside is that both stage-1 and stage-2 configurations
are the same. So it is not possible to build different stage
configurations.

This patch allow explicit bootstrap options to override any
passthrough ones.

For instance, the following settings would build:
  stage-1 (Release) and stage-2(Debug)

-DCMAKE_BUILD_TYPE=Release -DBOOTSTRAP_CMAKE_BUILD_TYPE=Debug

Reviewed By: @beanz

Differential Revision: https://reviews.llvm.org/D131755
2022-08-17 08:16:10 +01:00
Tom Stellard d2b158e29e clang/cmake: Drop use of llvm-config for LLVM install discovery
This has been deprecated for a while, since D51714 in 2018.

Remove it in favor of using CMake's find_package() function.

Reviewed By: phosek, mgorny

Differential Revision: https://reviews.llvm.org/D128777
2022-08-06 16:22:59 -04:00
Tobias Hieta b1356504e6
[LLVM] Update C++ standard to 17
Also make the soft toolchain requirements hard. This allows
us to use C++17 features in LLVM now.

If we find patterns with C++17 that improve readability
it should be recommended in the coding standards.

Reviewed By: jhenderson, cor3ntin, MaskRay

Differential Revision: https://reviews.llvm.org/D130689
2022-08-06 09:42:10 +02:00
Sunho Kim a8f2e24e48 [clang-repl] Disable building when LLVM_STATIC_LINK_CXX_STDLIB is ON.
We have seen random symbol not found "__cxa_throw" error in fuschia build bots and out-of-tree users. The understanding have been that they are built without exception support, but it turned out that these platforms have LLVM_STATIC_LINK_CXX_STDLIB ON so that they link libstdc++ to llvm statically. The reason why this is problematic for clang-repl is that by default clang-repl tries to find symbols from symbol table of executable and dynamic libraries loaded by current process. It needs to load another libstdc++, but the platform that had LLVM_STATIC_LINK_CXX_STDLIB turned on is usally those with missing or obsolate shared libstdc++ in the first place -- trying to load it again would be destined to fail eventually with a risk to introuduce mixed libstdc++ versions.

A proper solution that doesn't take a workaround is statically link the same libstdc++ by clang-repl side, but this is not possible with old JIT linker runtimedyld. New just-in-time linker JITLink handles this relatively well, but it's not availalbe in majority of platforms. For now, this patch just disables the building of clang-repl when LLVM_STATIC_LINK_CXX_STDLIB is ON and removes the "__cxa_throw" check in exception unittest as well as reverting previous exception check flag patch.

Reviewed By: v.g.vassilev

Differential Revision: https://reviews.llvm.org/D130788
2022-07-31 05:42:57 +09:00
John Ericson cc56a5022c [clang][lld][cmake] Simplify header dirs
We don't need to recompute the list LLVMConfig.cmake provides us.

When LLVM is being built, the list is two elements long: generated headers and headers from source.

When LLVM is already built,the list is one element long: the installed header directory containing both generated and hand-written sources.

Reviewed By: sebastian-ne

Differential Revision: https://reviews.llvm.org/D130553
2022-07-28 19:36:40 -04:00
John Ericson 07b749800c [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore
First of all, `LLVM_TOOLS_INSTALL_DIR` put there breaks our NixOS
builds, because `LLVM_TOOLS_INSTALL_DIR` defined the same as
`CMAKE_INSTALL_BINDIR` becomes an *absolute* path, and then when
downstream projects try to install there too this breaks because our
builds always install to fresh directories for isolation's sake.

Second of all, note that `LLVM_TOOLS_INSTALL_DIR` stands out against the
other specially crafted `LLVM_CONFIG_*` variables substituted in
`llvm/cmake/modules/LLVMConfig.cmake.in`.

@beanz added it in d0e1c2a550 to fix a
dangling reference in `AddLLVM`, but I am suspicious of how this
variable doesn't follow the pattern.

Those other ones are carefully made to be build-time vs install-time
variables depending on which `LLVMConfig.cmake` is being generated, are
carefully made relative as appropriate, etc. etc. For my NixOS use-case
they are also fine because they are never used as downstream install
variables, only for reading not writing.

To avoid the problems I face, and restore symmetry, I deleted the
exported and arranged to have many `${project}_TOOLS_INSTALL_DIR`s.
`AddLLVM` now instead expects each project to define its own, and they
do so based on `CMAKE_INSTALL_BINDIR`. `LLVMConfig` still exports
`LLVM_TOOLS_BINARY_DIR` which is the location for the tools defined in
the usual way, matching the other remaining exported variables.

For the `AddLLVM` changes, I tried to copy the existing pattern of
internal vs non-internal or for LLVM vs for downstream function/macro
names, but it would good to confirm I did that correctly.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D117977
2022-07-21 19:04:00 +00:00
John Ericson 0bb317b7bf Revert "[cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore"
This reverts commit d5daa5c5b0.
2022-06-10 19:26:12 +00:00
John Ericson d5daa5c5b0 [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore
First of all, `LLVM_TOOLS_INSTALL_DIR` put there breaks our NixOS
builds, because `LLVM_TOOLS_INSTALL_DIR` defined the same as
`CMAKE_INSTALL_BINDIR` becomes an *absolute* path, and then when
downstream projects try to install there too this breaks because our
builds always install to fresh directories for isolation's sake.

Second of all, note that `LLVM_TOOLS_INSTALL_DIR` stands out against the
other specially crafted `LLVM_CONFIG_*` variables substituted in
`llvm/cmake/modules/LLVMConfig.cmake.in`.

@beanz added it in d0e1c2a550 to fix a
dangling reference in `AddLLVM`, but I am suspicious of how this
variable doesn't follow the pattern.

Those other ones are carefully made to be build-time vs install-time
variables depending on which `LLVMConfig.cmake` is being generated, are
carefully made relative as appropriate, etc. etc. For my NixOS use-case
they are also fine because they are never used as downstream install
variables, only for reading not writing.

To avoid the problems I face, and restore symmetry, I deleted the
exported and arranged to have many `${project}_TOOLS_INSTALL_DIR`s.
`AddLLVM` now instead expects each project to define its own, and they
do so based on `CMAKE_INSTALL_BINDIR`. `LLVMConfig` still exports
`LLVM_TOOLS_BINARY_DIR` which is the location for the tools defined in
the usual way, matching the other remaining exported variables.

For the `AddLLVM` changes, I tried to copy the existing pattern of
internal vs non-internal or for LLVM vs for downstream function/macro
names, but it would good to confirm I did that correctly.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D117977
2022-06-10 14:35:18 +00:00
Sam McCall 7cc8377f2c Generalize "check-all" umbrella targets, use for check-clang-tools
The mechanism behind "check-all" is recording params of add_lit_testsuite()
calls in global variables LLVM_LIT_*, and then creating an extra suite with
their union at the end.
This avoids composing the check-* targets directly, which doesn't work well.

We generalize this by allowing multiple families of variables LLVM_{name}_LIT_*:
  umbrella_lit_testsuite_begin(check-foo)
  ... test suites here will be added to LLVM_FOO_LIT_* variables ...
  umbrella_lit_testsuite_end(check-foo)
(This also moves some implementation muck out of {llvm,clang}/CMakeLists.txt

This patch also changes check-clang-tools to use be an umbrella test target,
which means the clangd and clang-pseudo tests are included in it, along with the
the other testsuites that already are (like check-clang-extra-clang-tidy).

Differential Revision: https://reviews.llvm.org/D121838
2022-05-06 12:30:49 +02:00
Nikita Popov 702d5de438 [Clang] Enable opaque pointers by default
Enable opaque pointers by default in clang, which can be disabled
either via cc1 option -no-opaque-pointers or cmake flag
-DCLANG_ENABLE_OPAQUE_POINTERS=OFF.

See https://llvm.org/docs/OpaquePointers.html for context.

Differential Revision: https://reviews.llvm.org/D123300
2022-04-11 11:13:45 +02:00
Fangrui Song ca68038d12 Reland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON""
(With C++ exceptions, `clang++ --target=mips64{,el}-linux-gnu -fpie -pie
-fuse-ld=lld` has link errors (lld does not implement some strange R_MIPS_64
.eh_frame handling in GNU ld). However, sanitizer-x86_64-linux-qemu used this to
build ScudoUnitTests. Pined ScudoUnitTests to -no-pie.)

Default the option introduced in D113372 to ON to match all(?) major Linux
distros. This matches GCC and improves consistency with Android and linux-musl
which always default to PIE.
Note: CLANG_DEFAULT_PIE_ON_LINUX may be removed in the future.

Differential Revision: https://reviews.llvm.org/D120305
2022-04-08 23:40:18 -07:00
Nico Weber e22a60b1c8 Revert "Reland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON"""
This reverts commit 2aca33baf1.
Broke tests on several bots, see comments on https://reviews.llvm.org/D120305
2022-04-07 10:07:07 -04:00
Nikita Popov 5390606aa9 [OpaquePtr][Clang] Add CLANG_ENABLE_OPAQUE_POINTERS cmake option
This option controls whether -opaque-pointers or -no-opaque-pointers
is the default. Once opaque pointers are enabled by default, this
will provide a simple way to temporarily opt-out of the change.

Differential Revision: https://reviews.llvm.org/D123122
2022-04-07 10:14:56 +02:00
Fangrui Song 2aca33baf1 Reland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON""
(The upgrade of the ppc64le bot and D121257 have fixed compiler-rt failures. Tested by nemanjai.)

Default the option introduced in D113372 to ON to match all(?) major Linux
distros. This matches GCC and improves consistency with Android and linux-musl
which always default to PIE.
Note: CLANG_DEFAULT_PIE_ON_LINUX may be removed in the future.

Differential Revision: https://reviews.llvm.org/D120305
2022-04-06 20:19:07 -07:00
Petr Hosek c624cc2527 [CMake][Clang] Skip host link version detection for lld on Darwin
When lld is being used as host linker, skip version detection since
lld version cannot be used interchangeably with ld64 version and lld
is already handled specially in Clang driver.

Differential Revision: https://reviews.llvm.org/D122109
2022-03-21 18:32:03 -07:00
Nikita Popov 8dcb5e6bf5 Revert "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON"
See post-commit discussion on https://reviews.llvm.org/D120305.
This change breaks the clang-ppc64le-rhel buildbot, though
there is suspicion that it's an issue with the bot. The change
also had a larger than expected impact on compile-time and
code-size.

This reverts commit 3c4ed02698
and some followup changes.
2022-02-26 15:32:49 +01:00
Fangrui Song 3c4ed02698 [Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON
Default the option introduced in D113372 to ON to match all(?) major Linux
distros. This matches GCC and improves consistency with Android and linux-musl
which always default to PIE.
Note: CLANG_DEFAULT_PIE_ON_LINUX will be removed in the future.

Reviewed By: thesamesam

Differential Revision: https://reviews.llvm.org/D120305
2022-02-25 00:22:12 +00:00
Jameson Nash 9d59cfc67e clang-analyzer plugins require LLVM_ENABLE_PLUGINS also
The clang-analyzer plugins are not linked to a particular tool, so they
can only be compiled if plugins are broadly supported. We could opt
instead to decide whether to link them to specifically against clang or
with undefined symbols, depending on the value of LLVM_ENABLE_PLUGINS,
but we do not currently expect there to be a use case for that rather
niche configuration.

Differential Revision: https://reviews.llvm.org/D119591
2022-02-16 11:59:09 -05:00
Jameson Nash 76cad51ba7 replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in tests
Ensure CLANG_PLUGIN_SUPPORT is compatible with llvm_add_library.
Fixes an issue noted in D111100.

Differential Revision: https://reviews.llvm.org/D119199
2022-02-09 17:31:34 -05:00
John Ericson e0eeae9a44 [lld][clang][cmake] Clean up a few things
- If not using `llvm-config`, `LLVM_MAIN_SRC_DIR` now has a sane default

- `LLVM_CONFIG_PATH` will continue to work for LLD for back compat.

- More quoting of paths in an abundance of caution.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D118792
2022-02-03 20:01:28 +00:00
Qiu Chaofan b797d5e6b2 [CMake] [Clang] Add option to specify PowerPC long double format
This method introduces new CMake variable
PPC_LINUX_DEFAULT_IEEELONGDOUBLE (false by default) to enable fp128 as
default long double format.

Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D118110
2022-01-27 00:50:53 +08:00
John Ericson 10d0d8c0c1 [clang][cmake] Use `GNUInstallDirs` to support custom installation dirs
I am breaking apart D99484 so the cause of build failures is easier to
understand.

Differential Revision: https://reviews.llvm.org/D117419
2022-01-21 23:58:08 +00:00
John Ericson da77db58d7 Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs."
https://lab.llvm.org/buildbot/#/builders/46/builds/21146 Still have
this odd error, not sure how to reproduce, so I will just try breaking
up my patch.

This reverts commit 4a678f8072.
2022-01-16 05:48:30 +00:00
John Ericson 4a678f8072 [cmake] Use `GNUInstallDirs` to support custom installation dirs.
This is the original patch in my GNUInstallDirs series, now last to merge as the final piece!

It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up

 - Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested.

 - Converting all the packages, not just LLVM, effecting many more projects than LLVM itself.

I figured it was time to make a new revision.

I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful.

---

As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`.

These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder.

Reviewed By: #libunwind, #libc, #libc_abi, compnerd

Differential Revision: https://reviews.llvm.org/D99484
2022-01-16 05:33:07 +00:00
John Ericson 6e52bfe09d Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs."
Sorry for the disruption, I will try again later.

This reverts commit efeb501970.
2022-01-15 07:35:02 +00:00
John Ericson efeb501970 [cmake] Use `GNUInstallDirs` to support custom installation dirs.
This is the original patch in my GNUInstallDirs series, now last to merge as the final piece!

It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up

 - Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested.

 - Converting all the packages, not just LLVM, effecting many more projects than LLVM itself.

I figured it was time to make a new revision.

I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful.

---

As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`.

These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder.

Reviewed By: #libunwind, #libc, #libc_abi, compnerd

Differential Revision: https://reviews.llvm.org/D99484
2022-01-15 01:08:35 +00:00
John Ericson 44e3365775 [CMake] Factor out config prefix finding logic
See the docs in the new function for details.

 I think I found every instance of this copy pasted code. Polly could
 also use it, but currently does something different, so I will save the
 behavior change for a future revision.

We get the shared, non-installed CMake modules following the pattern
established in D116472.

It might be good to have LLD and Flang also use this, but that would be
a functional change and so I leave it as future work.

Reviewed By: beanz, lebedev.ri

Differential Revision: https://reviews.llvm.org/D116521
2022-01-07 20:16:18 +00:00
John Ericson a3ab2c94a2 [clang][cmake] Rearrange top-level CMakeLists.txt for D116492
In that revision, I make LLD match Clang in deprecating `llvm-config`.
This patch isn't to worthwhile on its own --- there isn't a sense in
which the new order is "better" in isolation --- but by putting the
steps that LLD also neeeds to do first, I make the diff between LLD and
Clang's top-level `CMakeLists.txt` very legible.

Longer term I hope:

 1. We can remove calling `llvm-config` altogether, and just go strait to
    finding the CMake config file. This is what Flang does, at least.

 2. Hopefully the diffable part is smaller then --- i.e. there is less
    duplicated boilerplate.

 3. Any duplicate boilerplate that remains can be factored out.

I didn't both trying to factor anything out in e.g. the top level common
CMake Utility modules because this deprecated-but-not-removed state is a
merely transitional.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D116548
2022-01-03 18:28:34 +00:00
Fangrui Song b5d3bbcc94 [CMake] Remove unneeded CLANG_DEFAULT_PIE_ON_LINUX canonicalization after D115751 2021-12-28 10:49:52 -08:00
Fangrui Song 1042de9058 [Driver] Add CLANG_DEFAULT_PIE_ON_LINUX to emulate GCC --enable-default-pie
In 2015-05, GCC added the configure option `--enable-default-pie`. When enabled,

* in the absence of -fno-pic/-fpie/-fpic (and their upper-case variants), -fPIE is the default.
* in the absence of -no-pie/-pie/-shared/-static/-static-pie, -pie is the default.

This has been adopted by all(?) major distros.

I think default PIE is the majority in the Linux world, but
--disable-default-pie users is not that uncommon because GCC upstream hasn't
switched the default yet (https://gcc.gnu.org/PR103398).

This patch add CLANG_DEFAULT_PIE_ON_LINUX which allows distros to use default PIE.
The option is justified as its adoption can be very high among Linux distros
to make Clang default match GCC, and is likely a future-new-default, at which
point we will remove CLANG_DEFAULT_PIE_ON_LINUX.
The lit feature `default-pie-on-linux` can be handy to exclude default PIE sensitive tests.

Reviewed By: foutrelis, sylvestre.ledru, thesamesam

Differential Revision: https://reviews.llvm.org/D113372
2021-12-14 10:09:00 -08:00
Nico Weber 3950e1be8d [clang] Remove CLANG_ROUND_TRIP_CC1_ARGS and always roundtrip in +assert builds
This removes the ability to disable roundtripping in assert builds.
(Roundtripping happens by default in assert builds both before and after
this patch.)

The CLANG_ROUND_TRIP_CC1_ARGS was added as an escape hatch 9 months ago
in https://reviews.llvm.org/D97462, with a FIXME to remove it eventually.
It's probably time to remove it.

Differential Revision: https://reviews.llvm.org/D114120
2021-11-18 08:31:21 -05:00
Frederic Cambus f0ffff43b7 [CMake] Fix typo in error message for LLD in bootstrap builds.
Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D110836
2021-10-06 22:38:12 +05:30
Petr Hosek d893692024 [CMake] Pass through CMAKE_READELF to subbuilds
This matches handling of other CMake variables.

Differential Revision: https://reviews.llvm.org/D110463
2021-09-24 18:20:30 -07:00
Sylvestre Ledru eccd477ce3 Add CMAKE_BUILD_TYPE to the list of BOOTSTRAP_DEFAULT_PASSTHROUGH variables
When building clang in stage2, when -DCMAKE_BUILD_TYPE=RelWithDebInfo is set,
the developer can expect that the stage2 clang is built using the same mode.
Especially as the performances are much worst in debug mode.
(Principle of least astonishment)

Differential Revision: https://reviews.llvm.org/D53014
2021-09-21 10:44:08 +02:00
Alfonso Gregory a2c319fdc6 [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project
This way, we do not need to set LLVM_CMAKE_PATH to LLVM_CMAKE_DIR when (NOT LLVM_CONFIG_FOUND)

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D107717
2021-09-16 18:29:57 +02:00
Jan Svoboda bb88a5aeee [clang][cli] Round-trip cc1 arguments in assert builds
This patch enables cc1 argument round-trip for assert builds. It can be disabled by building clang with `-DCLANG_ROUND_TRIP_CC1_ARGS=OFF`.

This will be committed only if we reach consensus in https://lists.llvm.org/pipermail/cfe-dev/2021-February/067714.html.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D97462
2021-03-27 17:24:03 +01:00
Shoaib Meenai 33930a0787 [clang] Pass option directly to command. NFC
This code was written back when LLVM's minimum required CMake version
was 2.8.8, and I assume ExternalProject_Add_Step didn't take this option
at that point. It does now though, so we should just use the option.
Setting the _EP_* property is entirely equivalent (and is in fact how
these commands behave internally), but that also feels like an internal
implementation detail we shouldn't be relying on.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D99322
2021-03-25 11:36:06 -07:00
Shoaib Meenai 0135bc996d [clang] Always execute multi-stage install steps
We want installs to be executed even if binaries haven't changed, e.g.
so that we can install to multiple places. This is consistent with how
non-multi-stage install targets (e.g. the regular install-distribution
target) behave.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D99321
2021-03-25 11:36:00 -07:00
Timm Bäder d9ef6bc426 [clang] Disable LTO and LLD on SystemZ for stage3 builds
LLD does not support SystemZ, so it doesn't make sense to use it for
boostrap/stage3 builds, and using LTO in these cases won't work.

Differential Revision: https://reviews.llvm.org/D89942
2021-03-17 15:15:41 +01:00
Markus Böck af2796c76d [test] Add ability to get error messages from CMake for errc substitution
Visual Studios implementation of the C++ Standard Library does not use strerror to produce a message for std::error_code unlike other standard libraries such as libstdc++ or libc++ that might be used.

This patch adds a cmake script that through running a C++ program gets the error messages for the POSIX error codes and passes them onto lit through an optional config parameter.

If the config parameter is not set, or getting the messages failed, due to say a cross compiling configuration without an emulator, it will fall back to using pythons strerror functions.

Differential Revision: https://reviews.llvm.org/D98278
2021-03-15 20:56:08 +01:00
Christopher Tetreault 39970764af [CMake] Require python 3.6 if enabling LLVM test targets
The lit test suite uses python 3.6 features. Rather than a strange
python syntax error upon running the lit tests, we will require the
correct version in CMake.

Reviewed By: serge-sans-paille, yln

Differential Revision: https://reviews.llvm.org/D95635
2021-03-15 09:50:39 -07:00
Martin Storsjö e81d813717 [clang] Don't set CLANG_DEFAULT_UNWINDLIB to none if rtlib is set to compiler-rt
002dd47bdd was meant to not be any
functional change, but it turned out it was.

With CLANG_DEFAULT_RTLIB set to compiler-rt, CLANG_DEFAULT_UNWINDLIB used
to bet set to an empty string, but now was set to "none".

If one only overrode rtlib to libgcc, one previously would get libgcc
as unwind lib, but now didn't. This caused test failures, fixed in
41476d89b8.

Secondly, for the android target, the previous default was to link
libunwind, which this now changed.

Reinstate the exact same behaviour as before (removing the previously
typoed cmake check) and fix the option comment in one place to match
the other one above.

Differential Revision: https://reviews.llvm.org/D98142
2021-03-08 22:29:54 +02:00
Martin Storsjö 002dd47bdd [clang] Fix typos in the default logic for CLANG_DEFAULT_UNWINDLIB
CLANG_DEFAULT_RTLIB had a typo, and libunwind isn't a valid
option for it.

This keeps the actual behaviour from before, defaulting to none if
using compiler-rt as rtlib.

Differential Revision: https://reviews.llvm.org/D98022
2021-03-06 08:50:46 +02:00