TechScript supports compiling programs directly to native machine code via the LLVM compiler framework.
When you run tech build --native main.txs, the compiler bypasses the VM bytecode generation and instead runs the native compilation flow:
- AST to LLVM IR: The compiler translates the verified AST into LLVM IR (Intermediate Representation) using
inkwell(safe Rust bindings for LLVM). - Optimization Passes: LLVM runs standard compilation optimization passes (e.g. constant propagation, loop unrolling, vectorization).
- Machine Code Generation: LLVM compiles the IR into target-specific assembly or machine code, linking it with the TechScript native runtime to generate a standalone executable.
- Zero VM Overhead: Executable binary runs on raw CPU instructions instead of stack emulation.
- Link-Time Optimization (LTO): Combines runtime libraries directly into the output executable for optimization.
- Native ABI: Supports compiling functions with native C ABI calling conventions, enabling seamless FFI integration.
To use the LLVM backend, you must have an active LLVM development toolchain installed on your machine and configure the compiler with target options:
tech build --native --target x86_64-pc-windows-msvc main.txs