-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove the alloc_system
crate
#55660
Conversation
r? @dtolnay (rust_highfive has picked a reviewer for you, use r? to override) |
use alloc_system::System; | ||
|
||
#[global_allocator] | ||
static ALLOC: System = System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this and the other sanitizer crates no longer link to System
as it's not an available type to use. While a regression I think this is minor enough to allow because the default allocator is now System
(not jemalloc) which all the sanitizers are compatible that. That, plus the fact that the sanitizers are unstable
src/libstd/alloc.rs
Outdated
/// This type can be used in a `static` item | ||
/// with the `#[global_allocator]` attribute | ||
/// to force the global allocator to be the system’s one. | ||
/// (The default is jemalloc for executables, on some platforms.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to update this doc comment while you're moving it?
Looks good to me but let's run this by @SimonSapin as well: r? @SimonSapin |
Looks good to me as well, with the doc-comment for It probably doesn’t make sense anymore to show a |
src/librustc_metadata/creader.rs
Outdated
self.sess.allocator_kind.set(None); | ||
return | ||
} | ||
|
||
// At this point we've determined that we need an allocator. Let's see | ||
// if our compilation session actually needs an allocator based on what | ||
// we're emitting. | ||
let mut need_lib_alloc = false; | ||
let mut need_exe_alloc = false; | ||
let mut all_rlib = true; | ||
for ct in self.sess.crate_types.borrow().iter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this could be let all_rlib = self.sess.crate_types.borrow().iter().all(|ct| *ct == config::CrateType::Rlib)
80e88cf
to
7fa5adf
Compare
@bors: r=dtolnay,SimonSapin |
📌 Commit 7fa5adfb6cbe5f222f092fbec429e7ce40d01a57 has been approved by |
☔ The latest upstream changes (presumably #55518) made this pull request unmergeable. Please resolve the merge conflicts. |
7fa5adf
to
1116d6e
Compare
@bors: r=dtolnay,SimonSapin |
📌 Commit 1116d6e0f46fa4b8fb15c606764d429351a4271e has been approved by |
cc @frewsxcv for the sanitizer implications |
What are the sanitizer implications of this? |
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
This commit cleans up allocator injection logic found in the compiler around selecting the global allocator. It turns out that now that jemalloc is gone the compiler never actually injects anything! This means that basically everything around loading crates here and there can be easily pruned. This also removes the `exe_allocation_crate` option from custom target specs as it's no longer used by the compiler anywhere.
This commit deletes the `alloc_system` crate from the standard distribution. This unstable crate is no longer needed in the modern stable global allocator world, but rather its functionality is folded directly into the standard library. The standard library was already the only stable location to access this crate, and as a result this should not affect any stable code.
1116d6e
to
cc75903
Compare
@bors: r=dtolnay,SimonSapin |
📌 Commit cc75903 has been approved by |
…imonSapin Remove the `alloc_system` crate In what's hopefully one of the final nails in the coffin of the "old allocator story of yore" this PR deletes the `alloc_system` crate and all traces of it from the compiler. The compiler no longer needs to inject allocator crates anywhere and the `alloc_system` crate has no real reason to exist outside the standard library. The unstable `alloc_system` crate is folded directly into the standard library where its stable interface, the `System` type, remains the same. All unstable traces of `alloc_system` are removed, however.
☀️ Test successful - status-appveyor, status-travis |
/// This is based on `malloc` on Unix platforms and `HeapAlloc` on Windows, | ||
/// plus related functions. | ||
/// | ||
/// This type implements the `GlobalAlloc` trait and Rust programs by deafult |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*default
What's the story for using the system allocator in a |
So far there is no story. The point of We could probably extract the existing impls into crates on crates.io ( |
I cross-posted to |
In what's hopefully one of the final nails in the coffin of the "old allocator story of yore" this PR deletes the
alloc_system
crate and all traces of it from the compiler. The compiler no longer needs to inject allocator crates anywhere and thealloc_system
crate has no real reason to exist outside the standard library.The unstable
alloc_system
crate is folded directly into the standard library where its stable interface, theSystem
type, remains the same. All unstable traces ofalloc_system
are removed, however.