-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Linker failure when global allocator overridden in lib.rs
#112715
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Adding the full linker error output here in case it's of interest. |
I tried adding pub const NO_ALLOC_SHIM_IS_UNSTABLE: &str = "__rust_no_alloc_shim_is_unstable"; based on a brief look at the change that |
I can reproduce this. I think registering a circular dependency between the defining crate of Edit: Reading the code it references closer, I think adding I can't work on this tomorrow, but unless someone else picks it up, I will work on this. |
Finished some work early. #112794 fixes the issue. |
…-obk Fix linker failures when #[global_allocator] is used in a dependency Fixes rust-lang#112715
@bjorn3, thank you for the quick fix! |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-high |
I have a project that overrides the global allocator in
lib.rs
, and recently noticed that I can no longer link the test binary for my project with recent beta/nightly compilers.cargo bisect-rustc
points to a2b1646 which certainly looks relevant. I reproduced the error using a slightly modified example from the global allocator documentation: https://doc.rust-lang.org/stable/std/alloc/trait.GlobalAlloc.html#exampleIf I move the allocator definition from
lib.rs
tomain.rs
, I no longer have a problem. Is that the right thing to do? If so, do I need to do anything else to make sure my tests use the desired allocator?Code
I tried this code:
I expected to see this happen:
Instead, this happened:
Version it worked on
searched nightlies: from nightly-2023-05-25 to nightly-2023-06-16
regressed nightly: nightly-2023-05-26
searched commit range: c373194...a2b1646
regressed commit: a2b1646
bisected with cargo-bisect-rustc v0.6.6
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
cargo bisect-rustc -- test
@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged
The text was updated successfully, but these errors were encountered: