Using LLVM ADT/Support lib in external projects without pulling full LLVM monorepo

Hello. I find LLVM Support/ADT library quite nice to use and I was experimenting recently to extract it to standalone project, to be usable without pulling entire LLVM monorepo as a dependency.

Repo: GitHub - Hardcode84/llvm-adt

Implementation details:

Also, I was experimenting with amalgamating all Support sources in single cpp, mostly to have a single file to add into the project and not bother with the cmake.
Surprisingly, this mostly worked out of the box and required only trivial fixes to upstream (which are mostly beneficial by itself):

I was told there is a general desire to pull Support lib from LLVM subtree to top-level project within monorepo, and something of this may be useful.

5 Likes

I always want something like this, thanks!
On the technical side: I thought LLVMSupport still depends on LLVMDemangle? Did you also pull that in?

Yeah, Demangle is skipped for now

1 Like

This might be interesting, but I don’t think there’s necessarily community consensus to do this.

Perhaps a first step in this direction would be to break LLVM Support out of the llvm subproject, and move it to it’s own proper top-level directory subproject. I don’t know if this remains true today, but MLIR people used to tell me “MLIR doesn’t really depend on LLVM, it really only uses Support”. Historically, each top-level subproject has maintained some support for building in “standalone mode”, which is ultimately what powers the new “runtimes builds” for libc++, compiler-rt, and the others. What you’re proposing is very much like an LLVMSupport standalone build.

I’ve also been thinking about trying to promote the LLVM and Clang dylib builds as the default build configuration, because the statically linked build configuration is so resource hungry, and most distros ship the dylib build (although I haven’t confirmed this). You might notice that in the dylib build configuration we have to do funny things to link LLVM Support statically or as a separate shared library for llvm-tblgen or to handle other edge cases.

All of that ladders up to about 50% of a case to make Support it’s own subproject, but IMO it doesn’t push it over the top. I’m not planning to work on this and I doubt there is consensus to do it, but if anyone ever did want to walk this path, this is the way I’d recommend.

1 Like