Skip to content

Commit 4d96ff6

Browse files
Merge branch 'master' into vectored-rt
2 parents 7bdb6e9 + b77662f commit 4d96ff6

File tree

9 files changed

+131
-36
lines changed

9 files changed

+131
-36
lines changed

riscv-rt/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ If `v-trap` feature is enabled, this macro also generates its corresponding trap
1919
- Moved all the assembly code to `asm.rs`
2020
- Use `weak` symbols for functions such as `_mp_hook` or `_start_trap`
2121
- `abort` is now `weak`, so it is possible to link third-party libraries including this symbol.
22+
- Made `cfg` variable selection more robust for custom targets
2223
- `_start_trap_rust` now only deals with exceptions. When an interrupt is detected, it now calls
2324
to `_dispatch_interrupt`.
2425

riscv-rt/build.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,20 @@ fn parse_target(target: &str, cargo_flags: &str) -> (u32, HashSet<char>) {
7272
}
7373

7474
fn main() {
75+
println!("cargo:rustc-check-cfg=cfg(riscv)");
76+
println!("cargo:rustc-check-cfg=cfg(riscv32)");
77+
println!("cargo:rustc-check-cfg=cfg(riscv64)");
78+
for ext in ['i', 'e', 'm', 'a', 'f', 'd', 'g', 'c'] {
79+
println!("cargo:rustc-check-cfg=cfg(riscv{})", ext);
80+
}
81+
7582
let target = env::var("TARGET").unwrap();
7683
let cargo_flags = env::var("CARGO_ENCODED_RUSTFLAGS").unwrap();
7784
let _name = env::var("CARGO_PKG_NAME").unwrap();
7885

7986
// set configuration flags depending on the target
8087
if target.starts_with("riscv") {
8188
println!("cargo:rustc-cfg=riscv");
82-
8389
// This is required until target_arch & target_feature risc-v work is
8490
// stable and in-use (rust 1.75.0)
8591
let (bits, extensions) = parse_target(&target, &cargo_flags);

riscv-semihosting/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased]
77

8+
### Changed
9+
10+
- Made `cfg` variable selection more robust for custom targets
11+
812
## [v0.1.0] - 2023-01-18
913

1014
- Add recommendation for `semihosting` in README.md.

riscv-semihosting/build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use std::env;
22

33
fn main() {
4+
println!("cargo:rustc-check-cfg=cfg(riscv)");
5+
46
let target = env::var("TARGET").unwrap();
57

68
if target.starts_with("riscv") {

riscv/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
### Added
1111

1212
- Add `Mcause::from(usize)` for use in unit tests
13+
- Add `Mstatus::from(usize)` for use in unit tests
1314
- Add `Mstatus.bits()`
15+
- Add `Eq` and `PartialEq` for `pmpcfgx::{Range, Permission}`
16+
- Export `riscv::register::macros` module macros for external use
1417

1518
### Fixed
1619

@@ -21,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2124
### Changed
2225

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

2529
## [v0.11.0] - 2024-01-14
2630

riscv/build.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
use std::env;
22

33
fn main() {
4-
let target = env::var("TARGET").unwrap();
4+
println!("cargo:rustc-check-cfg=cfg(riscv)");
5+
println!("cargo:rustc-check-cfg=cfg(riscv32)");
6+
println!("cargo:rustc-check-cfg=cfg(riscv64)");
57

6-
if target.starts_with("riscv32") {
8+
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
9+
10+
if target_arch == "riscv32" {
711
println!("cargo:rustc-cfg=riscv");
812
println!("cargo:rustc-cfg=riscv32");
9-
} else if target.starts_with("riscv64") {
13+
} else if target_arch == "riscv64" {
1014
println!("cargo:rustc-cfg=riscv");
1115
println!("cargo:rustc-cfg=riscv64");
1216
}

0 commit comments

Comments
 (0)