TopGit tracks osquery/osquery-toolchain on GitHub. The project has 43 stars. A LLVM-based toolchain for Linux designed to build a portable osquery
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
The script in this repository is used to build the LLVM/Clang toolchain which is used in the osquery project to create portable binaries of it.
The procedure to build such a toolchain has been based on the build-anywhere project: https://github.com/theopolis/build-anywhere
Following the main goals of the toolchain:
Obtain a LLVM/Clang toolchain which is portable and which doesn't depend from libstdc++ or libgcc.
The toolchain is compiled with a specific glibc version, so that it runs on a wide range of distributions.
The toolchain lives in a sysroot folder which should be self sufficient.
The toolchain should be able to produce binaries that are portable and run on libc >= 2.17 on x86_64 and libc >= 2.27 on aarch64.
To do so, the output binary should depend only on shared libraries which are deeply connected with the environment they run on,
typically libc, libdl, librt, libpthread.
The rough steps used to achieve the above goals:
Use crosstool-ng to compile a stage0 GCC static toolchain, which might be newer than the one available in the system.
Compile an older libz/zlib which is compatible with the old glibc.
Link all GCC binaries into the sysroot created by crosstool-ng, so that the sysroot can be used for the next steps
Compile a first Clang and lld (stage1), which uses libstdc++.
Use the stage1 Clang to compile a stage1 compiler-rt (builtins only).
Use the stage1 Clang/lld to compile a stage1 libc++, which will use the previously compiled compiler-rt
Use the stage1 Clang/lld to compile the rest of compiler-rt (*san libraries) and link them to the stage1 compiler-rt builtins
Use the stage1 Clang to compile a stage1 libunwind (static only)
Use the stage1 Clang, libunwind, libc++/c++abi, compiler-rt builtins, to build a final/full toolchain
The version of crosstool-ng used is 1.28.0
The version of the GCC compiler built by crosstool-ng is 13.4.0
The version of the libc library built by crosstool-ng is 2.17 (x86_64) / 2.27 (aarch64)
The version of LLVM/Clang built by the script is 18.1.8
The version of the zlib library built by the script is 1.3.1
Among others, the toolchain LLVM/Clang includes the clang static analyzer, scan-build, clang-format, clang-tidy.
The default configuration is ready to go, though if customization is needed, there are two files that can be modified: config and crosstool-ng-config.
config contains global configuration values like, versions of llvm, zlib, how many parallel jobs to use, which build system to use and such.
crosstool-ng-config contains the configuration that is feed into the crosstool-ng tool, which compiles the portable GCC.
It controls the GCC version built, libc and kernel headers version to build everything.
This is config normally generated by another tool that crosstool-ng provides, but the config can be manually modified after being generated.
Build
The script has to be run as a normal user and accepts one argument, which is the folder where the various stages and the final toolchain will be built:
./build.sh /opt/osquery-toolchain
This should output the sysroot under /opt/osquery-toolchain/final and the LLVM toolchain will be under /opt/osquery-toolchain/final/sysroot/usr
Redistributing and usage
Enter inside the final folder within the destination path
Rename the sysroot folder to osquery-toolchain
Compress the folder with the following command: tar -pcvJf osquery-toolchain-<VERSION>.tar.xz osquery-toolchain
Make sure that the field matches a valid tag, for example: osquery-toolchain-1.0.1.tar.xz.
The generated tarball can then be uncompressed wherever you like on the target machine.
The toolchain defaults to using libc++ as the C++ standard library, compiler-rt as part of the builtins it needs, instead of relying on libgcc and lld as the linker; so these are implicit.
libc++abi has to be explicitly linked when compiling C++ with l:libc++abi.a instead; merged with it there's also libunwind, which is therefore implicit.
Sometimes explicitly adding -ldl and/or -lrt is needed, depending on what functions the binary is using.
The only other flag that's needed is --sysroot=<sysroot path>, so that the toolchain searches what it needs in the correct path.
Troubleshooting
If the compilation stops at any point in time, just relaunching the script should restart it.
The script doesn't delete anything when it restarts the build, so if you want to start clean from some substep, you need to do that manually.
So for more advanced troubleshooting, following the build example in general we have:
/opt/osquery-toolchain/stage0: here lives crosstool-ng source code, build, zlib source code, build and GCC/G++ toolchain compiled by crosstool-ng. The GCC/G++ toolchain folder is also copied on the next stages
/opt/osquery-toolchain/stage1: here lives the intermediate LLVM/Clang toolchain, together with a copy of the previous step GCC/G++ toolchain and it's used to build the final toolchain
/opt/osquery-toolchain/final: here lives the final sysroot containing only the LLVM/Clang toolchain we want to use
/opt/osquery-toolchain/llvm: here lives the source code for the LLVM/Clang and the various build folders for the LLVM build substeps
The script decides it has to build one of the stages if it doesn't find a specific file in one of the install folders (stage0, stage1, final).
For crosstool-ng is /opt/osquery-toolchain/stage0/crosstool-ng/ct-ng.
For GCC is /opt/osquery-toolchain/stage0/x86_64-osquery-linux-gnu/bin/x86_64-osquery-linux-gnu-gcc
For zlib is /opt/osquery-toolchain/stage0/x86_64-osquery-linux-gnu/x86_64-osquery-linux-gnu/usr/lib/libz.a
For LLVM/Clang stage1 is /opt/osquery-toolchain/stage0/x86_64-osquery-linux-gnu/x86_64-osquery-linux-gnu/sysroot/usr/bin/clang
For compiler-rt builtins is /opt/osquery-toolchain/x86_64-osquery-linux-gnu/x86_64-osquery-linux-gnu/sysroot/usr/lib/clang/<clang version>/lib/linux/libclang_rt.builtins-x86_64.a
For libc++, libc++abi, libunwind, which are compiled together, is one of /opt/osquery-toolchain/x86_64-osquery-linux-gnu/x86_64-osquery-linux-gnu/sysroot/usr/lib/libc++.a/opt/osquery-toolchain/x86_64-osquery-linux-gnu/x86_64-osquery-linux-gnu/sysroot/usr/lib/libc++abi.a/opt/osquery-toolchain/x86_64-osquery-linux-gnu/x86_64-osquery-linux-gnu/sysroot/usr/lib/libunwind.a
For the LLVM/Clang and respective libraries of the final stage is /opt/osquery-toolchain/final/sysroot/usr/bin/clang, because the install step is a single unit.
TopGit's last sync did not record any GitHub topics for osquery/osquery-toolchain. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on osquery/osquery-toolchain?
The most recent commit recorded on osquery/osquery-toolchain was 7 months ago, based on the GitHub push timestamp. The repository has 23 forks — one of the better signals of community interest.
How many stars does osquery/osquery-toolchain have?
osquery/osquery-toolchain has 43 GitHub stars — refresh the page for the live number, or check github.com/osquery/osquery-toolchain. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is osquery/osquery-toolchain written in?
osquery/osquery-toolchain is written primarily in Shell. GitHub's language field is based on the largest share of bytes in the default branch.
Where do I read more about osquery/osquery-toolchain?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/osquery/osquery-toolchain is the definitive source.
Read full README in the tab above.
Still deciding about osquery-toolchain?
One click hands the question to an AI along with this page — see what it says about osquery-toolchain.