Skip to content

build: remove dead NOWARNINGS env var, restore deny-warnings for board builds - #5076

Merged
bradjc merged 2 commits into
masterfrom
dev/nowarnings-cleanup
Aug 17, 2026
Merged

bradjc merged 2 commits into
masterfrom
dev/nowarnings-cleanup

Conversation

@ppannuto

Copy link
Copy Markdown
Member

Pull Request Overview

Our Makefile was full of vestigial references to NOWARNINGS, but nothing's actually used that environment variable since 01b36bb (in 2024...).

As as consequence, ci-job-syntax, ci-job-compilation, and ci-job-debug-support-targets stopped denying warnings on board builds at all.

This PR removes the dead variable and restores deny-on-warnings for those jobs.

One of the reasons we didn't do this before is that using the RUSTFLAGS environment variable replaces other rustflags, and several of our builds rely on .cargo/config.toml rustflags for linker flags. It turns out the right way to handle this is just adding a second cargo config since cargo will merge multiple configs.

There was one latent warning that we'd been silently allowing that is also now fixed in this PR (a missing unsafe in a newly-2024 edition crate).

Testing Strategy

Verified with real injected warnings, not just inspection: confirmed ci-job-syntax/ci-job-compilation fail on a deliberately introduced warning while a plain local make check/release doesn't (and doesn't lose any board-specific flags); reverted and ran the full real ci-job-syntax and ci-job-compilation (all 61 boards) clean. make prepush passes.

TODO or Help Wanted

N/A

Checklist

  • Ran make prepush.

PR Contents

Documentation

  • No documentation updates are required.

AI Use

  • AI was used in this PR. I have read Tock's AI policy and have properly
    disclosed my AI use below.

This PR was produced by an extended Claude Code session covering investigation, implementation, and verification.

Prompts that drove the content of this PR
  1. "investigate NOWARNINGS env variable"

  2. "The Makefile sets an environment variable, NOWARNINGS, in lots of places, but it's not obvious if anything actually reads this any more?

    Is this an environment variable that possibly some subtools are sensitive to? Or is it actually not used any more?

    Investigate git history to see how the variable used to be used to inform whether it is still relevant / useful.

    Is this something we should just remove, or should we add back some logic that got lost to do something different based on the environment variable?"

    (I chose the option "Delete NOWARNINGS, restore deny-warnings for board builds" from a set of choices Claude presented.)

  3. "is CARGO_FLAGS just an arbitrary name, or a special environment variable that cargo normally pays attention to?"

  4. "I see you got the name from history, does anything in-tree use CARGO_FLAGS prior to our work here? Does our use of this variable conflict?"

  5. "yes, fix it and fold into the same commit" (in response to Claude finding the boards/opentitan/earlgrey-cw310/Makefile clobber bug)

  6. "since this environment variable is really more about how Tock wants to drive cargo rather than invoking standard cargo things, would it make sense to rename it to TOCK_CARGO_FLAGS ?"

  7. "it seems like we now have two paths that deny warnings—some things that use DENY_WARNINGS_CARGO_CONFIG and some things that manually specify RUSTFLAGS="-D warnings"

    why do we have two different ways to enable warnings?

    do we need both, can we harmonize to one?"

    (I chose "Yes, switch everything to --config" from Claude's presented options.)

  8. "Does CI still pass with these changes, or were there latent warnings slipping through that now need to be fixed" (this is what led to finding and fixing the arch/cortex-m7 bug)

I have manually reviewed the diff before opening this PR.

ppannuto and others added 2 commits August 13, 2026 10:11
…d builds

NOWARNINGS was set in ~25 places in the Makefile but nothing has read it
since RUSTFLAGS moved to `.cargo/config.toml` in 01b36bb (2024-07-15),
which dropped its only two consumers in boards/Makefile.common. This
silently regressed CI: `allcheck`/`allboards` stopped denying warnings on
board builds at all.

Restore deny-on-warnings for CI everywhere it's checked, using a single
mechanism: `cargo --config boards/cargo/deny_warnings.toml`. This merges
its `rustflags` with whatever a crate already sets via `.cargo/config.toml`
(if anything), unlike the `RUSTFLAGS` environment variable, which replaces
it outright and would have dropped required board linker flags. Board
builds thread this through a new `TOCK_CARGO_FLAGS` Makefile variable
(top-level `allcheck`/`allboards` and `boards/Makefile.common`'s
check/rustc/build invocations, named with a `TOCK_` prefix since it's not
a variable cargo itself recognizes); crate-level `cargo test` jobs pass
`--config` directly.

`boards/opentitan/earlgrey-cw310/Makefile` already used this variable
(then named `CARGO_FLAGS`) for its `BOARD_CONFIGURATION` feature-selection
option, predating this change. Renamed it to match, and switched its
`CARGO_FLAGS = ...` to `+=` so it extends rather than clobbers any value
already inherited from the environment, e.g. the new deny-warnings flag.

Drop the remaining `NOWARNINGS=true` occurrences elsewhere (miri,
qemu-runner, rustdoc, toc.sh); none of them ever read it, and they don't
deny warnings at all.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
cortex-m7's switch_to_user (an unsafe fn) called the unsafe
cortexv7m::switch_to_user_arm_v7m without an explicit `unsafe {}` block.
Under the crate's Rust 2024 edition, unsafe_op_in_unsafe_fn is
warn-by-default, which becomes a hard error (E0133) under `-D warnings`.
Sibling arch crates (cortex-m4, cortex-m4f, cortex-m33) already wrap the
identical call; cortex-m7 was the one outlier.

This was invisible to CI: it only reproduces in a real cross-compiled
per-board build (the target-gated `#[cfg(all(target_arch = "arm",
target_os = "none"))]` branch never compiles under a host-target
`cargo check`), and of the two affected boards (teensy40,
imxrt1050-evkb), neither is one of the four boards ci-job-clippy checks.
Found while restoring board-build warnings-as-errors enforcement in CI
(see the prior commit on this branch) and confirming the fix against a
full real build of all boards.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions github-actions Bot added the WG-OpenTitan In the purview of the OpenTitan working group. label Aug 13, 2026
@ppannuto ppannuto mentioned this pull request Aug 13, 2026
3 tasks done
@bradjc bradjc added the last-call Final review period for a pull request. label Aug 13, 2026
@bradjc
bradjc added this pull request to the merge queue Aug 17, 2026
Merged via the queue into master with commit cd2eca5 Aug 17, 2026
19 of 23 checks passed
@bradjc
bradjc deleted the dev/nowarnings-cleanup branch August 17, 2026 16:38
@lschuermann lschuermann mentioned this pull request Oct 7, 2026
2 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

last-call Final review period for a pull request. WG-OpenTitan In the purview of the OpenTitan working group.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants