rustc: Implement the #[global_allocator] attribute
This PR is an implementation of [RFC 1974] which specifies a new method of defining a global allocator for a program. This obsoletes the old `#![allocator]` attribute and also removes support for it. [RFC 1974]: https://github.com/rust-lang/rfcs/pull/197 The new `#[global_allocator]` attribute solves many issues encountered with the `#![allocator]` attribute such as composition and restrictions on the crate graph itself. The compiler now has much more control over the ABI of the allocator and how it's implemented, allowing much more freedom in terms of how this feature is implemented. cc #27389
This commit is contained in:
parent
4c225c4d17
commit
695dee063b
115 changed files with 2860 additions and 1201 deletions
|
|
@ -15,6 +15,7 @@ log = { version = "0.3", features = ["release_max_level_info"] }
|
|||
env_logger = { version = "0.4", default-features = false }
|
||||
proc_macro_plugin = { path = "../libproc_macro_plugin" }
|
||||
rustc = { path = "../librustc" }
|
||||
rustc_allocator = { path = "../librustc_allocator" }
|
||||
rustc_back = { path = "../librustc_back" }
|
||||
rustc_borrowck = { path = "../librustc_borrowck" }
|
||||
rustc_const_eval = { path = "../librustc_const_eval" }
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ use rustc::traits;
|
|||
use rustc::util::common::{ErrorReported, time};
|
||||
use rustc::util::nodemap::NodeSet;
|
||||
use rustc::util::fs::rename_or_copy_remove;
|
||||
use rustc_allocator as allocator;
|
||||
use rustc_borrowck as borrowck;
|
||||
use rustc_incremental::{self, IncrementalHashesMap};
|
||||
use rustc_resolve::{MakeGlobMap, Resolver};
|
||||
|
|
@ -750,6 +751,13 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
|
|||
});
|
||||
}
|
||||
|
||||
krate = time(time_passes, "creating allocators", || {
|
||||
allocator::expand::modify(&sess.parse_sess,
|
||||
&mut resolver,
|
||||
krate,
|
||||
sess.diagnostic())
|
||||
});
|
||||
|
||||
after_expand(&krate)?;
|
||||
|
||||
if sess.opts.debugging_opts.input_stats {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ extern crate graphviz;
|
|||
extern crate env_logger;
|
||||
extern crate libc;
|
||||
extern crate rustc;
|
||||
extern crate rustc_allocator;
|
||||
extern crate rustc_back;
|
||||
extern crate rustc_borrowck;
|
||||
extern crate rustc_const_eval;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue