Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Build Options

Build options are named values passed from the command line into build.fol. They follow Zig’s -D convention.

Syntax

fol code build -Dname=value

Multiple options can be passed in one command:

fol code build -Dtarget=x86_64-linux-gnu -Doptimize=release-fast -Dstrip=true

Standard Options

Two options are pre-defined by the build system: target and optimize. They are read via dedicated graph methods.

Target

var target = graph.standard_target();

CLI: -Dtarget=arch-os-env

Format: arch-os-env triple. Examples:

TripleMeaning
x86_64-linux-gnux86-64 Linux with glibc
x86_64-linux-muslx86-64 Linux with musl libc
aarch64-linux-gnuARM64 Linux with glibc
aarch64-linux-muslARM64 Linux with musl libc
x86_64-macos-gnux86-64 macOS
aarch64-macos-gnuARM64 macOS
x86_64-windows-gnux86-64 Windows with MinGW
x86_64-windows-msvcx86-64 Windows with MSVC
aarch64-windows-msvcARM64 Windows with MSVC

Supported architectures: x86_64, aarch64. Supported operating systems: linux, macos, windows. Supported environments: gnu, musl, msvc.

If not set, the host target is used.

standard_target() always exposes the compact FOL spelling shown above, so when and case comparisons are stable even when the CLI accepted a canonical Rust triple. Artifact identity and the backend separately retain the matching canonical Rust triple (for example, x86_64-unknown-linux-gnu).

To pass the resolved value to an artifact:

var target = graph.standard_target();
var app = graph.add_exe({
    name   = "app",
    root   = "src/main.fol",
    target = target,
});

Optimize

var optimize = graph.standard_optimize();

CLI: -Doptimize=mode

Valid modes:

ModeMeaning
debugNo optimization, full debug info
release-safeOptimized release build with safety checks (required for C ABI, Wasm, freestanding)
release-fastOptimized release build for pure hosted FOL artifacts; retains FOL safety checks
release-smallOptimized release build for pure hosted FOL artifacts; retains FOL safety checks

Default: debug. A fol code ... --release request supplies release-safe when no explicit optimize value is present. An explicit -Doptimize=... or --optimize ... value takes precedence and also determines whether the artifact uses the debug or release output/rustc profile, so the directory identity cannot disagree with the compiler profile. All release modes retain FOL runtime and overflow safety checks; artifacts that use C imports, C ABI library exports, Wasm, or freestanding targets require debug or release-safe.

To pass the resolved value to an artifact:

var optimize = graph.standard_optimize();
var app = graph.add_exe({
    name     = "app",
    root     = "src/main.fol",
    optimize = optimize,
});

Sanitize

CLI: --sanitize address,undefined on fol code build, run, and test, or FOL_SANITIZE=address,undefined in the environment.

The executable or shared library is linked with the C driver’s -fsanitize= runtime, so a C provider compiled with the same flags links and reports its violations. The generated Rust itself is not instrumented: the pinned stable rustc has no sanitizer instrumentation. Every heap allocation in the process still goes through the sanitizer’s allocator, so leaks, double frees and foreign frees are reported on the Rust side too. A static library is unchanged, because its C consumer links the runtime. Only Linux GNU targets are accepted, and an unknown name is refused.

User Options

graph.option(...) declares a named option specific to the package.

var strip = graph.option({
    name    = "strip",
    kind    = "bool",
    default = false,
});

CLI: -Dstrip=true

Option Kinds

KindExample CLIDefault type
bool-Dverbose=truefalse
int-Djobs=80
str-Dprefix=/usr""
enum-Dbackend=llvmfirst value
path-Droot=src/main.fol""
target-Dtarget=x86_64-linux-gnuhost target
optimize-Doptimize=release-fastdebug

Using Option Values

Option handle values can be interpolated into strings or compared with ==:

var root_opt = graph.option({ name = "root", kind = "path", default = "src/main.fol" });
var app = graph.add_exe({ name = "app", root = root_opt });

Comparing in a when condition:

var strip = graph.option({ name = "strip", kind = "bool", default = false });
when(strip == true) {
    {
        var strip_step = graph.step("strip");
    }
};

Shorthand vs Long Form

Both of these are equivalent:

fol code build -Dtarget=x86_64-linux-gnu
fol code build --build-option target=x86_64-linux-gnu

-D is the shorthand. -Dtarget= and -Doptimize= route to the dedicated standard option slots. All other -Dname=value pairs route to user-declared options.