xclang is a clang toolchain that cross-compiles C and C++ for Linux, Windows
and macOS with one --target flag, and builds programs that need nothing at
run time but the OS.
clang++ -O2 --target=aarch64-unknown-linux-gnu hello.cpp -o hello-linux-arm64
clang++ -O2 --target=x86_64-unknown-linux-musl hello.cpp -o hello-static-x64
clang++ -O2 --target=aarch64-w64-mingw32 hello.cpp -o hello-windows-arm64.exeNothing else to install: for each --target, clang reads a config file in
bin/ that points it to the target's sysroot and prebuilt runtimes, which
come with the toolchain. Each program runs on any machine of its target, as
a single file.
- Targets: Linux (glibc and static musl), Windows (MinGW and MSVC) and
macOS, on x64 and arm64, from every host. The SDKs no one may
redistribute, Apple's and Microsoft's, come from the vendor through
xclang sdk fetch. - Programs that need only the OS:
libc++,libc++abi,libunwindandcompiler-rtare linked in; a Linux program runs on glibc 2.17 or later, a Windows one on Windows 10 or later, a macOS one on macOS 13 or later. - Build systems: CMake with
import std, Bazel, cargo throughxclang cargo, and Make and Meson all use the same toolchain. - Speed:
clangandlldare built with PGO and ThinLTO and linked statically against xclang's ownlibc++on every host. - Pinned, reproducible releases: built from LLVM's release source with
documented patches, verified by
SHA256SUMS, and never replaced. - libclang: the
clangand LLVM libraries each release was built from, as ThinLTO bitcode, for tools built onclang.
From the clice conda channel with pixi.toml:
[workspace]
name = "hello"
channels = ["conda-forge", "https://conda.clice.io"]
platforms = ["linux-64", "linux-aarch64", "osx-64", "osx-arm64", "win-64", "win-arm64"]
[dependencies]
xclang = "*"pixi installYou can also install from release archives, CMake FetchContent, or the Bazel
registry; see the quick start.
CMake: the toolchain file, with XCLANG_TARGET ($XCLANG is the toolchain
directory):
cmake -G Ninja -B build-aarch64-w64-mingw32 --toolchain $XCLANG/lib/cmake/xclang/toolchain.cmake \
-DXCLANG_TARGET=aarch64-w64-mingw32
cmake --build build-aarch64-w64-mingw32Bazel: the module from bazel.clice.io, and a platform per target:
bazel_dep(name = "xclang", version = "23.1.5.1")bazel build --platforms=@xclang//platforms:x86_64-w64-mingw32 //:hellocargo: xclang cargo sets the compilers and linkers of each target, with
no cargo config:
xclang cargo build --release --target x86_64-pc-windows-gnullvmThe documentation has the rest: import std,
Make and Meson, sanitizers, runtimes built from source, debug symbols,
libclang and CI.
What is not in a release yet is in the roadmap. xclang is developed for clice, whose release builds are its first user; catter builds with it too.
CHANGELOG · contributing · security · license