What changed, and why it matters
This commit changes the firmware's Rust build script so that when a developer turns on Rust's strict 'treat warnings as errors' mode, the same strictness is also applied to C code compiled during the build. It is purely a build tooling/CI hardening change and does not affect device behavior, user data, or runtime security.
No security action required. Treat as a normal build-quality/CI improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In src/rust/bitbox02-sys/build.rs, the extra_flags vector is made mutable and a new block inspects CARGO_ENCODED_RUSTFLAGS. If any flag equals -Dwarnings, -Werror is appended to the C compiler flags used by the cc crate when building C sources. This harmonizes Rust’s deny(warnings) behavior with C compilation in the same build, ensuring warnings fail the build in both languages.
Changed components
src/rust/bitbox02-sys/build.rsInspect captured patch +10 / −1
diff --git a/src/rust/bitbox02-sys/build.rs b/src/rust/bitbox02-sys/build.rs
index 98af9f8..1e287ca 100644
--- a/src/rust/bitbox02-sys/build.rs
+++ b/src/rust/bitbox02-sys/build.rs
@@ -270,7 +270,7 @@ pub fn main() -> Result<(), &'static str> {
let arm_sysroot = env::var("CMAKE_SYSROOT").unwrap_or("/usr/local/arm-none-eabi".to_string());
let arm_sysroot = format!("--sysroot={arm_sysroot}");
- let extra_flags = if cross_compiling {
+ let mut extra_flags = if cross_compiling {
vec![
"-D__SAMD51J20A__",
"--target=thumbv7em-none-eabi",
@@ -284,6 +284,15 @@ pub fn main() -> Result<(), &'static str> {
vec!["-DTESTING", "-D_UNIT_TEST_", "-DPRODUCT_BITBOX_MULTI=1"]
};
+ // If user enables -Dwarnings for rust we also want to enable -Werror for C.
+ if let Ok(rustflags) = std::env::var("CARGO_ENCODED_RUSTFLAGS") {
+ for flag in rustflags.split('\x1f') {
+ if flag == "-Dwarnings" {
+ extra_flags.push("-Werror");
+ }
+ }
+ }
+
let mut includes = vec![
// $INCLUDES
"../..",
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.