Built-in Targets
Dryft includes two built-in targets located insrc/targets/:
GCC Target (gcc.toml)
The default target that compiles Dryft code to C99 and uses GCC for final compilation.
- Backend: C99 - Generates portable C code
- Output: C source file compiled to native executable
- Dependencies: GCC compiler
- Use case: Default target for maximum portability
ELF Target (elf.toml)
Direct compilation to x86-64 assembly using NASM.
- Backend: x86 - Generates x86-64 assembly
- Output: Native ELF executable
- Dependencies: NASM assembler, ld linker
- Note: No standard library compilation (currently limited)
- Warning: Not stable in REPL environment
Target Structure
A target file is a TOML configuration that defines platform-specific compilation pipelines.Platform Sections
Targets support multiple platforms:Target Fields
The code generation backend to use. Available backends:
C99- Generates C99-compliant C codex86- Generates x86-64 NASM assembly
File path where the compiler writes the generated intermediate representation.Examples:
build/ir.cfor C99 backendbuild/ir.asmfor x86 backend
List of external tools required by this target. Currently informational only.Example:
Shell command to compile the Dryft standard library for this target.Example:
Shell command to assemble/compile the intermediate representation into an object file.Example:
Shell command to link object files into the final executable.Example:
Command to execute the final product. Used with the
--run flag and in REPL mode.Default: ./a.outExample:Available Backends
Backends are the code generation engines in Dryft. Each backend implements theBackend trait defined in src/backends.rs.
C99 Backend
- Name:
C99 - Implementation:
src/backends/c99/ - Output format: C99-compliant C code
- Features: Full language support, portable
- Use case: Production builds requiring portability
x86 Backend
- Name:
x86 - Implementation:
src/backends/x86/ - Output format: NASM x86-64 assembly
- Features: Direct assembly generation
- Limitations: REPL instability, limited stdlib support
- Use case: Low-level systems programming, education
Creating Custom Targets
You can create custom target files to support new platforms or compilation workflows.Example: LLVM Target
Example: Cross-Compilation Target
Using Custom Targets
Specify your custom target file with the--custom-target flag: