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:
- There is a script llvm-adt/scripts/update.py at master · Hardcode84/llvm-adt · GitHub to pull relevant LLVM sources (headers, cpps and tests) to the repo.
- There are googletest/googlemock sources pulled from LLVM repo for testing llvm-adt/third-party/unittest at master · Hardcode84/llvm-adt · GitHub (not updated via script)
- Initially I only wanted
STLExtrasandSmallVectorbut SmallVector and tests pulled a lot of lib dependencies and I decided to pull the entire library. - There is a GH action to run the update script and tests every night with current LLVM HEAD llvm-adt/.github/workflows/update-llvm-sha.yml at master · Hardcode84/llvm-adt · GitHub.
- LLVM proper has the
llvm-config.hwhich is generated by CMake, for this project I just hardcoded it for linux, for now llvm-adt/include/llvm/Config/llvm-config.h at master · Hardcode84/llvm-adt · GitHub - Some tests are depending on LLVM IR, unfortunately, and skipped, but the Support lib itself is mostly looks fine in this regard (but we have cases when C++ API depends on C API).
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):
- [support] SlowDynamicAPInt: use fully qualified namespaces for func definitions by Hardcode84 · Pull Request #132575 · llvm/llvm-project · GitHub
- [support][nfc] MD5: Undef macros after use by Hardcode84 · Pull Request #132132 · llvm/llvm-project · GitHub
- Few files are still skipped llvm-adt/scripts/update.py at master · Hardcode84/llvm-adt · GitHub, mostly because they have same-named functions/static vars in different modules.
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.