Skip to content

Commit 56a0753

Browse files
committed
Fix cross-crate global allocators on windows
1 parent 458ba7a commit 56a0753

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/librustc_trans/back/symbol_export.rs

+9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc::util::nodemap::{FxHashMap, NodeSet};
1313
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE, INVALID_CRATE, CRATE_DEF_INDEX};
1414
use rustc::session::config;
1515
use rustc::ty::TyCtxt;
16+
use rustc_allocator::ALLOCATOR_METHODS;
1617
use syntax::attr;
1718

1819
/// The SymbolExportLevel of a symbols specifies from which kinds of crates
@@ -83,6 +84,14 @@ impl ExportedSymbols {
8384
SymbolExportLevel::C));
8485
}
8586

87+
if tcx.sess.allocator_kind.get().is_some() {
88+
for method in ALLOCATOR_METHODS {
89+
local_crate.push((format!("__rust_{}", method.name),
90+
INVALID_DEF_ID,
91+
SymbolExportLevel::Rust));
92+
}
93+
}
94+
8695
if let Some(id) = tcx.sess.derive_registrar_fn.get() {
8796
let def_id = tcx.hir.local_def_id(id);
8897
let idx = def_id.index;

src/libstd/lib.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,18 @@
319319
#![default_lib_allocator]
320320

321321
// Always use alloc_system during stage0 since we don't know if the alloc_*
322-
// crate the stage0 compiler will pick by default is available (most
323-
// obviously, if the user has disabled jemalloc in `./configure`).
322+
// crate the stage0 compiler will pick by default is enabled (e.g.
323+
// if the user has disabled jemalloc in `./configure`).
324324
// `force_alloc_system` is *only* intended as a workaround for local rebuilds
325325
// with a rustc without jemalloc.
326-
#![cfg_attr(any(stage0, feature = "force_alloc_system"), feature(global_allocator))]
327-
#[cfg(any(stage0, feature = "force_alloc_system"))]
326+
// The not(stage0+msvc) gates will only last until the next stage0 bump
327+
#![cfg_attr(all(
328+
not(all(stage0, target_env = "msvc")),
329+
any(stage0, feature = "force_alloc_system")),
330+
feature(global_allocator))]
331+
#[cfg(all(
332+
not(all(stage0, target_env = "msvc")),
333+
any(stage0, feature = "force_alloc_system")))]
328334
#[global_allocator]
329335
static ALLOC: alloc_system::System = alloc_system::System;
330336

src/tools/tidy/src/pal.rs

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const EXCEPTION_PATHS: &'static [&'static str] = &[
6969
"src/libstd/path.rs",
7070
"src/libstd/f32.rs",
7171
"src/libstd/f64.rs",
72+
"src/libstd/lib.rs", // Until next stage0 snapshot bump
7273
"src/libstd/sys_common/mod.rs",
7374
"src/libstd/sys_common/net.rs",
7475
"src/libterm", // Not sure how to make this crate portable, but test needs it

0 commit comments

Comments
 (0)