Skip to content

Adopt the Rust build standard and dev-build footprint - #577

Draft
leynos wants to merge 2 commits into
mainfrom
jm5-wildside-bs
Draft

leynos wants to merge 2 commits into
mainfrom
jm5-wildside-bs

Conversation

@leynos

@leynos leynos commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Part of DF12-110

Brings wildside to both Rust build rules in one PR, because they edit the same configuration files: the dev-build footprint (concordat rust-dev-build-footprint, DF-001 to DF-003) and the build standard (rust-build-defaults, BD-001 to BD-009).

Changes

  • .cargo/config.toml: [profile.dev] gets incremental = false and debug = 0; [unstable] embed-metadata = false (the native key for dated nightlies from 2026-07-31, which the pin is on); -Zthreads=8 in [build] and the Linux target table, -Clink-arg=-fuse-ld=mold in the Linux table only (Cargo selects one rustflags source, so each repeats the frontend flag).
  • Makefile: GATE_RUST_FLAGS_ENV composes -D warnings, any inherited RUSTFLAGS and the standard flags into lint-architecture and test-rust; it refuses CARGO_BUILD_TARGET, because the linker flag is chosen from the host. RUST_FLAGS_ENV (-D warnings only) stays on the Whitaker recipes, which build their lint driver on another toolchain and must not inherit the flags.
  • CI: the build job's setup-rust step installs mold and exports RUSTFLAGS as -D warnings -Zthreads=8 -Clink-arg=-fuse-ld=mold, and the Dependabot Rust tests step restates it. The mutation workflow installs mold and its setup-commands restores the same value for cargo-mutants, because setup-rust exports -D warnings alone there. The coverage jobs are unchanged and keep -D warnings alone, so a measurement stays on the platform linker.
  • Cranelift is not adopted; the developers' guide records the exception (BD-004/BD-006). make test-rust on nightly-2026-10-28 with Cranelift selected for the dev and test profiles was stopped at 1,218 of 1,849 tests with 52 SIGABRTs (Cranelift-compiled panics find no unwind handler; for example domain::ports::cache_key::tests::coordinate_bound_is_inclusive) and domain::user::tests::new_panics_when_invalid_id failing; the suite passes on LLVM. The pin has since moved to nightly-2026-10-31; the guide says so and sets a re-measurement by 2026-11-30.
  • tests/workflow_contracts/build_standard_test.py holds the footprint settings, the configuration sources, the Makefile composition (Linux and non-Linux, via make -n), the target refusal, the Whitaker boundary, the build job's inputs and the mutation workflow. mutation_testing_test.py follows the new inputs.

Evidence

  • Before, on main 9206b8f: rust-dev-build-footprint noncompliant (DF-001, DF-002, DF-003) and rust-build-defaults noncompliant (BD-001, BD-002, BD-004, BD-008, BD-009). After, on this tree: concordat artefact rule run reports both compliant.
  • Gates through gate-slot.sh: make check-fmt, make lint (on nightly-2026-10-31), make test, make markdownlint and make nixie; make lint-makefile, make lint-actions, make lint-python, make check-fmt-python, make typecheck-python and make test-workflow-contracts also pass. Results are appended below once the run completes.
  • Expect the first CI run to be cold: the flags are part of the sccache key, so every crate misses once (about 87 minutes for build on ubicloud-standard-4, under its 120-minute ceiling).

Open PRs touching the same files: Dependabot PRs #535 and #526.

Summary by Sourcery

Adopt the repository-wide Rust build standard and development footprint across Cargo, Makefile gates, and CI.

Enhancements:

  • Adopt the Rust development-build footprint by disabling incremental state and debug information while using Cargo-managed metadata embedding.
  • Adopt the Rust build standard with parallel compilation everywhere and the mold linker on Linux, including consistent Makefile and CI flag propagation with cross-target safeguards.
  • Document the build defaults, platform-specific behavior, cache impact, and the decision not to adopt Cranelift.

CI:

  • Update build, Dependabot test, and mutation-testing workflows to install mold and apply the standard Rust flags where appropriate.

Documentation:

  • Document the Rust build standard, development footprint, linker and flag boundaries, and Cranelift exception in the developers guide.

Tests:

  • Add workflow contract coverage for Cargo settings, Makefile flag composition, target refusal, Whitaker isolation, and CI linker provisioning; update mutation workflow contracts.

Chores:

  • Update typo-checker exceptions for the new linker and workflow identifiers.

Set incremental = false, debug = 0 and embed-metadata = false for the
footprint rule, and -Zthreads=8 in every rustflags source with mold in the
Linux source for the build standard. Restate both flags where RUSTFLAGS is
assigned (the gate recipes, the build job's setup-rust, the Dependabot test
step and the mutation workflow), install mold in CI, and record why
Cranelift is not the development backend. A contract test holds the
configuration, the recipes and the CI provisioning.
@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

@sourcery-ai

sourcery-ai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR adopts the Rust build standard and development-build footprint by centralizing Cargo defaults, composing equivalent flags through Makefile and CI paths where RUSTFLAGS overrides Cargo configuration, provisioning mold on Linux runners, documenting the Cranelift exception and operational trade-offs, and enforcing the behavior with workflow contract tests.

Sequence diagram for Makefile Rust gate flag composition

sequenceDiagram
    participant Developer
    participant Makefile
    participant Cargo
    participant Rustc

    Developer->>Makefile: make test-rust
    Makefile->>Makefile: STANDARD_TARGET_GUARD
    Makefile->>Makefile: GATE_RUST_FLAGS_ENV
    Makefile->>Cargo: RUSTFLAGS=-D warnings plus inherited flags and STANDARD_RUSTFLAGS
    Cargo->>Rustc: cargo nextest run
    Rustc->>Rustc: -Zthreads=8
    alt Linux host
        Rustc->>Rustc: -Clink-arg=-fuse-ld=mold
    end
Loading

Flowchart for Cargo Rust build defaults

flowchart TD
    Start["Cargo build"] --> Profile["dev profile: incremental=false, debug=0"]
    Profile --> Metadata["embed-metadata=false"]
    Metadata --> Frontend["-Zthreads=8"]
    Frontend --> Platform{"target_os = linux?"}
    Platform -->|Yes| Mold["Use mold linker"]
    Platform -->|No| Native["Use platform linker"]
Loading

File-Level Changes

Change Details Files
Adopts the Rust development-build footprint and build-standard defaults in repository Cargo configuration.
  • Disables dev incremental compilation and debug information, and disables embedded metadata using Cargo’s native unstable setting.
  • Enables eight-thread rustc frontend compilation for all builds and mold linking on Linux only, while documenting the Cranelift exception.
.cargo/config.toml
Propagates the standard Rust flags through local build gates and preserves toolchain-specific boundaries.
  • Adds host-aware flag composition for architecture lint and Rust tests, including inherited RUSTFLAGS and a cross-target refusal.
  • Keeps Whitaker recipes on warnings-only flags.
Makefile
Configures CI and mutation testing runners to provide the Linux linker and complete build-standard flags.
  • Installs mold and exports or restates the parallel frontend and linker flags in the build and Dependabot test paths.
  • Restores the flags in mutation testing while leaving coverage behavior unchanged.
.github/workflows/ci.yml
.github/workflows/mutation-testing.yml
tests/workflow_contracts/mutation_testing_test.py
Documents the adopted defaults, operational trade-offs, and the measured Cranelift exception.
  • Explains Cargo flag-source precedence, platform behavior, cache impact, debugging overrides, and cross-compilation handling.
  • Records Cranelift test failures, the current nightly pin, and a re-measurement deadline.
docs/developers-guide.md
Adds workflow contract coverage for configuration, Makefile behavior, and CI provisioning.
  • Validates footprint settings, flag sources, Linux-only mold usage, inherited flags, target refusal, and Whitaker isolation.
  • Checks build and mutation workflow inputs and exact RUSTFLAGS composition.
tests/workflow_contracts/build_standard_test.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

codescene-access[bot]

This comment was marked as outdated.

mold names the linker, not the English word the en-GB dictionary prefers.
Ignore only the flag and the install-mold input so prose stays checked.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant