llvm-project/compiler-rt/cmake/Modules
Dan Liew fd28517d87 [CMake][Compiler-rt] Make it possible to configure standalone compiler-rt without `LLVMConfig.cmake`.
Previously it wasn't possible to configure a standalone compiler-rt
build if the `LLVMConfig.cmake` file isn't present in a shipped
toolchain.

This patch adds a fallback behaviour for when `LLVMConfig.cmake` is not
available in the toolchain being used for configure. The fallback
behaviour mocks out the bare minimum required to make a configure
succeed when the host is Darwin. Support for other platforms could
be added in future patches.

The new code path is taken either in one of the following cases:

* `llvm-config` is not available.
* `llvm-config` is available but it provides an invalid path for the CMake files.

The motivation here is to be able to generate the compiler-rt lit test
suites for an arbitrary LLVM toolchain and then run the tests against
it.

The invocation to do this looks something like.

```
CC=/path/to/cc \
CXX=/path/to/c++ \
cmake \
  -G Ninja \
  -DLLVM_CONFIG_PATH=/path/to/llvm-config \
  -DCOMPILER_RT_INCLUDE_TESTS=ON \
  /path/to/llvm-project/compiler-rt

 # Note we don't compile compiler-rt in this workflow.
bin/llvm-lit -v test/path/to/generated/test_suite
```

A possible alternative approach is to configure the
`cmake/modules/LLVMConfig.cmake.in` file in the LLVM source tree
and then include it. This approach was not taken because it is more
complicated.

An interesting side benefit of this patch is that it is now
possible to configure on Darwin without `llvm-config` being available
by configuring with `-DLLVM_CONFIG_PATH=""`. This moves us a step
closer to a world where no LLVM build artefacts are required to
build compiler-rt.

rdar://76016632

Differential Revision: https://reviews.llvm.org/D99621
2021-04-06 08:31:18 -07:00
..
CustomLibcxx [runtimes] Use standalone build only for compiler-rt 2021-03-03 00:06:20 -08:00
AddCompilerRT.cmake [compiler-rt] Produce the right arch suffix for arm libraries 2021-03-18 14:58:58 +02:00
BuiltinTests.cmake [cmake] Strip quotes in try_compile_only 2019-09-19 11:28:32 +00:00
CompilerRTCompile.cmake [CMake] Rename RUNTIMES_BUILD to LLVM_RUNTIMES_BUILD 2021-03-03 10:58:51 -08:00
CompilerRTDarwinUtils.cmake Re-apply "[CMake][compiler-rt][AArch64] Avoid preprocessing LSE builtins separately" 2020-12-15 08:18:07 +02:00
CompilerRTLink.cmake
CompilerRTMockLLVMCMakeConfig.cmake [CMake][Compiler-rt] Make it possible to configure standalone compiler-rt without `LLVMConfig.cmake`. 2021-04-06 08:31:18 -07:00
CompilerRTUtils.cmake [CMake][Compiler-rt] Make it possible to configure standalone compiler-rt without `LLVMConfig.cmake`. 2021-04-06 08:31:18 -07:00
HandleCompilerRT.cmake [compiler-rt] Build with correct ABI (PR38025) 2020-04-03 11:53:40 -07:00
SanitizerUtils.cmake build: use Python3 for compiler-rt 2020-04-28 17:29:04 +00:00
UseLibtool.cmake [compiler-rt] Disable ranlib when using libtool 2020-08-24 13:48:28 -07:00