Skip to content

Commit 37f58d9

Browse files
committed
Keep __ONCE__ for backcompat
1 parent f10a810 commit 37f58d9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cortex-m-rt/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,14 @@ 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.
696+
#[export_name = "error: cortex-m-rt appears more than once in the dependency graph"]
697+
#[doc(hidden)]
698+
pub static __ONCE__: () = ();
699+
692700
/// Registers stacked (pushed onto the stack) during an exception.
693701
#[derive(Clone, Copy)]
694702
#[repr(C)]

0 commit comments

Comments
 (0)