Skip to content

Commit 942a45e

Browse files
committed
riscv: build: make cfg variables more robust
Change which Cargo `CFG` environment variables are used to select the custom `cfg` variables. See #204 (comment) for discussion.
1 parent a9d3e33 commit 942a45e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

riscv/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2323
### Changed
2424

2525
- Made `asm::wfi`, `fence`, `fence_i` and `sfence` safe (ie, removed `unsafe` from their definitions)
26+
- Made `cfg` variable selection more robust for custom targets
2627

2728
## [v0.11.0] - 2024-01-14
2829

riscv/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use std::env;
22

33
fn main() {
4-
let target = env::var("TARGET").unwrap();
4+
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
55

6-
if target.starts_with("riscv32") {
6+
if target_arch == "riscv32" {
77
println!("cargo:rustc-cfg=riscv");
88
println!("cargo:rustc-cfg=riscv32");
9-
} else if target.starts_with("riscv64") {
9+
} else if target_arch == "riscv64" {
1010
println!("cargo:rustc-cfg=riscv");
1111
println!("cargo:rustc-cfg=riscv64");
1212
}

0 commit comments

Comments
 (0)