Skip to content

zig_configure_binary

Once-native configured Zig executable target.

Description

Compiles a Zig executable with zig build-exe, with configuration declared directly on the target. This is the Once shape for configured Zig binaries: use target attributes such as mode, threaded, zig_version, and zigopt instead of wrapping another target through a transition.

The root can be set with main, or omitted when deps contains exactly one Zig module dependency.

Canonical module names are generated from target labels with collision-safe escaping. import_names keys must match exactly one Zig module dependency by full label, short label name, import name, or canonical name; ambiguous or unknown keys fail validation.

Attributes

This target accepts the complete attribute set documented by zig_binary, including strip, translate_c_identity, csrcs, linker settings, run env, and run args.

Dependency Edges

EdgeAcceptsDescription
depszig_module, c_providerZig modules and C provider dependencies consumed by the executable

Providers

The target emits zig_binary.

Capabilities

CapabilityOutput groupsRequires
buildbinary, asm, llvm_ir, llvm_bc, zig_docs
rundefaultbinary

Example

toml
[[target]]
name = "hello_release"
kind = "zig_configure_binary"
deps = ["./math"]
srcs = ["src/**/*.zig"]

[target.attrs]
main = "src/main.zig"
mode = "release_safe"
zigopt = ["-fllvm"]

Released under an open-source license.