Skip to content

dustlang/dust

Dust - DPL Compiler and Toolchain

dust is the compiler and toolchain for the Dust Programming Language (DPL).

This repository contains:

  • the DPL specification (spec/)
  • reference examples (examples/)
  • the dust compiler implementation (Rust)
  • dust-runtime - OS services for bare-metal kernels

Status

  • DPL Specification: v0.2 (active development)
  • Compiler: v0.2 (bare-metal and extended feature support)

Linker Policy

  • Host executable builds prefer dustlink as the linker frontend.
  • To bootstrap dustlink itself, the compiler bypasses dustlink and falls back to lld paths (-fuse-ld=lld, rust-lld, ld.lld) before the driver default linker.
  • dust kernel-link remains available but is deprecated; use dust obj + dustlink.
  • Host linker runtime support used by Dust-built tools now includes:
    • cross-format shared-symbol ingestion (ELF/PE/COFF/Mach-O paths)
    • COFF/Mach-O object-format probe and symbol-ingest acceptance for arm64 machine/cpu IDs in addition to x86_64
    • block-aware linker-script statement splitting
    • section output-address parsing inside SECTIONS { ... }
    • script expression evaluation (ORIGIN/LENGTH/ADDR/LOADADDR/SIZEOF/ALIGN, unary ops, +/-, *, /, %, shifts, bitwise ops) and ASSERT(...) checks
    • strict script handling for unknown directive heads plus direct symbol-assignment statements (SYMBOL = <expr>)
    • PHDRS / VERSION script compatibility blocks with block-shape validation
    • SECTIONS ... AT(<expr>) load-address capture
    • required-symbol registration for ENTRY(symbol) script form
    • sysroot-aware SEARCH_DIR(=...) linker-script resolution and script INPUT handling for -L / -l tokens
    • compatibility-flag state wiring for hash-style/threading/diagnostic/icf controls
    • runtime consumption of compatibility-state fields for hash-style ELF dynamic tags, --dependency-file depfile emission, --emit-relocs map-row expansion, and --print-gc-sections drop diagnostics
    • broader CLI compatibility handling for script/export-related ld/lld flags (--version-script, --dynamic-list, --trace-symbol, --print-map, --start-lib, --end-lib)
    • non-silent compatibility no-op handling in Dust-built dustlink CLI paths (warning diagnostics, or hard-fail under fatal-warnings mode)
    • improved unsupported flag/target diagnostics for host linker CLI parsing
    • dynamic-policy alias handling for --no-allow-shlib-undefined
    • expanded -z semantic handling for defs/undefs plus accepted compatibility tokens text/notext/origin
    • lld-link slash-option compatibility handling (/OUT, /ENTRY, /MACHINE, /LIBPATH, /DEFAULTLIB, /MAP, /DLL, /SUBSYSTEM, /OPT, /WX, /NOENTRY, /DYNAMICBASE, /NXCOMPAT, /LARGEADDRESSAWARE)
    • additional target alias parsing for aarch64/arm64 triples (mapped to platform linker target families), musl triples, Windows GNU triples, and bare-metal *-none[-elf] aliases
    • architecture-aware target preservation for both x86_64 and aarch64 host linker target IDs
    • machine-aware relocation validation/application paths keyed by object machine type
    • refined COFF and Mach-O relocation-kind mapping during host object ingestion (machine-aware COFF mapping and Mach-O reloc-type decoding)
    • baseline AArch64 relocation support in Dust linker relocation pipeline (R_AARCH64_NONE, R_AARCH64_ABS64, R_AARCH64_ABS32, R_AARCH64_PREL32)
    • expanded AArch64 relocation support in Dust linker relocation pipeline:
      • branch/instruction forms (CALL26, JUMP26, CONDBR19, TSTBR14, LD_PREL_LO19, ADR_PREL_LO21, ADRP page relocs, ADD/LDST lo12 patching including LDST128)
      • MOVW families (UABS, SABS, PREL)
      • starter TLS relocation families:
        • instruction/descriptor forms (TLSGD, TLSLD, TLSDESC) recognized/validated with strict ERR_NOT_IMPLEMENTED_YET application for unsupported TLS descriptor semantics
        • data relocs (TLS_DTPMOD / TLS_DTPREL / TLS_TPREL) use host-runtime TLS layout metadata helpers for non-shared links
        • shared-link TLS data reloc semantics now partially differentiate models: TLS_DTPREL resolves from TLS layout metadata, shared-link TLS_TPREL is rejected as invalid, and shared-link TLS_DTPMOD remains not yet implemented
        • TLSLE/TLSLD low12 offset instruction forms (*_ADD_*_LO12_NC, *_LDST64_*_LO12_NC, *_LDST128_*_LO12_NC) now reuse host-runtime TLS offset helpers in non-shared links
        • R_AARCH64_TLSDESC_CALL now applies as an instruction-shape-validated preserve (BLR) instead of being blanket-rejected with the remaining unsupported TLS descriptor sequence relocs
        • host-runtime AArch64 TLS synthetic descriptor/GOT planning state and helper ABI are now used by Dust linker relocation application for TLSGD / TLSLD / TLSDESC descriptor-sequence instruction relocations (reserve, count, slot address, reloc-value)
        • ELF host writer now materializes a synthetic AArch64 TLS descriptor/GOT-like load-image region for reserved descriptor-sequence slots and emits minimal dynamic relocation metadata (DT_SYMTAB, DT_SYMENT, DT_RELA*, synthetic .rela.dyn records) for staged TLS descriptor-sequence parity work
        • initial TLS descriptor-sequence relaxation scope is limited to deterministic synthetic-slot reuse/coalescing (including TLSLD module-slot coalescing); full instruction-sequence rewrite relaxations remain pending
    • host runtime shared-object symbol ingest now returns ERR_INVALID_FORMAT for unknown/unsupported shared object payloads (no silent success on unknown format)
    • host runtime shared-object symbol ingest now validates target/ABI compatibility and shared-file kind before symbol ingest (ELF ET_DYN, Windows PE DLL/COFF machine, Mach-O dylib CPU type)
    • host runtime shared-object symbol ingest now filters non-exported metadata entries more strictly (ELF hidden/internal dynsyms, Mach-O private extern/debug symbols)
    • host runtime needed-library recording now prefers embedded shared-library names when available (ELF DT_SONAME, PE export DLL name, Mach-O LC_ID_DYLIB install name) instead of filename-only normalization
    • Dust linker now reserves AArch64 TLS synthetic planning slots when unsupported TLS descriptor-sequence relocs are encountered (preparatory infrastructure only; no descriptor/GOT emission yet)
    • architecture-correct output header stamping in ELF/PE/Mach-O writers based on resolved target
    • real PE compatibility-state wiring for /NOENTRY, /DYNAMICBASE, /NXCOMPAT, /LARGEADDRESSAWARE
    • broader soft-compatibility handling for common ld/lld/lld-link metadata/profiling flag families (--warn-*, --time-trace*, --lto-*, /GUARD:*, /TIMESTAMP:*, /MERGE:*, /SECTION:*)
    • complete ELF writer execution in staged header/finalize flow (no ident-only prewrite)
    • sectionized PE/Mach-O host writer emission from real alloc chunks

What Works Today (v0.2)

The compiler supports multiple output modes:

1. Native Executables (Host)

dust build hello.ds
./target/dust/hello

2. Object Files (for linking)

dust obj hello.ds -o hello.o

3. Cross-Compilation

dust obj hello.ds --target x86_64-unknown-linux-gnu

4. Bare-Metal Kernels (no libc)

dust obj hello.ds --bare-metal -o kernel.bin

DPL v0.2 Specification

Supported Features

K-Regime (Classical Computing)

  • Entry Point: K main { ... }
  • Variable Declarations: let x = 5;
  • Control Flow:
    • if condition { ... } else { ... }
    • while condition { ... }
    • for i in 0..10 { ... }
  • Effects: emit "string" for output
  • Arithmetic: +, -, *, /, %
  • Comparisons: ==, !=, <, <=, >, >=

Q-Regime (Quantum Simulation)

  • Returns ERR_DOMAIN_NOT_AVAILABLE (100) - stub implementation

Φ-Regime (Future Computing)

  • Returns ERR_DOMAIN_NOT_AVAILABLE (100) - stub implementation

Data Types

  • UInt8, UInt16, UInt32, UInt64
  • Int8, Int16, Int32, Int64
  • Float32, Float64
  • Bool
  • Char

Code Generation

  • Cranelift-based JIT/AOT compilation
  • ELF (Linux), PE (Windows), Mach-O (macOS) executables
  • Flat binary for bare-metal
  • Object files (.o) for linking with dustlink

Supported Targets

Target Description
(host) Native (default)
x86_64-unknown-linux-gnu Linux
x86_64-pc-windows-gnu Windows
x86_64-apple-darwin macOS
x86_64-unknown-none Bare-metal (x86-64)

Quickstart

Build and run an example

cargo run -p dust -- build examples/K/k_hello_world.ds
./target/dust/k_hello_world

Expected output:

Hello, Dust

Build a bare-metal kernel

cargo run -p dust -- obj kernel.ds --bare-metal -o kernel.bin

Build an object file

cargo run -p dust -- obj mymodule.ds -o mymodule.o

Build + link a multi-object bare-metal kernel

cargo run -p dust -- obj xdv-kernel/sector/xdv_kernel/src xdv-runtime/src xdv-xdvfs/src --target x86_64-pc-none-elf --out-dir target/dust/kernel_objs
dustlink --oformat=binary --image-base 0x100000 -Ttext 0x100000 -e _dust_kernel_start -o target/dust/xdv-kernel.bin target/dust/kernel_objs/*.o

Dust Runtime (dust-runtime/)

OS services for bare-metal DPL kernels written entirely in DPL:

  • Console I/O - VGA text mode output
  • Memory Management - Physical page allocation, heap management
  • Process Management - Task scheduling and context switching
  • Interrupt Handling - IDT and IRQ management
  • I/O Ports - Direct hardware I/O for x86
K main {
    Runtime::K::init();
    emit "Kernel started";
}

Runtime API

// Console
Console::K::init()
Console::K::putchar(ch: UInt8)
Console::K::puts(s: UInt64)
Console::K::clear()
Console::K::set_cursor(row: UInt32, col: UInt32)

// Memory
Memory::K::init()
Memory::K::alloc(size: UInt32) -> UInt64
Memory::K::free(ptr: UInt64) -> UInt32
Memory::K::copy(dest: UInt64, src: UInt64, size: UInt32) -> UInt32

// Process
Process::K::init()
Process::K::create_task(entry: UInt64, stack: UInt64) -> UInt32
Process::K::schedule()
Process::K::yield()

// Interrupts
Interrupts::K::init()
Interrupts::K::enable()
Interrupts::K::disable()
Interrupts::K::register_handler(vector: UInt8, handler: UInt64)

// I/O Ports
IOPort::K::inb(port: UInt16) -> UInt8
IOPort::K::outb(port: UInt16, value: UInt8)
IOPort::K::inw(port: UInt16) -> UInt16
IOPort::K::outw(port: UInt16, value: UInt16)

XDV OS Integration

Dust compiles to bare-metal binaries that can be used with xdv-os:

xdv-os/
├── boot_sector.asm    # 512-byte boot sector
├── kernel.asm         # Assembly kernel entry
├── kernel.ds          # DPL kernel
└── kernel.bin         # Compiled kernel

Build the bootable image:

cd xdv-os/src
./build.sh  # Linux/Mac
build.bat   # Windows

Architecture

.ds source → dust parser → dust semantics → DIR IR
                                      ↓
                         dust_codegen (Cranelift)
                                      ↓
              ┌─────────────┬──────────────┴──────────────┐
              ↓             ↓                           ↓
        Executable    Object File (.o)           Bare-Metal (.bin)
        (ELF/PE/Mach)  (for linking)            (flat binary)

CI Verification

GitHub Actions verifies:

  • Workspace build
  • Unit tests
  • Example compilation
  • Executable execution
  • Object file generation
  • Bare-metal kernel compilation

License

Dust Open Source License
© 2026 Dust LLC

About

The Dust Compiler

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages