Skip to content

Commit fbcfff1

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 d08f531 + 37f58d9 commit fbcfff1

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

cortex-m-rt/Cargo.toml

Lines changed: 1 addition & 0 deletions
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"

cortex-m-rt/src/lib.rs

Lines changed: 4 additions & 0 deletions
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)