The Thrush Compiler efficiently transfers source code from Thrush files directly to the intended target. The process involves static type analysis, code generation, target-specific optimizations, specific machine-compiled code, and finally, emission or linking.
Important
We're very close to releasing a beta version of the compiler, and we're working on the documentation.
Warning
The compiler is in an early development phase. It may contain bugs when testing certain syntax. Continue on your own.
You must first clone the repository and access it locally.
git clone --depth 1 https://github.com/thrushlang/thrushc && cd thrushcAmong the dependencies required by the compiler is the LLVM-C API, which you can find pre-compiled for each operating system at Thrush Programming Language - Toolchains.
Automatically:
cd builder && cargo run && cd ..Now you need to have Rust installed with a recent version.
- >= Rust (v1.18.5)
- Rust 2024 Edition
Now you need to compile the compiler with Rust.
cargo run -- --helpIf you just need to quickly see the commands, you can look at Thrush Compiler - Commands & Flags.
The language syntax is under construction at the same time as the compiler. It may be outdated compared to the compiler, as the latter progresses more rapidly. This will be normalized once a valid and sufficiently stable beta is released.
Thrush Programming Language - General Syntax
Currently, the only backend available for the thrush compiler to compile is the current LLVM, using the LLVM-C API.
The compiler has Clang compiled for Linux & Windows inside the executable in case the programmer does not have access to it; however, you can specify a custom Clang & GCC.
The code generation is in 3 phases.
- Intermediate Code Generation (
LLVM IR). - Emit object files (
.o). - Linking with some linker through the
ClangorGCCC compilers. ~ Rust 2015 be like
In summary:
The LLVM backend infrastructure is the default code generator for the Thrush Programming Language. It offers full scope and portability across many architectures or targets.
17.0.6
Between version 16-17, the introduction to the change of typed pointers was made, which are now almost a standard in the backend.
Some programming languages like Swift tend to use versions lower than 16 of LLVM, for reasons of compatibility with code generation that differs between higher and lower versions of LLVM, and version 16 offers legacy support for languages that need it.
We only need support for C and nothing else. We are not interested in FFI with C++ for the moment, nor in mangling with it either. 17 is enough and from there on.
Beyond the standard triple targets, the compiler also supports all architectures available through the LLVM-C API. These include:
x86_64AArch64RISC-VARMMIPSPowerPCSystemZAMDGPUHexagonLanaiLoongArchMSP430NVPTXSPARCXCoreBPFSPIR-VWebAssembly
The GCC compiler backend is still under construction.
In the future, you will be able to use it with the -gcc-backend flag to use the GCC backend code generator instead of the default LLVM one.
However, it is only available on GNU/Linux.
You must also have libgccjit.so dynamically installed in your distribution so that the compiler doesn't get scared at runtime when using GCC.
The GCC backend, which is completely embeddable, of the JIT compiler type, can practically only be built dynamically and not statically. For this reason, it has been distributed in many package managers of Linux distributions.
If you need help finding a way to install libgccjit on your system, you can check: GCC JIT - Documentation
sudo dnf install libgccjit-develsudo pacman -S libgccjitsudo apt install libgccjit-0-dev$ git clone --depth 1 https://gcc.gnu.org/git/gcc.git
$ cd gcc
$ mkdir build && cd build
$ ../configure \
--enable-languages=jit \
--enable-host-shared \
--disable-multilib \
--disable-bootstrap
$ make -j$(nproc)
$ make installCurrently, the very same Rust is using libgccjit as a library for an AOT backend prototype for Rust. Called rustc_codegen_gcc. Thrush will integrate it in his own way for use in the language.
For more information: Rust - GCC AOT Code Generation
Regarding the concept of bootstrapping in compilers (For more information: https://www.bootstrappable.org/).
The decision was made to fully implement all the programming language functions in the compiler written in Rust, because it proposes a development approach similar to what Gleam Team did for Gleam Programming Language, and also to lighten the workload, given that we are already using LLVM.

%20v1.3.png)