-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Cargo's links = "name"
feature in singleton crates
#467
Comments
In general 👍 on this. For the PACs, we don't host them in the wg, and svd2rust doesn't generate What value do you think PACs should use for the links key? I wonder if just |
Yeah, makes sense to use a shared key. We should probably document this in a central place (maybe this repo?). And, I suppose, I'd like svd2rust to generate Cargo.toml then. |
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]>
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]>
We have several crates that only support linking a single version of them into a crate graph. These crates include:
cortex-m-rt
,riscv-rt
,msp430-rt
, ...cortex-m
and all svd2rust-generated PACs.take()
theirPeripherals
twice.Currently, these crates define a
#[no_mangle]
symbol to ensure that only a single version of them is linked to by an application, causing a linker error when more than one version is present.Another way to do this is to use Cargo's
links = "<name>"
feature, which was designed to support precisely this use case (only for linking to C libraries that have global state). I think we should switch every crate to use the Cargo feature, since it was designed for this, gives a better error message, and cannot fail when no methods from one of the versions are called (a shortcoming of the current approach).To do this, we need to migrate slowly, since removing the clashing symbol removes the protection with older versions of the library. That means, we start by adding a
links
key to all affected crates, and only after a couple of releases we remove the clashing symbol.The text was updated successfully, but these errors were encountered: