Is the documentation for building the LLVM toolchain outdated?

I have been googling around and looking at the documentation in order to build clang and the entire toolchain.
This means all of the runtimes, clang, clang-tools-extra, lld, lldb, polly, bolt, etc.
(I was also building MLIR and the LLVM libraries as a friend and I are working on a toy project.)

However I am noticing some things don’t seem up to date. Like the LLVM_ENABLE_PROJECTS and RUNTIMES variables’ descriptions aren’t up to date. (The site where i find variable descriptions: Building LLVM with CMake — LLVM 20.0.0git documentation)
The PROJECTS variable desc. includes pstl, but the RUNTIMES variable desc. doesn’t, even though it is included in the runtimes/CMakeLists.txt file.
Not to mention that LLVM_ENABLE_PROJECTS doesn’t mention the bolt project, even though it will be built when choosing the all option.

I also had a problem with my build, where it froze after building runtimes, and a another Topic on this site, suggested it was because that user had libc in both LLVM_ENABLE_PROJECTS and LLVM_ENABLE_RUNTIMES. And I might have had the same issue but with pstl, because it was included when specifiying: LLVM_ENABLE_RUNTIMES=all. And I had it enabled in PROJECTS because It was not in the description of the RUNTIMES variable.

I am also noticing some vairables when using cmake -S llvm -LAH, not appearing on the list, although that might be because I’m not supposed to touch them.

But I’m worried that the documentation to build the LLVM Toolchain is partially wrong or outdated. Since my build has already failed 3 times. And it’s quite annoying not being able to use my computer.

The LLVM CMake documentation lists only the most useful LLVM specific options. But I think the project and runtime lists are not updated frequently enough.
You should prioritize building the runtime when available instead of the project (example: prefer building openmp as a runtime, and not as a project).

You can see by yourself all projects listed in LLVM’s CMakeLists.txt.

And here for all supported runtimes:

Is it a bug that we allow specifying the same runtime twice, once in PROJECTS and again in RUNTIMES? The one in PROJECTS would be built using the host compiler, but wouldn’t it then be overwritten by the one built by RUNTIMES?

Though maybe you want to use host to build a clang that uses libcxx, and then use that clang to build libcxx. But again I would think that would overwrite parts of the first libcxx build.

@petrhosek do you know if allowing a runtime to appear twice is ever useful?

Edit: the docs prohibit this, we just don’t enforce it from cmake. So that answers my question.

Edit: though the runtimes build may not know what the PROJECTS were, but I’m still interested in the theory of it.

[llvm][docs] Update the project and runtimes lists by DavidSpickett · Pull Request #109788 · llvm/llvm-project · GitHub to fix this.

[llvm][cmake] Error when a runtime is in LLVM_ENABLE_PROJECTS and LLVM_ENABLE_RUNTIMES by DavidSpickett · Pull Request #109791 · llvm/llvm-project · GitHub to make cmake error if you duplicate projects.

1 Like

@DavidSpickett
Thank you, I was thinking of doing this, but i didn’t know where the docs were.
Also will this file update the website or only the docs in repo?

Building LLVM with CMake — LLVM 20.0.0git documentation is generated from llvm-project/llvm/docs/CMake.rst at main · llvm/llvm-project · GitHub. All the documentation parts of the website are in there, the rest is in GitHub - llvm/llvm-www.

The build uses CMake which invokes Sphinx etc etc see Buildbot.

(that build bot is the one that also publishes it to the live site)

The general tactic is look for a file <pagename>.(rst|md) or just “find in files” for some small chunk of the text.

I do agree this is not great, I would like to get “Edit on GitHub” buttons added to these pages to save folks’ time.

1 Like