Skip to content

Commit 6c5212f

Browse files
committed
Auto merge of #43589 - aidanhs:aphs-fix-system-malloc, r=alexcrichton
Make a disable-jemalloc build work Fixes #43510. I've tested this up to building a stage1 compiler. r? @alexcrichton cc @cuviper @vorner @cuviper your fix was almost correct, you just had a stray `!` in there which caused the second error you saw.
2 parents 13d94d5 + 56a0753 commit 6c5212f

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
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

+16
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,22 @@
318318

319319
#![default_lib_allocator]
320320

321+
// Always use alloc_system during stage0 since we don't know if the alloc_*
322+
// crate the stage0 compiler will pick by default is enabled (e.g.
323+
// if the user has disabled jemalloc in `./configure`).
324+
// `force_alloc_system` is *only* intended as a workaround for local rebuilds
325+
// with a rustc without jemalloc.
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")))]
334+
#[global_allocator]
335+
static ALLOC: alloc_system::System = alloc_system::System;
336+
321337
// Explicitly import the prelude. The compiler uses this same unstable attribute
322338
// to import the prelude implicitly when building crates that depend on std.
323339
#[prelude_import]

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)