Skip to content
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

Make a disable-jemalloc build work #43589

Merged
merged 2 commits into from
Aug 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/librustc_trans/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::session::config;
use rustc::ty::TyCtxt;
use rustc_allocator::ALLOCATOR_METHODS;
use syntax::attr;

/// The SymbolExportLevel of a symbols specifies from which kinds of crates
Expand Down Expand Up @@ -83,6 +84,14 @@ impl ExportedSymbols {
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() {
let def_id = tcx.hir.local_def_id(id);
let idx = def_id.index;
Expand Down
16 changes: 16 additions & 0 deletions src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,22 @@

#![default_lib_allocator]

// Always use alloc_system during stage0 since we don't know if the alloc_*
// crate the stage0 compiler will pick by default is enabled (e.g.
// if the user has disabled jemalloc in `./configure`).
// `force_alloc_system` is *only* intended as a workaround for local rebuilds
// with a rustc without jemalloc.
// The not(stage0+msvc) gates will only last until the next stage0 bump
#![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]
static ALLOC: alloc_system::System = alloc_system::System;

// Explicitly import the prelude. The compiler uses this same unstable attribute
// to import the prelude implicitly when building crates that depend on std.
#[prelude_import]
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/pal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const EXCEPTION_PATHS: &'static [&'static str] = &[
"src/libstd/path.rs",
"src/libstd/f32.rs",
"src/libstd/f64.rs",
"src/libstd/lib.rs", // Until next stage0 snapshot bump
"src/libstd/sys_common/mod.rs",
"src/libstd/sys_common/net.rs",
"src/libterm", // Not sure how to make this crate portable, but test needs it
Expand Down