From b8f0523d16dd828b25e3540ca96a6996eeee7da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rom=C3=A1n=20C=C3=A1rdenas?= Date: Tue, 19 Dec 2023 14:09:44 +0100 Subject: [PATCH] add links to Cargo.toml --- riscv-rt/CHANGELOG.md | 1 + riscv-rt/Cargo.toml | 1 + riscv-rt/src/lib.rs | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/riscv-rt/CHANGELOG.md b/riscv-rt/CHANGELOG.md index ecbb8a5d..ba54c538 100644 --- a/riscv-rt/CHANGELOG.md +++ b/riscv-rt/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added +- Add `links` field in `Cargo.toml` - Add FPU initialization - Static array for vectored-like handling of exceptions - New GitHub workflow for checking invalid labels in PRs diff --git a/riscv-rt/Cargo.toml b/riscv-rt/Cargo.toml index bd00de4b..3bb41590 100644 --- a/riscv-rt/Cargo.toml +++ b/riscv-rt/Cargo.toml @@ -10,6 +10,7 @@ documentation = "https://docs.rs/riscv-rt" keywords = ["riscv", "runtime", "startup"] license = "ISC" edition = "2021" +links = "riscv-rt" # Prevent multiple versions of riscv-rt being linked [features] s-mode = [] diff --git a/riscv-rt/src/lib.rs b/riscv-rt/src/lib.rs index a7a900eb..b82fed40 100644 --- a/riscv-rt/src/lib.rs +++ b/riscv-rt/src/lib.rs @@ -423,6 +423,10 @@ use riscv::register::mstatus as xstatus; pub use riscv_rt_macros::{entry, pre_init}; +/// We export this static with an informative name so that if an application attempts to link +/// two copies of riscv-rt together, linking will fail. We also declare a links key in +/// Cargo.toml which is the more modern way to solve the same problem, but we have to keep +/// __ONCE__ around to prevent linking with versions before the links key was added. #[export_name = "error: riscv-rt appears more than once in the dependency graph"] #[doc(hidden)] pub static __ONCE__: () = ();