Skip to content

The Thrush Programming Language. A modern general purpose low-level systems programming language that provides a new low-level development approach.

License

Notifications You must be signed in to change notification settings

thrushlang/thrushc

Repository files navigation

logo

Note

TEMPORARY ONE-MONTH HIATUS

We have reached a point where we are faced with higher obligations that somewhat set this project aside. Therefore, from 8/5/25 to 9/6/25, there will be a HIATUS in the development of the compiler and its plans moving forward.

What does it mean?

Essentially, not much, just that thrushc won't be reflected with commits regularly or habitually. The other projects or repositories of the organization will continue with the planned development pace, but with a little less frequency.

If you'd like to be part of the team, please contact us through the organization's social media channels. They will continue as usual.

Without anything else to say, Kevin Benavides, see you next month.

Warning

The compiler is in an early development stage; it may contain bugs until a code fuzzer is developed for each backend code generator. Build it at your own risk.

The Thrush Compiler

The Thrush Compiler efficiently transfers source code from Thrush files directly to the intended target. Beyond this, it serves as a flexible bridge, integrating with diverse code generators for both research and development purposes.

LLVM

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.

LLVM Version

  • 17.0.6

Why this specific version of LLVM for the compiler?

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.

LLVM Targets

Beyond the standard triple targets, the compiler also supports all architectures available through the LLVM-C API. These include:

  • x86_64
  • AArch64
  • RISC-V
  • ARM
  • MIPS
  • PowerPC
  • SystemZ
  • AMDGPU
  • Hexagon
  • Lanai
  • LoongArch
  • MSP430
  • NVPTX
  • SPARC
  • XCore
  • BPF
  • SPIR-V
  • WebAssembly

GCC

The GCC compiler backend is still under construction.

In the future, you will be able to use it with the -gcc flag to use the GCC backend code generator instead of the default LLVM one.

However, it is only available on 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.

Syntax

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

¿How it works?

Currently, the only backend available for the thrush compiler to compile is the current LLVM, using the LLVM-C API.

Embedded Clang

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.

Code Generations Phases

The code generation is in 3 phases.

  • Intermediate Code Generation (LLVM IR).
  • Emit object files (.o).
  • Linking with some linker through the Clang or GCC C compilers. ~ Rust 2015 be like

In summary:

Getting Started

Start

You must first clone the repository and access it locally.

git clone --depth 1 https://github.com/thrushlang/thrushc && cd thrushc

Build dependencies

Among 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

Build the Compiler

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 -- --help

Frequent Questions

> Why isn't the compiler designed to use it as a bootstrap compiler?

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.

About

The Thrush Programming Language. A modern general purpose low-level systems programming language that provides a new low-level development approach.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages