Skip to content

Commit 7396326

Browse files
authored
Merge pull request #168 from rust-embedded/riscv-rt-links
`riscv-rt`: add links to Cargo.toml
2 parents d9b9df3 + b8f0523 commit 7396326

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

riscv-rt/CHANGELOG.md

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

1010
### Added
1111

12+
- Add `links` field in `Cargo.toml`
1213
- Add FPU initialization
1314
- Static array for vectored-like handling of exceptions
1415
- New GitHub workflow for checking invalid labels in PRs

riscv-rt/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ documentation = "https://docs.rs/riscv-rt"
1010
keywords = ["riscv", "runtime", "startup"]
1111
license = "ISC"
1212
edition = "2021"
13+
links = "riscv-rt" # Prevent multiple versions of riscv-rt being linked
1314

1415
[features]
1516
s-mode = []

riscv-rt/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ use riscv::register::mstatus as xstatus;
423423

424424
pub use riscv_rt_macros::{entry, pre_init};
425425

426+
/// We export this static with an informative name so that if an application attempts to link
427+
/// two copies of riscv-rt together, linking will fail. We also declare a links key in
428+
/// Cargo.toml which is the more modern way to solve the same problem, but we have to keep
429+
/// __ONCE__ around to prevent linking with versions before the links key was added.
426430
#[export_name = "error: riscv-rt appears more than once in the dependency graph"]
427431
#[doc(hidden)]
428432
pub static __ONCE__: () = ();

0 commit comments

Comments
 (0)