Skip to content

First party debug flag for cargo oxide build #1255

Closed

Description

@forrest-angus

What problem does this solve?

I have a Maturin-based (pyo3) scientific pipeline where I occasionally need to compile conditional gpu_printf! macros diagnostics into kernels. cargo oxide build currently uses the release-like policy, so it always applies -Copt-level=3 -Cdebug-assertions=off, including when preparing the environment for maturin develop.

Proposed API / behavior

--debug-assertions = -Copt-level=3 -Cdebug-assertions=on -Coverflow-checks=off
seems like the sensible choice of flag for the issue. It keeps the whole example suite working while overflow checks stay a separate decision.

Nihal's perspective

  • more MIR : debug_assert! checks and the panic paths behind them, plus your cfg(debug_assertions) code. All of that translates fine today; a failing assert becomes a device trap.
  • overflow checks come along for free: rustc turns -Coverflow-checks on whenever debug-assertions is on. Every + and * grows a check and a trap. That changes the MIR enough to break at least one pattern-sensitive lowering (the WGMMA accumulator-fusion path stops recognising its K-loop).
flag                                     
examples compiling
debug-assertions=on, overflow follows    225 / 227
debug-assertions=on, overflow off        227 / 227

Alternatives considered

For my current project I am using a Cargo feature as a local workaround. I wanted to check whether exposing the independent rustc setting fits the intended profile model before potentially creating an issue.

cargo oxide build --device-cfg gpu_diag plus #[cfg(gpu_diag)] also exists today but seems like a workaround instead of having a toggle.

Activity

  1. added
    enhancement
    TBD
    on Sep 8, 2026
  2. uurl commented on Sep 10, 2026

    @uurl
    Contributor

    I can take a pass at this.

    My intended scope would be limited to cargo oxide build --debug-assertions, keeping the existing release-like optimization policy while switching the wrapper-owned rustc flags to:

    -Copt-level=3
    -Cdebug-assertions=on
    -Coverflow-checks=off
    

    I would model this as a separate CodegenProfilePolicy rather than changing the backend or the existing ReleaseLike semantics, and cover the regular build, Cargo passthrough, and metadata interop device-build paths.

    I’ll keep cargo oxide test unchanged so Cargo remains authoritative for its selected profile.

    If that policy shape is undesirable, please let me know; otherwise I’ll send a draft PR against #1255.

  3. added
    cargo-oxide
    and removed
    TBD
    on Sep 15, 2026
  4. nihalpasham commented on Sep 15, 2026

    @nihalpasham
    Collaborator

    #1258 is ready after maintainer rebase and implements this request.

    cargo oxide build --debug-assertions
      -> optimization 3, assertions on, overflow checks off
    
    • Ordinary, Cargo passthrough and metadata device builds are covered.
    • Full-debug handling is preserved; test profiles remain Cargo-owned.
    • CLI tests, actual device on/off controls and hosted CI pass.

    Keeping this issue open until the PR is merged.

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

    cargo-oxideenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions