-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
#[global_allocator] in dependent crate can be optimized away #64402
Comments
It looks like |
I think that |
@jorendorff to confirm you added |
First question, yes. Second question, no. Instead, I made a separate project to play with, and in that project |
AFAIK |
Here's the repo that shows the bug: https://github.com/jorendorff/rust-lang-bug-64402/ The allocator in this repo panics on Adding |
|
Ok, thanks for the clarification! In that case, yes, Most crates when linked don't actually have any side effect (e.g. just a bland rlib), but some crates (like the global allocator) when linked actually affect how the compiler structures things. To be conservative the As a bug the compiler could perhaps give special treatment to |
Is this also a bug that, e.g., |
@jorendorff this is what I mean by topmost crate: https://gist.github.com/mati865/05f96512240e974dec0ca9740316bde6 the same thing should apply for |
@gnzlbg I don't really know for sure, I'd try it out. If that works then |
Fixes rust-lang#64731, rust-lang#73531. See also rust-lang#64402#issuecomment-530852886
Clarify --extern documentation. Fixes rust-lang#64731, rust-lang#73531. See also rust-lang#64402 (comment)
jemallocator-global
is a library intended to make jemalloc your allocator. It works by declaring a static allocator with#[global_allocator]
.However, a downstream crate linked with
jemallocator-global
nonetheless uses the system malloc on MacOS X.After experimenting a bit with
#[global_allocator]
, it's behaving as though rustc optimizes away a whole crate if you don't seem to be using it; and it doesn't detect that the global allocator is always used.The text was updated successfully, but these errors were encountered: