From 57016282cc3e107eca0b55bd70683621ac22e845 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Mon, 6 May 2024 18:16:27 -0700 Subject: [PATCH] Fix nightly CI by adding --check-cfg flags Emit `cargo::rustc-check-cfg=CHECK_CFG` in build.rs so that they can be cross-checked even if cfg option itself isn't set. --- riscv-rt/build.rs | 7 +++++++ riscv-semihosting/build.rs | 4 ++++ riscv/CHANGELOG.md | 1 + riscv/build.rs | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/riscv-rt/build.rs b/riscv-rt/build.rs index fa405808..64b13675 100644 --- a/riscv-rt/build.rs +++ b/riscv-rt/build.rs @@ -76,6 +76,13 @@ fn main() { let cargo_flags = env::var("CARGO_ENCODED_RUSTFLAGS").unwrap(); let _name = env::var("CARGO_PKG_NAME").unwrap(); + println!("cargo:rustc-check-cfg=cfg(riscv)"); + println!("cargo:rustc-check-cfg=cfg(riscv32)"); + println!("cargo:rustc-check-cfg=cfg(riscv64)"); + for ext in ['i', 'e', 'm', 'a', 'f', 'd', 'g', 'c'] { + println!("cargo:rustc-check-cfg=cfg(riscv{})", ext); + } + // set configuration flags depending on the target if target.starts_with("riscv") { println!("cargo:rustc-cfg=riscv"); diff --git a/riscv-semihosting/build.rs b/riscv-semihosting/build.rs index 298364fd..6c1f3d53 100644 --- a/riscv-semihosting/build.rs +++ b/riscv-semihosting/build.rs @@ -3,6 +3,10 @@ use std::env; fn main() { let target = env::var("TARGET").unwrap(); + println!("cargo:rustc-check-cfg=cfg(riscv)"); + println!("cargo:rustc-check-cfg=cfg(riscv32)"); + println!("cargo:rustc-check-cfg=cfg(riscv64)"); + if target.starts_with("riscv") { println!("cargo:rustc-cfg=riscv"); } diff --git a/riscv/CHANGELOG.md b/riscv/CHANGELOG.md index e8716944..4ca9a40f 100644 --- a/riscv/CHANGELOG.md +++ b/riscv/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Add `Mstatus::from(usize)` for use in unit tests - Add `Mstatus.bits()` - Export `riscv::register::macros` module macros for external use +- Add --check-cfg options to fix nightly CI ### Fixed diff --git a/riscv/build.rs b/riscv/build.rs index 30db72e7..25c56aa3 100644 --- a/riscv/build.rs +++ b/riscv/build.rs @@ -3,6 +3,10 @@ use std::env; fn main() { let target = env::var("TARGET").unwrap(); + println!("cargo:rustc-check-cfg=cfg(riscv)"); + println!("cargo:rustc-check-cfg=cfg(riscv32)"); + println!("cargo:rustc-check-cfg=cfg(riscv64)"); + if target.starts_with("riscv32") { println!("cargo:rustc-cfg=riscv"); println!("cargo:rustc-cfg=riscv32");