Skip to content

Commit

Permalink
Fix nightly CI by adding --check-cfg flags
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jsgf committed May 7, 2024
1 parent a9d3e33 commit 5701628
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions riscv-rt/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 4 additions & 0 deletions riscv-semihosting/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
1 change: 1 addition & 0 deletions riscv/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions riscv/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 5701628

Please sign in to comment.