Skip to content

--target flag and cross-compilation path (§18.5) #425

Closed

Description

@ehartford

Summary

with build --target <triple> is specified, but the current driver does not expose --target in usage, one-liner option parsing, or build command handling. Cross-target selections must be represented and either built correctly or rejected loudly; they must not silently produce native output.

Spec

docs/with-specification.md:9612-9634 lists with build [--release] [--target <triple>] and states that cross-compilation is a normal mode. docs/with-specification.md:9692-9705 says BuildTarget can represent non-native targets and unsupported non-native selections must fail loudly instead of falling back to native output.

Current state

src/main.w:601-639 parses and dispatches with build, but the global flag scan does not include a target triple. src/main.w:2535-2564 prints build usage without --target, and the one-liner known-option list in src/main.w:361-368 does not reserve --target either.

The absence is especially risky because the spec forbids a silent native fallback for unsupported non-native selections.

Implementation plan

  1. Add --target <triple> and --target=<triple> parsing to the build command option parser.
  2. Thread the parsed target through the build graph/project configuration as a semantic BuildTarget, not as an opaque late linker string.
  3. For the first implementation step, accept the native triple and make any non-native triple fail loudly with a diagnostic that says cross-target codegen/linking is not implemented yet.
  4. Once backend/link support exists, use the target to select target data layout, object format, platform runtime object, linker mode, C ABI details, and any sysroot/SDK inputs.
  5. Update help text and one-liner option scanning so --target is consistently recognized where build-like options are accepted.

Test plan

  • Add CLI tests for with build --target <native-triple> and with build --target=<native-triple>.
  • Add a negative CLI test for a supported-looking non-native triple that currently fails loudly instead of producing a native binary.
  • Add a help-text test or inventory-gate coverage through Add the spec inventory gate (keywords/attributes/CLI/modules vs spec tables) #410 to ensure --target remains listed.
  • Add build graph tests proving target values survive through std.build.BuildTarget.

Acceptance criteria

  • with build --target <triple> is parsed and represented.
  • Unsupported non-native targets fail loudly and never produce native artifacts.
  • Usage/help text matches the spec.
  • with build, with build :fixpoint, with build :test, and with build :test-green pass before this issue is closed.

Dependencies

Related to #410 for keeping CLI inventories synchronized with the spec.

Traceability

From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 18.5.1.2.

Activity

  1. ehartford commented on Jun 11, 2026

    @ehartford
    ContributorAuthor

    Implemented in 5bccf1e. with build now parses --target <triple> and --target=<triple> into the build target kind, recognizes --target in one-liner/build option scanning, lists it in help, accepts native/host triples, and fails loudly for unsupported non-native or unknown triples without producing a native artifact. Verification passed with the project seed (WITH=$PWD/out/bin/with ./out/bin/with): build, fixpoint, full test suite, and test-green.

  2. added a commit that references this issue on Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions