-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Data silently disappeared with certain configuration on Linux #31
Comments
Looks like this compiler bug: rust-lang/rust#47384. If nothing else from the enclosing module is used by the program, the whole module is incorrectly dropped. |
Thanks for filing this issue @crlf0710 and the link @dtolnay. I think this problem is the same with inventory/issues#32. I wanted to switch over to linkme from inventory, but the same problem appears here.
I can confirm that your repository runs fine with |
I now added this to my [profile.dev]
codegen-units = 1
[profile.release]
codegen-units = 1 |
Even this didn't work for me. I had to explicitly use something from the relevant crate to get Rust to populate the distributed slice. That is to say, this code leads to a panic: // Binary crate
assert_eq!(STORAGE_SYSTEM.len(), 1);
// Downstream "plugin" crate
#[distributed_slice(STORAGE_SYSTEM)]
fn make_storage_provider() -> Box<dyn StorageProvider> {
Box::new(FileStorageProvider)
} and this code does not lead to a panic: // Binary crate
let _nine = file::foo();
assert_eq!(STORAGE_SYSTEM.len(), 1);
// Downstream "plugin" crate
pub fn foo() -> usize {
9
}
#[distributed_slice(STORAGE_SYSTEM)]
fn make_storage_provider() -> Box<dyn StorageProvider> {
Box::new(FileStorageProvider)
} If it matters, my distributed slice |
This is fixed in rustc 1.62.0 / linkme 0.3.0. |
The repro project still fails the assertion for me using rustc 1.62.1 and linkme 0.3.0 (macOS) |
@dtolnay I can also reproduce it in Inventory 0.3.1 on rustc 1.65-nightly, macOS – see getditto/safer_ffi#131 (no minimum reproducible repo at this moment 😞). Is there any approach that can workaround that? |
Ran into this with
Where I register objects in |
The macOS-specific issue is tracked in #61. |
I am not sure if I should open a new issue for this, but I thought that this would work since 1.62:
Unless I do My rust version is: |
I created a minimal repro project at https://github.com/crlf0710/linkme_bug_repro/
To reproduce: run
cargo run
, the program will panic (the distributed slice is empty), while it should be not (there is one data entry inmodule sub
within theinner
crate.)Interestingly, if you comment the
module sub
part out (lifting the definition to toplevel), the program will work fine.The text was updated successfully, but these errors were encountered: