[llvm] [llvm][CMake] Introduce LLVM_RUNTIME_<project>_BUILD in CMake (PR #88934)

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 25 00:18:15 PDT 2024


petrhosek wrote:

> > It should be moved to `runtimes/CMakeLists.txt`, not `llvm/runtimes/CMakeLists.txt`.
> 
> Hm. When I do this, it does not seem that it is picked up and when adding a debugging message, CMake does not seem to go through `runtimes/CMakeList.txt`, but `llvm/runtimes/CMakeLists.txt` for a configuration like this:
> 
> ```
> cmake -DLLVM_ENABLE_PROJECTS="clang;flang;lld" -DLLVM_ENABLE_RUNTIMES="openmp" [...] ../llvm
> ```
> 
> So, if I correctly understand your explanation above, then I'm doing a bootstrapping build with the above command line. I have to use a command line like this to trigger the code in `runtimes/CMakefile.txt`:
> 
> ```
> cmake -DLLVM_ENABLE_RUNTIMES="openmp" [...] ../runtimes
> ```
> 
> So, a bootstrapping build simply configures the request to build a runtime via `llvm/runtimes/CMakeLists.txt` and then, when actually building, invokes CMake with a runtime build (using a command line like the 2nd one and C/C++ compiler set to Clang), which in turn triggers `runtime/CMakeLists.txt`? Is this thinking remotely correct?

Yes, your understanding is correct.

> Because then it would seem like code would need to be duplicated (or be moved to a CMake file that can be included in both `llvm/runtimes` and `runtimes`). Because only that would allow a bootstrapping build to detect that a particular has been requested to, say, enable a bunch of LIT tests. Or, alternatively, even have `LLVM_RUNTIME_<project>_BUILD` and `LLVM_BOOTSTRAP_<project>_BUILD` to distinguish the two variants of these builds to enable other parts of the CMake files to detect either one.

No, I don't think this is desirable. The reason is that the bootstrapping build also supports more advanced scenarios such as the following:

```
cmake -DLLVM_ENABLE_PROJECTS="clang;flang;lld" -DLLVM_RUNTIME_TARGETS="x86_64-linux-gnu;aarch64-linux-gnu" -DRUNTIMES_x86_64-linux-gnu_LLVM_ENABLE_RUNTIMES="libc" -DRUNTIMES_aarch64-linux-gnu_LLVM_ENABLE_RUNTIMES="openmp" [...] ../llvm
```

This would invoke the runtimes build once for requested target, so simply setting `LLVM_BOOTSTRAP_openmp_BUILD=ON` may be misleading; if your host platform is `x86_64-linux-gnu`, you still wouldn't want to run tests because although `openmp` was built, it was built for a different target.

Can you explain what the motivation behind introducing these variables is (and also ideally include it in the description of the PR)? I can try to think a better way we could address your needs but I need to understand the use case.

https://github.com/llvm/llvm-project/pull/88934


More information about the llvm-commits mailing list