Fix cross-crate global allocators on windows
This commit is contained in:
parent
458ba7aeb5
commit
56a07539c0
3 changed files with 20 additions and 4 deletions
|
@ -13,6 +13,7 @@ use rustc::util::nodemap::{FxHashMap, NodeSet};
|
||||||
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE, INVALID_CRATE, CRATE_DEF_INDEX};
|
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE, INVALID_CRATE, CRATE_DEF_INDEX};
|
||||||
use rustc::session::config;
|
use rustc::session::config;
|
||||||
use rustc::ty::TyCtxt;
|
use rustc::ty::TyCtxt;
|
||||||
|
use rustc_allocator::ALLOCATOR_METHODS;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
|
|
||||||
/// The SymbolExportLevel of a symbols specifies from which kinds of crates
|
/// The SymbolExportLevel of a symbols specifies from which kinds of crates
|
||||||
|
@ -83,6 +84,14 @@ impl ExportedSymbols {
|
||||||
SymbolExportLevel::C));
|
SymbolExportLevel::C));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if tcx.sess.allocator_kind.get().is_some() {
|
||||||
|
for method in ALLOCATOR_METHODS {
|
||||||
|
local_crate.push((format!("__rust_{}", method.name),
|
||||||
|
INVALID_DEF_ID,
|
||||||
|
SymbolExportLevel::Rust));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(id) = tcx.sess.derive_registrar_fn.get() {
|
if let Some(id) = tcx.sess.derive_registrar_fn.get() {
|
||||||
let def_id = tcx.hir.local_def_id(id);
|
let def_id = tcx.hir.local_def_id(id);
|
||||||
let idx = def_id.index;
|
let idx = def_id.index;
|
||||||
|
|
|
@ -319,12 +319,18 @@
|
||||||
#![default_lib_allocator]
|
#![default_lib_allocator]
|
||||||
|
|
||||||
// Always use alloc_system during stage0 since we don't know if the alloc_*
|
// Always use alloc_system during stage0 since we don't know if the alloc_*
|
||||||
// crate the stage0 compiler will pick by default is available (most
|
// crate the stage0 compiler will pick by default is enabled (e.g.
|
||||||
// obviously, if the user has disabled jemalloc in `./configure`).
|
// if the user has disabled jemalloc in `./configure`).
|
||||||
// `force_alloc_system` is *only* intended as a workaround for local rebuilds
|
// `force_alloc_system` is *only* intended as a workaround for local rebuilds
|
||||||
// with a rustc without jemalloc.
|
// with a rustc without jemalloc.
|
||||||
#![cfg_attr(any(stage0, feature = "force_alloc_system"), feature(global_allocator))]
|
// The not(stage0+msvc) gates will only last until the next stage0 bump
|
||||||
#[cfg(any(stage0, feature = "force_alloc_system"))]
|
#![cfg_attr(all(
|
||||||
|
not(all(stage0, target_env = "msvc")),
|
||||||
|
any(stage0, feature = "force_alloc_system")),
|
||||||
|
feature(global_allocator))]
|
||||||
|
#[cfg(all(
|
||||||
|
not(all(stage0, target_env = "msvc")),
|
||||||
|
any(stage0, feature = "force_alloc_system")))]
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static ALLOC: alloc_system::System = alloc_system::System;
|
static ALLOC: alloc_system::System = alloc_system::System;
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ const EXCEPTION_PATHS: &'static [&'static str] = &[
|
||||||
"src/libstd/path.rs",
|
"src/libstd/path.rs",
|
||||||
"src/libstd/f32.rs",
|
"src/libstd/f32.rs",
|
||||||
"src/libstd/f64.rs",
|
"src/libstd/f64.rs",
|
||||||
|
"src/libstd/lib.rs", // Until next stage0 snapshot bump
|
||||||
"src/libstd/sys_common/mod.rs",
|
"src/libstd/sys_common/mod.rs",
|
||||||
"src/libstd/sys_common/net.rs",
|
"src/libstd/sys_common/net.rs",
|
||||||
"src/libterm", // Not sure how to make this crate portable, but test needs it
|
"src/libterm", // Not sure how to make this crate portable, but test needs it
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue