Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit 4d60835

Browse files
bors[bot]adamgreig
andauthored
Merge #276
276: Replace __ONCE__ with Cargo links key r=jonas-schievink a=adamgreig This would fix #275. We use the links key in cortex-m already [here](https://github.com/rust-embedded/cortex-m/blob/master/Cargo.toml#L16). See also rust-embedded/wg#467. Co-authored-by: Adam Greig <[email protected]>
2 parents 3664d46 + 134a4ed commit 4d60835

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ readme = "README.md"
1414
repository = "https://github.com/rust-embedded/cortex-m-rt"
1515
version = "0.6.11"
1616
autoexamples = true
17+
links = "cortex-m-rt" # Prevent multiple versions of cortex-m-rt being linked
1718

1819
[dependencies]
1920
r0 = "1.0"

src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,10 @@ pub use macros::exception;
689689
/// [rfc1414]: https://github.com/rust-lang/rfcs/blob/master/text/1414-rvalue_static_promotion.md
690690
pub use macros::pre_init;
691691

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

0 commit comments

Comments
 (0)