diff --git a/riscv/CHANGELOG.md b/riscv/CHANGELOG.md index e8716944..4b5ca9e0 100644 --- a/riscv/CHANGELOG.md +++ b/riscv/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Made `asm::wfi`, `fence`, `fence_i` and `sfence` safe (ie, removed `unsafe` from their definitions) +- Made `cfg` variable selection more robust for custom targets and downstream users ## [v0.11.0] - 2024-01-14 diff --git a/riscv/build.rs b/riscv/build.rs index 30db72e7..448ab817 100644 --- a/riscv/build.rs +++ b/riscv/build.rs @@ -1,12 +1,12 @@ use std::env; fn main() { - let target = env::var("TARGET").unwrap(); + let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); - if target.starts_with("riscv32") { + if target_arch == "riscv32" { println!("cargo:rustc-cfg=riscv"); println!("cargo:rustc-cfg=riscv32"); - } else if target.starts_with("riscv64") { + } else if target_arch == "riscv64" { println!("cargo:rustc-cfg=riscv"); println!("cargo:rustc-cfg=riscv64"); }