llvm-project/compiler-rt/cmake/Modules
John Ericson 1e03c37b97 Prepare Compiler-RT for GnuInstallDirs, matching libcxx, document all
This is a second attempt at D101497, which landed as
9a9bc76c0e but had to be reverted in
8cf7ddbdd4.

This issue was that in the case that `COMPILER_RT_INSTALL_PATH` is
empty, expressions like "${COMPILER_RT_INSTALL_PATH}/bin" evaluated to
"/bin" not "bin" as intended and as was originally.

One solution is to make `COMPILER_RT_INSTALL_PATH` always non-empty,
defaulting it to `CMAKE_INSTALL_PREFIX`. D99636 adopted that approach.
But, I think it is more ergonomic to allow those project-specific paths
to be relative the global ones. Also, making install paths absolute by
default inhibits the proper behavior of functions like
`GNUInstallDirs_get_absolute_install_dir` which make relative install
paths absolute in a more complicated way.

Given all this, I will define a function like the one asked for in
https://gitlab.kitware.com/cmake/cmake/-/issues/19568 (and needed for a
similar use-case).

---

Original message:

Instead of using `COMPILER_RT_INSTALL_PATH` through the CMake for
complier-rt, just use it to define variables for the subdirs which
themselves are used.

This preserves compatibility, but later on we might consider getting rid
of `COMPILER_RT_INSTALL_PATH` and just changing the defaults for the
subdir variables directly.

---

There was a seaming bug where the (non-Apple) per-target libdir was
`${target}` not `lib/${target}`. I suspect that has to do with the docs
on `COMPILER_RT_INSTALL_PATH` saying was the library dir when that's no
longer true, so I just went ahead and fixed it, allowing me to define
fewer and more sensible variables.

That last part should be the only behavior changes; everything else
should be a pure refactoring.

---

I added some documentation of these variables too. In particular, I
wanted to highlight the gotcha where `-DSomeCachePath=...` without the
`:PATH` will lead CMake to make the path absolute. See [1] for
discussion of the problem, and [2] for the brief official documentation
they added as a result.

[1]: https://cmake.org/pipermail/cmake/2015-March/060204.html

[2]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#options

In 38b2dec37e the problem was somewhat
misidentified and so `:STRING` was used, but `:PATH` is better as it
sets the correct type from the get-go.

---

D99484 is the main thrust of the `GnuInstallDirs` work. Once this lands,
it should be feasible to follow both of these up with a simple patch for
compiler-rt analogous to the one for libcxx.

Reviewed By: phosek, #libc_abi, #libunwind

Differential Revision: https://reviews.llvm.org/D105765
2021-07-13 15:21:41 +00:00
..
CustomLibcxx [runtimes] Use standalone build only for compiler-rt 2021-03-03 00:06:20 -08:00
AddCompilerRT.cmake Prepare Compiler-RT for GnuInstallDirs, matching libcxx, document all 2021-07-13 15:21:41 +00:00
BuiltinTests.cmake [cmake] Strip quotes in try_compile_only 2019-09-19 11:28:32 +00:00
CompilerRTAIXUtils.cmake [AIX][compiler-rt] Deliver libatomic.a at top level library directory 2021-06-29 03:14:20 +00:00
CompilerRTCompile.cmake [CMake] Rename RUNTIMES_BUILD to LLVM_RUNTIMES_BUILD 2021-03-03 10:58:51 -08:00
CompilerRTDarwinUtils.cmake Prepare Compiler-RT for GnuInstallDirs, matching libcxx, document all 2021-07-13 15:21:41 +00: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 Prepare Compiler-RT for GnuInstallDirs, matching libcxx, document all 2021-07-13 15:21:41 +00: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