Skip to content

Latest commit

 

History

History
183 lines (111 loc) · 6.36 KB

File metadata and controls

183 lines (111 loc) · 6.36 KB

logo

Thrust Compiler

standard-separator

Thrust Compiler is a compiler that transfers the source code of Thrust files directly to the specified destination. The process includes static type analysis, code generation, destination-specific optimizations, machine-specific code compilation, and finally, emitting or linking.

Important

The compiler is in an early development phase. It still hasn't made the major releases.

Getting Started

Compiled

If you don't want to build the project from scratch, you can check if there are available versions in Github releases.

Thrust Compiler - Github Releases

Supported operating systems and architectures:

  • Linux x64 (GNU)
  • Windows x64 (MSVC)
  • MacOS x64 (arm/aarch64)
  • MacOS x64 (intel)

From Scratch

Build dependencies

Among the dependencies required by the compiler is LLVM compiler infrastructure.

Automatically:

$ git clone --depth=1 https://github.com/thrustlang/compiler-dependency-builder 
$ cd compiler-dependency-builder 
$ cargo build --release
$ ./target/release/compiler-dependency-builder

Another way:

$ git clone --depth=1 https://github.com/thrustlang/compiler-dependency-builder 
$ cd compiler-dependency-builder 
$ cargo run 

If you want to know a high-level command line view, you should check out: Compiler Dependency Builder - Commands & Flags

You must first clone the repository and access it locally.

$ git clone --depth=1 https://github.com/thrustlang/thrustc 
$ cd thrustc

Build Cargo/rustc dependencies

Among other mandatory dependencies, we also need additional libraries specifically for Cargo and rustc.

You must install each Cargo dependency automatically:

Bash

sh scripts/cargo-dependencies.sh

Fish

fish scripts/cargo-dependencies.fish

CMD

scripts\cargo-dependencies.bat

PowerShell

.\scripts\cargo-dependencies.ps1

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 build --release
$ ./target/release/thrustc --help

Cross Compilation

Thrust Compiler offers powerful cross-compilation support, just like 'Clang'.

RISC-V 64-bit

./thrustc main.thrust my_library.thrust \
  -target-triple riscv64-unknown-linux-gnu \
  -cpu sifive-u74 \
  -opt O3 

WebAssembly

./thrustc main.thrust my_library.thrust \
  -target-triple wasm32-unknown-unknown \
  -opt O3 

You can target macOS, Windows, Linux, and other platforms directly from your current system without needing to switch machines.

Commands & Flags

If you want to know a high-level command line view, you should check out: Thrust Compiler - Commands & Flags

Compiler Structure

If you want to know a little about the compiler's structure, you should check out: Thrust Programming Language - Compiler Structure

Rust Code Documentation

If you want to know regarding Rust code's structure that resides in the compiler, you should check out: Thrust Programming Language - Rust Code Documentation

Cargo Alias

If you require to know the command line shorcuts available in the project across rust-cargo, you should check out: Thrust Programming Language - Cargo Alias

Commit Conventions

If you want to know the commit conventions to follow in order to delivery a good Github commit, you should check out: Thrust Programming Language - Commit Conventions

Compiler Diagnostics

If you want to see examples of the type of compiler diagnostics you can find in thrustc, you should check out: Thrust Programming Language - Compiler Diagnostics

Compiler Fuzzing

If you want to know how to fuzz the compiler with stable and unstable features to find issues, you should check out: Thrust Programming Language - Compiler Fuzzing

Compiler Releasing

If you want to know how a new compiler version is released, you should check out: Thrust Programming Language - Compiler Releasing

Release Binary Variants

If you want to know the differences between the compiler binaries shipped in Github releases, you should check out: Thrust Programming Language - Release Binary Variants

Code of Conduct

If you want to know the code of conduct expected from the project contributors, you should check out: Thrust Programming Language - Code of Conduct

License

Thrust Compiler is distributed under the terms of the GNU General Public License (version 3). See LICENSE.txt file for details.

Q&A

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

> Agentic AI

No, I don't use it and I never will. This compiler will always have code analyzed, processed, and studied by a human.

I don't care. You can't use agentic AI in this project.