-
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
Cannot use alloc_system allocator for binary #44510
Comments
It looks like the documentation there is unfortunately out of date - this is the way the allocator is selected now: https://github.com/rust-lang/rust/blob/master/src/doc/unstable-book/src/language-features/global-allocator.md. |
Thanks, @sfackler. Indeed, the documentation is outdated. |
is |
It's still present for the alloc_system library - it's just that the method of selecting the global allocator changed. https://github.com/rust-lang/rust/blob/master/src/liballoc_system/lib.rs#L13-L16 |
Can we please add an informative warning for |
tagging p-high and assigning myself; i think @SimonSapin or someone sent in a PR to address this? |
The book’s example became incomplete when The way to select the system allocator is now: #![feature(alloc_system, global_allocator, allocator_api)]
extern crate alloc_system;
#[global_allocator]
static A: alloc_system::System = alloc_system::System; |
According to the the book, we can override default allocator of a binary from jemelloc to system allocator by:
This feature works in previous nightly (back to Rust 1.9.0 and 1.11.0-nightly a967611 2016-05-30) according to this this blog, but it was broken in recent nightly versions.
I try to compile this code with
cargo build --release
, and here is the result:The binary should not this large, the strings results indicate that je_malloc is still used as the allocator.
Meta
rustc --version --verbose
:rustc 1.22.0-nightly (ca94c75 2017-09-10)
binary: rustc
commit-hash: ca94c75
commit-date: 2017-09-10
host: x86_64-unknown-linux-gnu
release: 1.22.0-nightly
LLVM version: 4.0
The text was updated successfully, but these errors were encountered: