Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Tools

    build

    Builds a native program or a selected web target.

    Invocation, options and results

    Link

    topaz build

    Synopsis
    1. topaz build [entry]

    Input

    topaz build [entry] accepts one optional source entry. Without it, the command loads topaz.toml from --root <dir>, which defaults to the current directory. With an entry, the default source root is the entry directory.

    --out-dir <dir> is required and its value must be nonempty. The target is native, web, or web-worker. An explicit --target overrides the package manifest. Otherwise a package uses [build].target and an entry build uses native.

    --release selects the optimized profile. Without it the native output uses the debug profile. --run executes a successfully built native artifact. Web targets reject --run before a build starts.

    Program arguments follow -- and are accepted when --run is present. They are passed unchanged to the built program. A program receiving explicit arguments must provide the supported exported entry contract.

    --compiler selects self or rust and defaults to self. --backend selects boxed or native and defaults to boxed. Native lowering requires --compiler rust. --native-report-json <file> requires native lowering and a nonempty path.

    The common compiler resource options require positive integer values. Unknown targets or backends, unsupported language modes, unsupported compiler combinations, output-format options, repeated options, attached values, extra entries, and missing values are rejected before compilation.

    Options and conflicts

    OptionDefaultContractConflicts
    --compiler rust|selfself

    compiler selector (default self); rust selects the reference compiler Also rejects combination with --producer, --self-source.

    None listed
    --releasefalse

    Command switch.

    None listed
    --runfalse

    Command switch.

    None listed
    --lockedfalse

    Verify topaz.lock before compiling the selected package.

    None listed
    --verbosefalse

    Reports the selected compiler and whether it was explicit or the default. For version, prints the detailed release report.

    None listed
    --root <dir>entry directory; . in package mode

    The explicit source root or package root for this invocation.

    None listed
    --out-dir <dir>Not specified

    lower + scaffold (--out-dir <dir>, required) + drive cargo to build a native binary at <dir>/target/<profile>/program (final binary only), or with --target web a wasm package at <dir>/topaz-web.wasm (--target web-worker also emits worker glue) (--release for an optimized build; --run to execute native builds after building; no entry = package mode) Required. build requires --out-dir <dir> (a non-empty directory)

    None listed
    --native-report-json <file>Not specified

    checked native emit/build only: atomically write a deterministic lowering decision report without changing normal output or artifacts --native-report-json requires --backend native

    None listed
    --backend boxed|nativeboxed

    emit/build: lowering backend (default boxed). Native specialization requires --compiler rust.

    None listed
    --target native|web|web-workernative for an explicit entry; topaz.toml [build].target in package mode

    build only: native executable (default), WASM package, or worker-ready web package

    None listed
    --language-version <5.21>5.21

    language version selector

    None listed
    --compiler-memory-mib <MiB>8192

    self compiler worker memory budget (8192); overrides TOPAZ_COMPILER_MEMORY_MIB A positive integer is required. Environment input: TOPAZ_COMPILER_MEMORY_MIB.

    None listed
    --compiler-time-ms <ms>1800000

    self compilation wall-clock budget (1800000); overrides TOPAZ_COMPILER_TIME_MS A positive integer is required. Environment input: TOPAZ_COMPILER_TIME_MS.

    None listed
    -- <args...>Not specified

    run/build --run: explicit program args passed to exported main(args, stdin) (test also accepts them for checked TestHost runs)

    None listed

    Output channels

    stdout

    stderr

    Exit status

    0

    The requested artifact was installed and no requested native execution failed.

    1

    Invalid arguments, package or lock failures, parsing, resolution, checking or lowering failures, unsupported target or profile combinations, unavailable installed build tools, resource exhaustion, build-tool failure, and artifact publication failure. A requested native process that cannot start or terminates without a representable exit status also returns 1.

    nonzero

    After successful artifact publication with --run, a native program exit from 1 through 255 is returned unchanged. The built artifact remains installed.

    Effects

    The command reads source, manifest, locked dependency content, and declared extern or Lispex inputs. It builds in a Topaz-owned temporary workspace and copies the final artifact into the requested destination.

    An existing topaz-artifact.json must name the same target. Managed output paths must remain inside the destination and must not traverse symlinks. Existing unrelated files are preserved, and collisions with unowned paths are rejected.

    New artifact bytes are staged before installation. Stale files recorded by the previous artifact manifest may be removed. The new manifest is installed after the managed files. An I/O failure during installation can leave incomplete output without a completed artifact manifest and returns failure.

    Temporary workspaces and build logs may remain for storage inspection after a failed build. --run adds the filesystem and other host effects of the executed program. Those effects are governed by the applicable program host and package capabilities.

    Compilation and artifact construction use installed components and offline locked build tools. Missing build inputs cause failure rather than a registry request, toolchain download, or compiler fallback.

    Automatic native execution may perform the network operations allowed by the program host. A build without --run does not execute the application.

    The compilation identity includes the selected compiler, language mode, backend, target, build profile, source bytes, locked dependencies, runtime components, host build toolchain, and build configuration. Byte reproducibility compares artifacts with all of those inputs fixed.

    Different host toolchains, target platforms, compiler choices, or build profiles are different inputs. Temporary paths, progress timing, and build logs are not stable artifact content. Program output under --run additionally depends on its arguments, input, and host effects.

    Package mode uses the manifest entry, dependency declarations, target configuration, and capabilities. --locked verifies the existing lock before compilation and does not create or repair it.

    Registry dependencies and Lispex package configuration require locked compilation. Missing, stale, duplicate, or undeclared lock entries fail before artifact production. An entry-file build outside package mode rejects --locked.

    Build does not edit topaz.toml, update topaz.lock, or vendor missing dependency content. The emitted native build crate has its own locked offline runtime closure, separate from the package lock.

    Operation

    Link

    Choose an output directory and a target supported by the installed product. Target selection and package activation are defined in Packages, locks and targets.

    Option conditions

    Link

    --target applies to emit, build, or init only

    --release applies to build only

    --run applies to build only

    --backend native applies to emit/build only

    --native-report-json applies to emit/build only

    --native-report-json requires --backend native

    --locked applies to package-mode check, run, emit, build, test, doc, bench, compiler observe, compiler preview. Selected-entry test also accepts it when --root contains topaz.toml.

    -- program args apply to run, test, and build --run only

    --compiler cannot be combined with bootstrap --producer or --self-source

    build --target web cannot be combined with --run

    build --target web-worker cannot be combined with --run

    build requires --out-dir <dir> (a non-empty directory)

    Behavior contract

    Link
    Ruletools-commands-build.rule.behavior

    Command behavior

    Arguments and rejection

    topaz build [entry] accepts one optional source entry. Without it, the command loads topaz.toml from --root <dir>, which defaults to the current directory. With an entry, the default source root is the entry directory.

    --out-dir <dir> is required and its value must be nonempty. The target is native, web, or web-worker. An explicit --target overrides the package manifest. Otherwise a package uses [build].target and an entry build uses native.

    --release selects the optimized profile. Without it the native output uses the debug profile. --run executes a successfully built native artifact. Web targets reject --run before a build starts.

    Program arguments follow -- and are accepted when --run is present. They are passed unchanged to the built program. A program receiving explicit arguments must provide the supported exported entry contract.

    --compiler selects self or rust and defaults to self. --backend selects boxed or native and defaults to boxed. Native lowering requires --compiler rust. --native-report-json <file> requires native lowering and a nonempty path.

    The common compiler resource options require positive integer values. Unknown targets or backends, unsupported language modes, unsupported compiler combinations, output-format options, repeated options, attached values, extra entries, and missing values are rejected before compilation.

    Output

    The build writes compiler diagnostics, build progress, warnings, and the final artifact path to standard error. A build without --run leaves standard output empty.

    With --run, standard output and standard error from the program are inherited after the build succeeds. Build diagnostics remain on standard error.

    --format json is rejected because build has no JSON report mode. The optional native lowering report is a separate file with schema identifier topaz.native-lowering-report.v1. It reports lowering decisions without replacing build output or the produced artifact.

    A native build installs target/debug/program or target/release/program under the output directory, with the executable suffix required by the host. A web build installs topaz-web.wasm, topaz-web.js, and topaz-web.d.ts. A worker build also installs its worker entry and client glue.

    The destination includes topaz-artifact.json and the required license and notice files. A reached Lispex application adds its identified runtime payload and host glue to the artifact.

    Exit status

    Exit code 0 means the requested artifact was installed and no requested native execution failed.

    Exit code 1 covers invalid arguments, package or lock failures, parsing, resolution, checking or lowering failures, unsupported target or profile combinations, unavailable installed build tools, resource exhaustion, build-tool failure, and artifact publication failure.

    After a successful build with --run, the command returns the program exit code when it is representable from 0 through 255. A failed process start, signal termination, or unrepresentable process status returns 1. Program failure does not remove the built artifact.

    Filesystem effects

    The command reads source, manifest, locked dependency content, and declared extern or Lispex inputs. It builds in a Topaz-owned temporary workspace and copies the final artifact into the requested destination.

    An existing topaz-artifact.json must name the same target. Managed output paths must remain inside the destination and must not traverse symlinks. Existing unrelated files are preserved, and collisions with unowned paths are rejected.

    New artifact bytes are staged before installation. Stale files recorded by the previous artifact manifest may be removed. The new manifest is installed after the managed files. An I/O failure during installation can leave incomplete output without a completed artifact manifest and returns failure.

    Temporary workspaces and build logs may remain for storage inspection after a failed build. --run adds the filesystem and other host effects of the executed program. Those effects are governed by the applicable program host and package capabilities.

    Network access

    Compilation and artifact construction use installed components and offline locked build tools. Missing build inputs cause failure rather than a registry request, toolchain download, or compiler fallback.

    Automatic native execution may perform the network operations allowed by the program host. A build without --run does not execute the application.

    Reproducibility

    The compilation identity includes the selected compiler, language mode, backend, target, build profile, source bytes, locked dependencies, runtime components, host build toolchain, and build configuration. Byte reproducibility compares artifacts with all of those inputs fixed.

    Different host toolchains, target platforms, compiler choices, or build profiles are different inputs. Temporary paths, progress timing, and build logs are not stable artifact content. Program output under --run additionally depends on its arguments, input, and host effects.

    Packages and locks

    Package mode uses the manifest entry, dependency declarations, target configuration, and capabilities. --locked verifies the existing lock before compilation and does not create or repair it.

    Registry dependencies and Lispex package configuration require locked compilation. Missing, stale, duplicate, or undeclared lock entries fail before artifact production. An entry-file build outside package mode rejects --locked.

    Build does not edit topaz.toml, update topaz.lock, or vendor missing dependency content. The emitted native build crate has its own locked offline runtime closure, separate from the package lock.

    Why

    Building an artifact and executing it express different intentions. Keeping --run explicit lets callers request an artifact without application effects. The target chooses the resulting artifact and does not silently choose another compiler.

    Source evidence

    The linked public CLI recipe checks the exact displayed argument rejection before the requested operation. It does not execute the successful operation or verify its effects.

    Successful builds invoke host toolchains and create binary artifacts, and --run executes application code. These invocations are outside the reviewed execution allowlist. The linked recipe rejects an invalid target before building. Host and Lispex target activation require administrator-owned installed-product CI evidence.

    Example contract

    Link
    Ruletools-commands-build.rule.invocation

    Example contract

    The invocation topaz build main.tpz --language-version 5.21 --target invalid is expected to exit with 1.

    Reject an unsupported target during argument validation before producing source, building a program, or creating a binary.

    Why

    An output target selects the representation of the generated program. Rejecting an unknown target prevents the command from producing a different representation than requested.

    Source evidence

    Example

    Link

    Argument-rejection example

    Link
    main.tpzArgument-rejection exampleOpen in Playground
    1. function identity<T>(value: T) -> T {
    2. value
    3. }
    target product 5.21.3
    Expected result

    Expected result

    Textual rejection details remain Pending in the reference model. The independent Tools example gate expects exit 1.

    Reject an unsupported target during argument validation before producing source, building a program, or creating a binary.

    Source evidence

    Verification scope

    Link

    Observed with Topaz 5.21.3 on 2026-11-06T08:36:29.642Z. This invocation passed; exit 1. 3 assertions were evaluated against the independent expected result. Execution record. This result covers the displayed invocation.

    Related references

    Link

    Compiler selection

    Packages, locks and targets

    Menu

    Download