-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Jemalloc sneaking in even with force_alloc_system #43524
Comments
I left a comment in that linked issue, but in short -
|
Thanks for the hints. After some experimentation I discovered it works when:
So, the question is, should it also work with |
It should probably work with |
#43589 does not fix this. It looks like the only allocation crate able to be pulled in explicitly as the default exe crate is jemalloc, since it's the only crate containing functions with the By setting exe allocator to Thoughts @alexcrichton? |
Right now the compiler isn't equipped to deal with |
Yes, setting it to As I said above, my real problem was solved by the |
Yeah in some sense this is deep within the internals of the compiler and is defacto pretty unstable. I'm fine fixing "bugs" like this but I don't think they'll be proactively fixed unless you'd like to endeavour to do so |
I actually want to start contributing code into the compiler and this could be a nice first one, for two reasons. Nobody really cares much how long this takes to fix and fixing it could be a fitting punishment for me opening such a useless and stupid issue 😇 However, as the code base is quite large, I'd use a pointer or two into the general direction in which to start digging. I think the solution to hijack the value somewhere on its way, special case it and replace it with |
Oh that'd be awesome! Right now there's three kinds of allocators each with their own prefix and the session's allocator kind is set in this function. We'd probably just want a way to configure the "allocator kind" by looking at the attributes in the crate rather than inferring based on the custom target spec. |
OK, so I've read all the relevant code I could find ( Now I see why I got the errors above and what they meant. However, I don't see an obvious next course of action. I understand the function you linked ( So, I have a few questions:
|
The various issues and RFCs tend to not go much into the implementation details, so for that you're mostly just relegated to code and comments to figure that out. Here what's happening is that the compiler just needs to select the right prefix for specifically the |
Autodetect the type of allocator crate used Annotate the allocator crates (allocator_system, allocator_jemalloc) by the type of allocator they are. If one is requested as an exe allocator, detect its type by the flags. This has the effect that using this (de jure wrong) configuration in the target spec works instead of producing a really unhelpful and arcane linker error: "exe-allocation-crate": "alloc_system" Fixes #43524. There are two yet unsolved FIXME's, I'll be glad for some advice on what to do with them.
Hello
I'm experimenting with some cross-compilation, using xargo. I have my own target description and a script that downloads SDK for the device and uses that to build the corresponding std.
If I enable jemalloc, I can compile a binary (with some other hacks) and it works. But I'd like to strip the size of the binary, so I'd prefer to use the system allocator instead. When I switch to use
force_alloc_system
and"exe-allocation-crate": "alloc_system"
in the target description, it fails to link with bunch of missing references, like__rde_dealloc
. Grepping the sources, these come fromliballoc_jemalloc
crate. So it seems, no matter what I do, some part of jemalloc (the rust part) gets pulled in, but the C part is not compiled.Experimenting with older nightlies, the first broken version is ‒ the compilation with system allocator works in older ones (and produces ~130kB smaller binary):
I have the code in this repository: https://github.com/vorner/xcompile. There's a build script that, when run, downloads the SDK (that one is a bit largish), copies current rust sources (yes, this needs
rustup component add rust-src
), patches them a little bit (I had some problems with libunwind) and compiles it. It doesn't clean things, so I always delete the sysroot and the sources between experiments (rm -rf ~/.xargo target rust-src
).There are two relevant (very similar) branches,
with_jemalloc
andwith_sys_alloc
.I think this might be somewhat related to this report: #43510, but the observable effects are quite different.
I noticed there's that new
#[global_allocator]
attribute, and I'll read its documentation, but theforce_alloc_system
feature is still available, so I believe it wasn't the intention to deprecate it.The text was updated successfully, but these errors were encountered: