TLDR; Skip to the Proposal section.
Hi,
Since the migration to the monorepo and Github, stand-alone build configurations for LLVM have existed in a very ambiguous state. There’s no documentation for how to use them, no buildbots testing them, and yet we still make a best effort to support this configuration in tree.
I would like to propose that we come up with concrete requirements for stand-alone builds and make sure that they are a supported build configuration going forward.
What are stand-alone builds?
I think everyone may have their own idea of what ‘stand-alone build’ means, but for the purposes of this proposal I would like to define stand-alone builds as follows:
A stand-alone build is a way of building an LLVM sub-project with only the source from the sub-project’s directory, plus the cmake files, headers, built libraries and tools from any other sub-project it depends on.
The important thing to note about this definition is that it means stand-alone builds should not be referencing source code (outside of the cmake files and includes) of other sub-projects. Some of the stand-alone build implementations in the tree currently use the LLVM_MAIN_SRC_DIR to find the llvm source directory. This would have to be changed if we adopt the above definition of stand-alone builds.
Benefits of stand-alone builds
Stand-alone builds make it possible to quickly update an LLVM sub-project by limiting the amount of code that needs to be built to produce a new build. This is important for Linux distributions (like Fedora and Red Hat Enterprise Linux, which I maintain), that need the flexibility to be able to deliver fixes quickly and without causing too much churn in the distribution. For example, stand-alone builds make it possible to patch a bug in lld and get a new build in 15 minutes vs the 12+ hours it would take to rebuild all the projects.
It also makes security and license analysis of the source code much easier if you only have the code for a single sub-project to analyze versus trying to analyze the entire monorepo.
Stand-alone builds also provide a good test case for building against a pre-installed version of LLVM or Clang. Consumers of the LLVM and Clang libraries build this way, so it’s beneficial that we have a test case for this in tree.
Disadvantages of stand-alone builds
The disadvantage of supporting stand-alone builds is that it adds complication to the build system, which may negatively impact users and developers who aren’t interested in this specific configuration.
Proposal
I propose that we formally support stand-alone builds (as defined above) for the llvm, clang, lld, and lldb sub-projects. Adding support for more sub-projects would need to be proposed via another RFC.
The high-level requirements for supporting stand-alone build would be:
- Sub-projects must not use llvm-config and should instead use CMake files for reading llvm project configuration (This will help stand-alone builds operate more like the monorepo builds).
- Sub-projects must not reference the LLVM_MAIN_SRC_DIR CMake variable when building in stand-alone mode.
- Sub-projects must be able to build and run make check successfully (or at least not have any extra failures in the case of lldb) in the supported stand-alone configuration (Note: This may be a subset of the tests supported in the monorepo build e.g. lit tests but no unit tests).
- The supported stand-alone build configurations must be documented including the CMake arguments.
- There must be a buildbot to test the supported stand-alone build configuration(s).
- There must be a code owner to ensure these requirements are met.
I’ve chosen these specific requirements, because I believe they will strike a good balance between providing useful stand-alone builds while not complicating the build system too much. However, I’m also open to other suggestions and ideas.
-Tom