From 7cf12f9e1d48ef481f59b5b1aca95a806a0c84f0 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 3 Jul 2018 15:56:37 +0200 Subject: [PATCH 1/5] Disable jemalloc on all platforms --- src/Cargo.lock | 12 ------------ src/librustc_target/spec/mod.rs | 6 +----- src/libstd/Cargo.toml | 5 ++--- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 7b5b86d39fc52..800a76e64494e 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -15,17 +15,6 @@ dependencies = [ "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "alloc_jemalloc" -version = "0.0.0" -dependencies = [ - "build_helper 0.1.0", - "cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.0.0", - "core 0.0.0", - "libc 0.0.0", -] - [[package]] name = "alloc_system" version = "0.0.0" @@ -2638,7 +2627,6 @@ name = "std" version = "0.0.0" dependencies = [ "alloc 0.0.0", - "alloc_jemalloc 0.0.0", "alloc_system 0.0.0", "build_helper 0.1.0", "cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index e54cd773123c8..e6cf1bfc8ec54 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -1182,11 +1182,7 @@ impl ToJson for Target { } fn maybe_jemalloc() -> Option { - if cfg!(feature = "jemalloc") { - Some("alloc_jemalloc".to_string()) - } else { - None - } + None } /// Either a target triple string or a path to a JSON file. diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 5a2dce5930a4b..09a4f655e0406 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -14,7 +14,6 @@ crate-type = ["dylib", "rlib"] [dependencies] alloc = { path = "../liballoc" } -alloc_jemalloc = { path = "../liballoc_jemalloc", optional = true } alloc_system = { path = "../liballoc_system" } panic_unwind = { path = "../libpanic_unwind", optional = true } panic_abort = { path = "../libpanic_abort" } @@ -44,8 +43,8 @@ build_helper = { path = "../build_helper" } [features] backtrace = [] -debug-jemalloc = ["alloc_jemalloc/debug"] -jemalloc = ["alloc_jemalloc"] +debug-jemalloc = [] +jemalloc = [] force_alloc_system = [] panic-unwind = ["panic_unwind"] profiler = ["profiler_builtins"] From 7ca729af7dc27516535c49c620a58089868bd6b7 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 3 Jul 2018 15:59:05 +0200 Subject: [PATCH 2/5] Remove alloc_jemalloc crate --- src/liballoc_jemalloc/Cargo.toml | 24 --- src/liballoc_jemalloc/build.rs | 152 ------------------- src/liballoc_jemalloc/lib.rs | 130 ---------------- src/liballoc_jemalloc/pthread_atfork_dummy.c | 16 -- 4 files changed, 322 deletions(-) delete mode 100644 src/liballoc_jemalloc/Cargo.toml delete mode 100644 src/liballoc_jemalloc/build.rs delete mode 100644 src/liballoc_jemalloc/lib.rs delete mode 100644 src/liballoc_jemalloc/pthread_atfork_dummy.c diff --git a/src/liballoc_jemalloc/Cargo.toml b/src/liballoc_jemalloc/Cargo.toml deleted file mode 100644 index 7986d5dd2eb54..0000000000000 --- a/src/liballoc_jemalloc/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -authors = ["The Rust Project Developers"] -name = "alloc_jemalloc" -version = "0.0.0" -build = "build.rs" -links = "jemalloc" - -[lib] -name = "alloc_jemalloc" -path = "lib.rs" -test = false -doc = false - -[dependencies] -core = { path = "../libcore" } -libc = { path = "../rustc/libc_shim" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } - -[build-dependencies] -build_helper = { path = "../build_helper" } -cc = "1.0.1" - -[features] -debug = [] diff --git a/src/liballoc_jemalloc/build.rs b/src/liballoc_jemalloc/build.rs deleted file mode 100644 index 0aa46dc6d205f..0000000000000 --- a/src/liballoc_jemalloc/build.rs +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(warnings)] - -extern crate build_helper; -extern crate cc; - -use std::env; -use std::path::PathBuf; -use std::process::Command; -use build_helper::{run, native_lib_boilerplate}; - -fn main() { - // FIXME: This is a hack to support building targets that don't - // support jemalloc alongside hosts that do. The jemalloc build is - // controlled by a feature of the std crate, and if that feature - // changes between targets, it invalidates the fingerprint of - // std's build script (this is a cargo bug); so we must ensure - // that the feature set used by std is the same across all - // targets, which means we have to build the alloc_jemalloc crate - // for targets like emscripten, even if we don't use it. - let target = env::var("TARGET").expect("TARGET was not set"); - let host = env::var("HOST").expect("HOST was not set"); - if target.contains("bitrig") || target.contains("emscripten") || target.contains("fuchsia") || - target.contains("msvc") || target.contains("openbsd") || target.contains("redox") || - target.contains("rumprun") || target.contains("wasm32") { - println!("cargo:rustc-cfg=dummy_jemalloc"); - return; - } - - // CloudABI ships with a copy of jemalloc that has been patched to - // work well with sandboxing. Don't attempt to build our own copy, - // as it won't build. - if target.contains("cloudabi") { - return; - } - - if target.contains("android") { - println!("cargo:rustc-link-lib=gcc"); - } else if !target.contains("windows") && !target.contains("musl") { - println!("cargo:rustc-link-lib=pthread"); - } - - if let Some(jemalloc) = env::var_os("JEMALLOC_OVERRIDE") { - let jemalloc = PathBuf::from(jemalloc); - println!("cargo:rustc-link-search=native={}", - jemalloc.parent().unwrap().display()); - let stem = jemalloc.file_stem().unwrap().to_str().unwrap(); - let name = jemalloc.file_name().unwrap().to_str().unwrap(); - let kind = if name.ends_with(".a") { - "static" - } else { - "dylib" - }; - println!("cargo:rustc-link-lib={}={}", kind, &stem[3..]); - return; - } - - let link_name = if target.contains("windows") { "jemalloc" } else { "jemalloc_pic" }; - let native = match native_lib_boilerplate("jemalloc", "jemalloc", link_name, "lib") { - Ok(native) => native, - _ => return, - }; - - let mut cmd = Command::new("sh"); - cmd.arg(native.src_dir.join("configure") - .to_str() - .unwrap() - .replace("C:\\", "/c/") - .replace("\\", "/")) - .current_dir(&native.out_dir) - // jemalloc generates Makefile deps using GCC's "-MM" flag. This means - // that GCC will run the preprocessor, and only the preprocessor, over - // jemalloc's source files. If we don't specify CPPFLAGS, then at least - // on ARM that step fails with a "Missing implementation for 32-bit - // atomic operations" error. This is because no "-march" flag will be - // passed to GCC, and then GCC won't define the - // "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4" macro that jemalloc needs to - // select an atomic operation implementation. - .env("CPPFLAGS", env::var_os("CFLAGS").unwrap_or_default()); - - if target.contains("ios") { - cmd.arg("--disable-tls"); - } else if target.contains("android") { - // We force android to have prefixed symbols because apparently - // replacement of the libc allocator doesn't quite work. When this was - // tested (unprefixed symbols), it was found that the `realpath` - // function in libc would allocate with libc malloc (not jemalloc - // malloc), and then the standard library would free with jemalloc free, - // causing a segfault. - // - // If the test suite passes, however, without symbol prefixes then we - // should be good to go! - cmd.arg("--with-jemalloc-prefix=je_"); - cmd.arg("--disable-tls"); - } else if target.contains("dragonfly") || target.contains("musl") { - cmd.arg("--with-jemalloc-prefix=je_"); - } - - // FIXME: building with jemalloc assertions is currently broken. - // See . - //if cfg!(feature = "debug") { - // cmd.arg("--enable-debug"); - //} - - cmd.arg(format!("--host={}", build_helper::gnu_target(&target))); - cmd.arg(format!("--build={}", build_helper::gnu_target(&host))); - - // for some reason, jemalloc configure doesn't detect this value - // automatically for this target - if target == "sparc64-unknown-linux-gnu" { - cmd.arg("--with-lg-quantum=4"); - } - - run(&mut cmd); - - let mut make = Command::new(build_helper::make(&host)); - make.current_dir(&native.out_dir) - .arg("build_lib_static"); - - // These are intended for mingw32-make which we don't use - if cfg!(windows) { - make.env_remove("MAKEFLAGS").env_remove("MFLAGS"); - } - - // mingw make seems... buggy? unclear... - if !host.contains("windows") { - make.arg("-j") - .arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")); - } - - run(&mut make); - - // The pthread_atfork symbols is used by jemalloc on android but the really - // old android we're building on doesn't have them defined, so just make - // sure the symbols are available. - if target.contains("androideabi") { - println!("cargo:rerun-if-changed=pthread_atfork_dummy.c"); - cc::Build::new() - .flag("-fvisibility=hidden") - .file("pthread_atfork_dummy.c") - .compile("pthread_atfork_dummy"); - } -} diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs deleted file mode 100644 index b3b20715511a7..0000000000000 --- a/src/liballoc_jemalloc/lib.rs +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![no_std] -#![allow(unused_attributes)] -#![unstable(feature = "alloc_jemalloc", - reason = "implementation detail of std, does not provide any public API", - issue = "0")] -#![feature(core_intrinsics)] -#![feature(libc)] -#![feature(linkage)] -#![feature(staged_api)] -#![feature(rustc_attrs)] -#![cfg_attr(dummy_jemalloc, allow(dead_code, unused_extern_crates))] -#![cfg_attr(not(dummy_jemalloc), feature(allocator_api))] -#![rustc_alloc_kind = "exe"] - -extern crate libc; - -#[cfg(not(dummy_jemalloc))] -pub use contents::*; -#[cfg(not(dummy_jemalloc))] -mod contents { - use libc::{c_int, c_void, size_t}; - - // Note that the symbols here are prefixed by default on macOS and Windows (we - // don't explicitly request it), and on Android and DragonFly we explicitly - // request it as unprefixing cause segfaults (mismatches in allocators). - extern "C" { - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", - target_os = "dragonfly", target_os = "windows", target_env = "musl"), - link_name = "je_mallocx")] - fn mallocx(size: size_t, flags: c_int) -> *mut c_void; - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", - target_os = "dragonfly", target_os = "windows", target_env = "musl"), - link_name = "je_calloc")] - fn calloc(size: size_t, flags: c_int) -> *mut c_void; - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", - target_os = "dragonfly", target_os = "windows", target_env = "musl"), - link_name = "je_rallocx")] - fn rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void; - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", - target_os = "dragonfly", target_os = "windows", target_env = "musl"), - link_name = "je_sdallocx")] - fn sdallocx(ptr: *mut c_void, size: size_t, flags: c_int); - } - - const MALLOCX_ZERO: c_int = 0x40; - - // The minimum alignment guaranteed by the architecture. This value is used to - // add fast paths for low alignment values. - #[cfg(all(any(target_arch = "arm", - target_arch = "mips", - target_arch = "powerpc")))] - const MIN_ALIGN: usize = 8; - #[cfg(all(any(target_arch = "x86", - target_arch = "x86_64", - target_arch = "aarch64", - target_arch = "powerpc64", - target_arch = "mips64", - target_arch = "s390x", - target_arch = "sparc64")))] - const MIN_ALIGN: usize = 16; - - // MALLOCX_ALIGN(a) macro - fn mallocx_align(a: usize) -> c_int { - a.trailing_zeros() as c_int - } - - fn align_to_flags(align: usize, size: usize) -> c_int { - if align <= MIN_ALIGN && align <= size { - 0 - } else { - mallocx_align(align) - } - } - - // for symbol names src/librustc/middle/allocator.rs - // for signatures src/librustc_allocator/lib.rs - - // linkage directives are provided as part of the current compiler allocator - // ABI - - #[no_mangle] - #[rustc_std_internal_symbol] - pub unsafe extern fn __rde_alloc(size: usize, align: usize) -> *mut u8 { - let flags = align_to_flags(align, size); - let ptr = mallocx(size as size_t, flags) as *mut u8; - ptr - } - - #[no_mangle] - #[rustc_std_internal_symbol] - pub unsafe extern fn __rde_dealloc(ptr: *mut u8, - size: usize, - align: usize) { - let flags = align_to_flags(align, size); - sdallocx(ptr as *mut c_void, size, flags); - } - - #[no_mangle] - #[rustc_std_internal_symbol] - pub unsafe extern fn __rde_realloc(ptr: *mut u8, - _old_size: usize, - align: usize, - new_size: usize) -> *mut u8 { - let flags = align_to_flags(align, new_size); - let ptr = rallocx(ptr as *mut c_void, new_size, flags) as *mut u8; - ptr - } - - #[no_mangle] - #[rustc_std_internal_symbol] - pub unsafe extern fn __rde_alloc_zeroed(size: usize, align: usize) -> *mut u8 { - let ptr = if align <= MIN_ALIGN && align <= size { - calloc(size as size_t, 1) as *mut u8 - } else { - let flags = align_to_flags(align, size) | MALLOCX_ZERO; - mallocx(size as size_t, flags) as *mut u8 - }; - ptr - } -} diff --git a/src/liballoc_jemalloc/pthread_atfork_dummy.c b/src/liballoc_jemalloc/pthread_atfork_dummy.c deleted file mode 100644 index 4e3df0ab26c37..0000000000000 --- a/src/liballoc_jemalloc/pthread_atfork_dummy.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// See comments in build.rs for why this exists -int pthread_atfork(void* prefork, - void* postfork_parent, - void* postfork_child) { - return 0; -} From 116e2df1f9bdb324c0569d76ceb348e5a7c17a41 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 3 Jul 2018 15:59:22 +0200 Subject: [PATCH 3/5] Remove jemalloc submodule --- .gitmodules | 3 --- src/jemalloc | 1 - 2 files changed, 4 deletions(-) delete mode 160000 src/jemalloc diff --git a/.gitmodules b/.gitmodules index f3eb902709ca7..7efdbe50f325b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,9 +2,6 @@ path = src/llvm url = https://github.com/rust-lang/llvm.git branch = master -[submodule "src/jemalloc"] - path = src/jemalloc - url = https://github.com/rust-lang/jemalloc.git [submodule "src/rust-installer"] path = src/tools/rust-installer url = https://github.com/rust-lang/rust-installer.git diff --git a/src/jemalloc b/src/jemalloc deleted file mode 160000 index 1f5a28755e301..0000000000000 --- a/src/jemalloc +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1f5a28755e301ac581e2048011e4e0ff3da482ef From bee536e39ca61d7c99c803bf3bd6429f9c706413 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 3 Jul 2018 16:17:51 +0200 Subject: [PATCH 4/5] Remove remaining alloc_jemalloc-related code --- COPYRIGHT | 32 --------- config.toml.example | 10 --- src/bootstrap/bootstrap.py | 5 -- src/bootstrap/compile.rs | 16 +---- src/bootstrap/config.rs | 14 ---- src/bootstrap/configure.py | 5 -- src/bootstrap/dist.rs | 3 - src/bootstrap/lib.rs | 14 +--- src/bootstrap/sanity.rs | 6 -- src/bootstrap/test.rs | 5 +- .../disabled/dist-x86_64-haiku/Dockerfile | 2 +- src/liballoc/tests/heap.rs | 2 +- src/librustc/middle/allocator.rs | 6 +- src/librustc/middle/dependency_format.rs | 15 ---- src/librustc/session/mod.rs | 2 - src/librustc_codegen_llvm/Cargo.toml | 4 -- src/librustc_metadata/creader.rs | 70 +++---------------- src/librustc_target/Cargo.toml | 3 - .../spec/aarch64_unknown_freebsd.rs | 1 - .../spec/aarch64_unknown_linux_gnu.rs | 1 - .../spec/aarch64_unknown_linux_musl.rs | 1 - src/librustc_target/spec/apple_base.rs | 1 - src/librustc_target/spec/apple_ios_base.rs | 1 - src/librustc_target/spec/cloudabi_base.rs | 1 - src/librustc_target/spec/dragonfly_base.rs | 1 - src/librustc_target/spec/freebsd_base.rs | 1 - src/librustc_target/spec/l4re_base.rs | 1 - src/librustc_target/spec/linux_base.rs | 1 - .../spec/mips64_unknown_linux_gnuabi64.rs | 1 - .../spec/mips64el_unknown_linux_gnuabi64.rs | 1 - .../spec/mips_unknown_linux_gnu.rs | 1 - .../spec/mips_unknown_linux_musl.rs | 1 - .../spec/mips_unknown_linux_uclibc.rs | 1 - .../spec/mipsel_unknown_linux_gnu.rs | 1 - .../spec/mipsel_unknown_linux_musl.rs | 1 - .../spec/mipsel_unknown_linux_uclibc.rs | 1 - src/librustc_target/spec/mod.rs | 10 --- .../spec/powerpc64_unknown_linux_gnu.rs | 1 - .../spec/powerpc64le_unknown_linux_gnu.rs | 1 - .../spec/powerpc_unknown_linux_gnu.rs | 1 - .../spec/powerpc_unknown_linux_gnuspe.rs | 1 - .../spec/powerpc_unknown_netbsd.rs | 1 - .../spec/s390x_unknown_linux_gnu.rs | 1 - src/librustc_target/spec/solaris_base.rs | 1 - .../spec/sparc64_unknown_linux_gnu.rs | 1 - .../spec/sparc_unknown_linux_gnu.rs | 1 - .../spec/sparcv9_sun_solaris.rs | 1 - .../spec/x86_64_rumprun_netbsd.rs | 1 - src/libstd/Cargo.toml | 2 - src/rustc/Cargo.toml | 3 - src/tools/tidy/src/cargo.rs | 3 +- src/tools/tidy/src/lib.rs | 1 - src/tools/tidy/src/pal.rs | 2 - 53 files changed, 20 insertions(+), 244 deletions(-) diff --git a/COPYRIGHT b/COPYRIGHT index 9bc018d983d7d..cddee94afa090 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -229,35 +229,3 @@ their own copyright notices and license terms: NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -* jemalloc, under src/jemalloc: - - Copyright (C) 2002-2014 Jason Evans - . All rights reserved. - Copyright (C) 2007-2012 Mozilla Foundation. - All rights reserved. - Copyright (C) 2009-2014 Facebook, Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice(s), - this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice(s), - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - OF SUCH DAMAGE. diff --git a/config.toml.example b/config.toml.example index 0578f929224d9..180cbaa27edba 100644 --- a/config.toml.example +++ b/config.toml.example @@ -270,12 +270,6 @@ # Adding debuginfo makes them several times larger. #debuginfo-tools = false -# Whether or not jemalloc is built and enabled -#use-jemalloc = true - -# Whether or not jemalloc is built with its debug option set -#debug-jemalloc = false - # Whether or not `panic!`s generate backtraces (RUST_BACKTRACE) #backtrace = true @@ -391,10 +385,6 @@ # target. #llvm-config = "../path/to/llvm/root/bin/llvm-config" -# Path to the custom jemalloc static library to link into the standard library -# by default. This is only used if jemalloc is still enabled above -#jemalloc = "/path/to/jemalloc/libjemalloc_pic.a" - # If this target is for Android, this option will be required to specify where # the NDK for the target lives. This is used to find the C compiler to link and # build native code. diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index a94792a2f9f59..fae237ed42f14 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -696,11 +696,6 @@ def update_submodules(self): backends = self.get_toml('codegen-backends') if backends is None or not 'emscripten' in backends: continue - if module.endswith("jemalloc"): - if self.get_toml('use-jemalloc') == 'false': - continue - if self.get_toml('jemalloc'): - continue if module.endswith("lld"): config = self.get_toml('lld') if config is None or config == 'false': diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 642f22b11ade3..e7fc41a23e0dc 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -152,16 +152,7 @@ pub fn std_cargo(builder: &Builder, .arg("--manifest-path") .arg(builder.src.join("src/rustc/compiler_builtins_shim/Cargo.toml")); } else { - let mut features = builder.std_features(); - - // When doing a local rebuild we tell cargo that we're stage1 rather than - // stage0. This works fine if the local rust and being-built rust have the - // same view of what the default allocator is, but fails otherwise. Since - // we don't have a way to express an allocator preference yet, work - // around the issue in the case of a local rebuild with jemalloc disabled. - if compiler.stage == 0 && builder.local_rebuild && !builder.config.use_jemalloc { - features.push_str(" force_alloc_system"); - } + let features = builder.std_features(); if compiler.stage != 0 && builder.config.sanitizers { // This variable is used by the sanitizer runtime crates, e.g. @@ -182,11 +173,6 @@ pub fn std_cargo(builder: &Builder, .arg("--manifest-path") .arg(builder.src.join("src/libstd/Cargo.toml")); - if let Some(target) = builder.config.target_config.get(&target) { - if let Some(ref jemalloc) = target.jemalloc { - cargo.env("JEMALLOC_OVERRIDE", jemalloc); - } - } if target.contains("musl") { if let Some(p) = builder.musl_root(target) { cargo.env("MUSL_ROOT", p); diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index e4d467c927245..cb0d485f1d675 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -118,8 +118,6 @@ pub struct Config { pub dist_gpg_password_file: Option, // libstd features - pub debug_jemalloc: bool, - pub use_jemalloc: bool, pub backtrace: bool, // support for RUST_BACKTRACE pub wasm_syscall: bool, @@ -158,7 +156,6 @@ pub struct Config { pub struct Target { /// Some(path to llvm-config) if using an external LLVM. pub llvm_config: Option, - pub jemalloc: Option, pub cc: Option, pub cxx: Option, pub ar: Option, @@ -289,8 +286,6 @@ struct Rust { debuginfo_only_std: Option, debuginfo_tools: Option, experimental_parallel_queries: Option, - debug_jemalloc: Option, - use_jemalloc: Option, backtrace: Option, default_linker: Option, channel: Option, @@ -320,7 +315,6 @@ struct Rust { #[serde(deny_unknown_fields, rename_all = "kebab-case")] struct TomlTarget { llvm_config: Option, - jemalloc: Option, cc: Option, cxx: Option, ar: Option, @@ -345,7 +339,6 @@ impl Config { config.llvm_enabled = true; config.llvm_optimize = true; config.llvm_version_check = true; - config.use_jemalloc = true; config.backtrace = true; config.rust_optimize = true; config.rust_optimize_tests = true; @@ -481,7 +474,6 @@ impl Config { let mut debuginfo_only_std = None; let mut debuginfo_tools = None; let mut debug = None; - let mut debug_jemalloc = None; let mut debuginfo = None; let mut debug_assertions = None; let mut optimize = None; @@ -521,12 +513,10 @@ impl Config { debuginfo_tools = rust.debuginfo_tools; optimize = rust.optimize; ignore_git = rust.ignore_git; - debug_jemalloc = rust.debug_jemalloc; set(&mut config.rust_optimize_tests, rust.optimize_tests); set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests); set(&mut config.codegen_tests, rust.codegen_tests); set(&mut config.rust_rpath, rust.rpath); - set(&mut config.use_jemalloc, rust.use_jemalloc); set(&mut config.backtrace, rust.backtrace); set(&mut config.channel, rust.channel.clone()); set(&mut config.rust_dist_src, rust.dist_src); @@ -568,9 +558,6 @@ impl Config { if let Some(ref s) = cfg.llvm_config { target.llvm_config = Some(config.src.join(s)); } - if let Some(ref s) = cfg.jemalloc { - target.jemalloc = Some(config.src.join(s)); - } if let Some(ref s) = cfg.android_ndk { target.ndk = Some(config.src.join(s)); } @@ -611,7 +598,6 @@ impl Config { config.rust_debuginfo_tools = debuginfo_tools.unwrap_or(false); let default = debug == Some(true); - config.debug_jemalloc = debug_jemalloc.unwrap_or(default); config.rust_debuginfo = debuginfo.unwrap_or(default); config.rust_debug_assertions = debug_assertions.unwrap_or(default); config.rust_optimize = optimize.unwrap_or(!default); diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 80fa96509bd87..35e5cce746c37 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -80,7 +80,6 @@ def v(*args): o("debuginfo-lines", "rust.debuginfo-lines", "build with line number debugger metadata") o("debuginfo-only-std", "rust.debuginfo-only-std", "build only libstd with debugging information") o("debuginfo-tools", "rust.debuginfo-tools", "build extended tools with debugging information") -o("debug-jemalloc", "rust.debug-jemalloc", "build jemalloc with --enable-debug --enable-fill") v("save-toolstates", "rust.save-toolstates", "save build and test status of external tools into this file") v("prefix", "install.prefix", "set installation prefix") @@ -95,7 +94,6 @@ def v(*args): v("llvm-root", None, "set LLVM root") v("python", "build.python", "set path to python") -v("jemalloc-root", None, "set directory where libjemalloc_pic.a is located") v("android-cross-path", "target.arm-linux-androideabi.android-ndk", "Android NDK standalone path (deprecated)") v("i686-linux-android-ndk", "target.i686-linux-android.android-ndk", @@ -144,7 +142,6 @@ def v(*args): # Many of these are saved below during the "writing configuration" step # (others are conditionally saved). o("manage-submodules", "build.submodules", "let the build manage the git submodules") -o("jemalloc", "rust.use-jemalloc", "build liballoc with jemalloc") o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two") o("extended", "build.extended", "build an extended rust tool set") @@ -322,8 +319,6 @@ def set(key, value): set('build.cargo', value + '/bin/cargo') elif option.name == 'llvm-root': set('target.{}.llvm-config'.format(build()), value + '/bin/llvm-config') - elif option.name == 'jemalloc-root': - set('target.{}.jemalloc'.format(build()), value + '/libjemalloc_pic.a') elif option.name == 'tools': set('build.tools', value.split(',')) elif option.name == 'host': diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 19a2c94dca7a2..bab019ea97925 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -834,7 +834,6 @@ impl Step for Src { "src/build_helper", "src/dlmalloc", "src/liballoc", - "src/liballoc_jemalloc", "src/liballoc_system", "src/libbacktrace", "src/libcompiler_builtins", @@ -854,13 +853,11 @@ impl Step for Src { "src/rustc/dlmalloc_shim", "src/libtest", "src/libterm", - "src/jemalloc", "src/libprofiler_builtins", "src/stdsimd", ]; let std_src_dirs_exclude = [ "src/libcompiler_builtins/compiler-rt/test", - "src/jemalloc/test/unit", ]; copy_src_dirs(builder, &std_src_dirs[..], &std_src_dirs_exclude[..], &dst_src); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 414f17dfad400..abca595a2b167 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -498,12 +498,6 @@ impl Build { fn std_features(&self) -> String { let mut features = "panic-unwind".to_string(); - if self.config.debug_jemalloc { - features.push_str(" debug-jemalloc"); - } - if self.config.use_jemalloc { - features.push_str(" jemalloc"); - } if self.config.backtrace { features.push_str(" backtrace"); } @@ -518,11 +512,7 @@ impl Build { /// Get the space-separated set of activated features for the compiler. fn rustc_features(&self) -> String { - let mut features = String::new(); - if self.config.use_jemalloc { - features.push_str(" jemalloc"); - } - features + String::new() } /// Component directory that Cargo will produce output into (e.g. @@ -732,7 +722,7 @@ impl Build { // If we're compiling on macOS then we add a few unconditional flags // indicating that we want libc++ (more filled out than libstdc++) and // we want to compile for 10.7. This way we can ensure that - // LLVM/jemalloc/etc are all properly compiled. + // LLVM/etc are all properly compiled. if target.contains("apple-darwin") { base.push("-stdlib=libc++".into()); } diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs index c7f514da939a6..f4ea35844aa9c 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -152,12 +152,6 @@ pub fn check(build: &mut Build) { if !build.config.dry_run { cmd_finder.must_have(build.cxx(*host).unwrap()); } - - // The msvc hosts don't use jemalloc, turn it off globally to - // avoid packaging the dummy liballoc_jemalloc on that platform. - if host.contains("msvc") { - build.config.use_jemalloc = false; - } } // Externally configured LLVM requires FileCheck to exist diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 90688b1c0e181..80395f922cfd5 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1468,8 +1468,7 @@ impl Step for CrateNotDefault { type Output = (); fn should_run(run: ShouldRun) -> ShouldRun { - run.path("src/liballoc_jemalloc") - .path("src/librustc_asan") + run.path("src/librustc_asan") .path("src/librustc_lsan") .path("src/librustc_msan") .path("src/librustc_tsan") @@ -1486,7 +1485,6 @@ impl Step for CrateNotDefault { target: run.target, test_kind, krate: match run.path { - _ if run.path.ends_with("src/liballoc_jemalloc") => "alloc_jemalloc", _ if run.path.ends_with("src/librustc_asan") => "rustc_asan", _ if run.path.ends_with("src/librustc_lsan") => "rustc_lsan", _ if run.path.ends_with("src/librustc_msan") => "rustc_msan", @@ -1525,7 +1523,6 @@ impl Step for Crate { run = run.krate("test"); for krate in run.builder.in_tree_crates("std") { if krate.is_local(&run.builder) - && !krate.name.contains("jemalloc") && !(krate.name.starts_with("rustc_") && krate.name.ends_with("san")) && krate.name != "dlmalloc" { diff --git a/src/ci/docker/disabled/dist-x86_64-haiku/Dockerfile b/src/ci/docker/disabled/dist-x86_64-haiku/Dockerfile index 440afd7c97f5e..880b319afd890 100644 --- a/src/ci/docker/disabled/dist-x86_64-haiku/Dockerfile +++ b/src/ci/docker/disabled/dist-x86_64-haiku/Dockerfile @@ -42,7 +42,7 @@ RUN sh /scripts/sccache.sh ENV HOST=x86_64-unknown-haiku ENV TARGET=target.$HOST -ENV RUST_CONFIGURE_ARGS --disable-jemalloc \ +ENV RUST_CONFIGURE_ARGS \ --set=$TARGET.cc=x86_64-unknown-haiku-gcc \ --set=$TARGET.cxx=x86_64-unknown-haiku-g++ \ --set=$TARGET.llvm-config=/bin/llvm-config-haiku diff --git a/src/liballoc/tests/heap.rs b/src/liballoc/tests/heap.rs index 6fa88ce969a0e..5611149d2b0f6 100644 --- a/src/liballoc/tests/heap.rs +++ b/src/liballoc/tests/heap.rs @@ -14,7 +14,7 @@ use std::alloc::{Global, Alloc, Layout}; /// https://github.com/rust-lang/rust/issues/45955 /// /// Note that `#[global_allocator]` is not used, -/// so `liballoc_jemalloc` is linked (on some platforms). +/// so `System` and `Global` might be backed by different allocators. #[test] fn alloc_system_overaligned_request() { check_overalign_requests(System) diff --git a/src/librustc/middle/allocator.rs b/src/librustc/middle/allocator.rs index 79a9ef0e8b577..cdd73ca0ff800 100644 --- a/src/librustc/middle/allocator.rs +++ b/src/librustc/middle/allocator.rs @@ -11,16 +11,14 @@ #[derive(Clone, Copy)] pub enum AllocatorKind { Global, - DefaultLib, - DefaultExe, + Default, } impl AllocatorKind { pub fn fn_name(&self, base: &str) -> String { match *self { AllocatorKind::Global => format!("__rg_{}", base), - AllocatorKind::DefaultLib => format!("__rdl_{}", base), - AllocatorKind::DefaultExe => format!("__rde_{}", base), + AllocatorKind::Default => format!("__rdl_{}", base), } } } diff --git a/src/librustc/middle/dependency_format.rs b/src/librustc/middle/dependency_format.rs index 4c99b46ddff6e..78cab4dc1898e 100644 --- a/src/librustc/middle/dependency_format.rs +++ b/src/librustc/middle/dependency_format.rs @@ -63,7 +63,6 @@ use hir::def_id::CrateNum; -use session; use session::config; use ty::TyCtxt; use middle::cstore::{self, DepKind}; @@ -225,7 +224,6 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // quite yet, so do so here. activate_injected_dep(*sess.injected_panic_runtime.get(), &mut ret, &|cnum| tcx.is_panic_runtime(cnum)); - activate_injected_allocator(sess, &mut ret); // When dylib B links to dylib A, then when using B we must also link to A. // It could be the case, however, that the rlib for A is present (hence we @@ -304,7 +302,6 @@ fn attempt_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option, } } -fn activate_injected_allocator(sess: &session::Session, - list: &mut DependencyList) { - let cnum = match sess.injected_allocator.get() { - Some(cnum) => cnum, - None => return, - }; - let idx = cnum.as_usize() - 1; - if list[idx] == Linkage::NotLinked { - list[idx] = Linkage::Static; - } -} - // After the linkage for a crate has been determined we need to verify that // there's only going to be one allocator in the output. fn verify_ok<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, list: &[Linkage]) { diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 076d56fb80842..22d7cd02a85a5 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -116,7 +116,6 @@ pub struct Session { /// The metadata::creader module may inject an allocator/panic_runtime /// dependency if it didn't already find one, and this tracks what was /// injected. - pub injected_allocator: Once>, pub allocator_kind: Once>, pub injected_panic_runtime: Once>, @@ -1117,7 +1116,6 @@ pub fn build_session_( type_length_limit: Once::new(), const_eval_stack_frame_limit: 100, next_node_id: OneThread::new(Cell::new(NodeId::new(1))), - injected_allocator: Once::new(), allocator_kind: Once::new(), injected_panic_runtime: Once::new(), imported_macro_spans: OneThread::new(RefCell::new(HashMap::new())), diff --git a/src/librustc_codegen_llvm/Cargo.toml b/src/librustc_codegen_llvm/Cargo.toml index 6ddae57e336ed..0a7a9d6313c3d 100644 --- a/src/librustc_codegen_llvm/Cargo.toml +++ b/src/librustc_codegen_llvm/Cargo.toml @@ -39,10 +39,6 @@ tempfile = "3.0" env_logger = { version = "0.5", default-features = false } [features] -# Used to communicate the feature to `rustc_target` in the same manner that the -# `rustc` driver script communicate this. -jemalloc = ["rustc_target/jemalloc"] - # This is used to convince Cargo to separately cache builds of `rustc_codegen_llvm` # when this option is enabled or not. That way we can build two, cache two # artifacts, and have nice speedy rebuilds. diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index cdeee92cb073f..82ff3ab4627e8 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -841,7 +841,6 @@ impl<'a> CrateLoader<'a> { needs_allocator = needs_allocator || data.root.needs_allocator; }); if !needs_allocator { - self.sess.injected_allocator.set(None); self.sess.allocator_kind.set(None); return } @@ -849,20 +848,18 @@ impl<'a> CrateLoader<'a> { // At this point we've determined that we need an allocator. Let's see // if our compilation session actually needs an allocator based on what // we're emitting. - let mut need_lib_alloc = false; - let mut need_exe_alloc = false; + let mut need_alloc = false; for ct in self.sess.crate_types.borrow().iter() { match *ct { - config::CrateTypeExecutable => need_exe_alloc = true, + config::CrateTypeExecutable | config::CrateTypeDylib | config::CrateTypeProcMacro | config::CrateTypeCdylib | - config::CrateTypeStaticlib => need_lib_alloc = true, + config::CrateTypeStaticlib => need_alloc = true, config::CrateTypeRlib => {} } } - if !need_lib_alloc && !need_exe_alloc { - self.sess.injected_allocator.set(None); + if !need_alloc { self.sess.allocator_kind.set(None); return } @@ -901,57 +898,13 @@ impl<'a> CrateLoader<'a> { }); if global_allocator.is_some() { self.sess.allocator_kind.set(Some(AllocatorKind::Global)); - self.sess.injected_allocator.set(None); return } - // Ok we haven't found a global allocator but we still need an - // allocator. At this point we'll either fall back to the "library - // allocator" or the "exe allocator" depending on a few variables. Let's - // figure out which one. - // - // Note that here we favor linking to the "library allocator" as much as - // possible. If we're not creating rustc's version of libstd - // (need_lib_alloc and prefer_dynamic) then we select `None`, and if the - // exe allocation crate doesn't exist for this target then we also - // select `None`. - let exe_allocation_crate_data = - if need_lib_alloc && !self.sess.opts.cg.prefer_dynamic { - None - } else { - self.sess - .target - .target - .options - .exe_allocation_crate - .as_ref() - .map(|name| { - // We've determined that we're injecting an "exe allocator" which means - // that we're going to load up a whole new crate. An example of this is - // that we're producing a normal binary on Linux which means we need to - // load the `alloc_jemalloc` crate to link as an allocator. - let name = Symbol::intern(name); - let (cnum, data) = self.resolve_crate(&None, - name, - name, - None, - None, - DUMMY_SP, - PathKind::Crate, - DepKind::Implicit); - self.sess.injected_allocator.set(Some(cnum)); - data - }) - }; - - let allocation_crate_data = exe_allocation_crate_data.or_else(|| { - // No allocator was injected - self.sess.injected_allocator.set(None); - - if attr::contains_name(&krate.attrs, "default_lib_allocator") { - // Prefer self as the allocator if there's a collision - return None; - } + let allocation_crate_data = if attr::contains_name(&krate.attrs, "default_lib_allocator") { + // Prefer self as the allocator if there's a collision + None + } else { // We're not actually going to inject an allocator, we're going to // require that something in our crate graph is the default lib // allocator. This is typically libstd, so this'll rarely be an @@ -963,7 +916,7 @@ impl<'a> CrateLoader<'a> { } }); allocator - }); + }; match allocation_crate_data { Some(data) => { @@ -977,8 +930,7 @@ impl<'a> CrateLoader<'a> { .map(|s| s as &str); let alloc_kind = match kind_str { None | - Some("lib") => AllocatorKind::DefaultLib, - Some("exe") => AllocatorKind::DefaultExe, + Some("lib") => AllocatorKind::Default, Some(other) => { self.sess.err(&format!("Allocator kind {} not known", other)); return; @@ -994,7 +946,7 @@ impl<'a> CrateLoader<'a> { that implements the GlobalAlloc trait."); return; } - self.sess.allocator_kind.set(Some(AllocatorKind::DefaultLib)); + self.sess.allocator_kind.set(Some(AllocatorKind::Default)); } } diff --git a/src/librustc_target/Cargo.toml b/src/librustc_target/Cargo.toml index bb686e914a048..684ea4c78978c 100644 --- a/src/librustc_target/Cargo.toml +++ b/src/librustc_target/Cargo.toml @@ -13,6 +13,3 @@ bitflags = "1.0" log = "0.4" rustc_cratesio_shim = { path = "../librustc_cratesio_shim" } serialize = { path = "../libserialize" } - -[features] -jemalloc = [] diff --git a/src/librustc_target/spec/aarch64_unknown_freebsd.rs b/src/librustc_target/spec/aarch64_unknown_freebsd.rs index 48177b8c79aed..9767f56c4dba6 100644 --- a/src/librustc_target/spec/aarch64_unknown_freebsd.rs +++ b/src/librustc_target/spec/aarch64_unknown_freebsd.rs @@ -15,7 +15,6 @@ pub fn target() -> TargetResult { base.max_atomic_width = Some(128); // see #36994 - base.exe_allocation_crate = None; Ok(Target { llvm_target: "aarch64-unknown-freebsd".to_string(), diff --git a/src/librustc_target/spec/aarch64_unknown_linux_gnu.rs b/src/librustc_target/spec/aarch64_unknown_linux_gnu.rs index 2351d01469215..f6c637672213f 100644 --- a/src/librustc_target/spec/aarch64_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/aarch64_unknown_linux_gnu.rs @@ -15,7 +15,6 @@ pub fn target() -> TargetResult { base.max_atomic_width = Some(128); // see #36994 - base.exe_allocation_crate = None; Ok(Target { llvm_target: "aarch64-unknown-linux-gnu".to_string(), diff --git a/src/librustc_target/spec/aarch64_unknown_linux_musl.rs b/src/librustc_target/spec/aarch64_unknown_linux_musl.rs index 5ab55a076f45b..e8e7a89e574b7 100644 --- a/src/librustc_target/spec/aarch64_unknown_linux_musl.rs +++ b/src/librustc_target/spec/aarch64_unknown_linux_musl.rs @@ -15,7 +15,6 @@ pub fn target() -> TargetResult { base.max_atomic_width = Some(128); // see #36994 - base.exe_allocation_crate = None; Ok(Target { llvm_target: "aarch64-unknown-linux-musl".to_string(), diff --git a/src/librustc_target/spec/apple_base.rs b/src/librustc_target/spec/apple_base.rs index 4b66891e36f8c..279d7ea770456 100644 --- a/src/librustc_target/spec/apple_base.rs +++ b/src/librustc_target/spec/apple_base.rs @@ -44,7 +44,6 @@ pub fn opts() -> TargetOptions { dll_suffix: ".dylib".to_string(), archive_format: "bsd".to_string(), pre_link_args: LinkArgs::new(), - exe_allocation_crate: super::maybe_jemalloc(), has_elf_tls: version >= (10, 7), abi_return_struct_as_int: true, emit_debug_gdb_scripts: false, diff --git a/src/librustc_target/spec/apple_ios_base.rs b/src/librustc_target/spec/apple_ios_base.rs index 46bb01e7c420d..a47ed24d83157 100644 --- a/src/librustc_target/spec/apple_ios_base.rs +++ b/src/librustc_target/spec/apple_ios_base.rs @@ -102,7 +102,6 @@ pub fn opts(arch: Arch) -> Result { // The following line is a workaround for jemalloc 4.5 being broken on // ios. jemalloc 5.0 is supposed to fix this. // see https://github.com/rust-lang/rust/issues/45262 - exe_allocation_crate: None, .. super::apple_base::opts() }) } diff --git a/src/librustc_target/spec/cloudabi_base.rs b/src/librustc_target/spec/cloudabi_base.rs index 2ffa74e737fd5..fb78cf495e22a 100644 --- a/src/librustc_target/spec/cloudabi_base.rs +++ b/src/librustc_target/spec/cloudabi_base.rs @@ -38,7 +38,6 @@ pub fn opts() -> TargetOptions { // dynamic linking. tls_model: "local-exec".to_string(), relro_level: RelroLevel::Full, - exe_allocation_crate: super::maybe_jemalloc(), .. Default::default() } } diff --git a/src/librustc_target/spec/dragonfly_base.rs b/src/librustc_target/spec/dragonfly_base.rs index 32eac8663afac..a9e317b7cb8a7 100644 --- a/src/librustc_target/spec/dragonfly_base.rs +++ b/src/librustc_target/spec/dragonfly_base.rs @@ -33,7 +33,6 @@ pub fn opts() -> TargetOptions { pre_link_args: args, position_independent_executables: true, relro_level: RelroLevel::Full, - exe_allocation_crate: super::maybe_jemalloc(), .. Default::default() } } diff --git a/src/librustc_target/spec/freebsd_base.rs b/src/librustc_target/spec/freebsd_base.rs index 04b8a6e706064..c8a2946da50a5 100644 --- a/src/librustc_target/spec/freebsd_base.rs +++ b/src/librustc_target/spec/freebsd_base.rs @@ -34,7 +34,6 @@ pub fn opts() -> TargetOptions { position_independent_executables: true, eliminate_frame_pointer: false, // FIXME 43575 relro_level: RelroLevel::Full, - exe_allocation_crate: super::maybe_jemalloc(), abi_return_struct_as_int: true, .. Default::default() } diff --git a/src/librustc_target/spec/l4re_base.rs b/src/librustc_target/spec/l4re_base.rs index 4ebc930d48b6f..7932adf3b1054 100644 --- a/src/librustc_target/spec/l4re_base.rs +++ b/src/librustc_target/spec/l4re_base.rs @@ -30,7 +30,6 @@ pub fn opts() -> TargetOptions { TargetOptions { executables: true, has_elf_tls: false, - exe_allocation_crate: None, panic_strategy: PanicStrategy::Abort, linker: Some("ld".to_string()), pre_link_args: args, diff --git a/src/librustc_target/spec/linux_base.rs b/src/librustc_target/spec/linux_base.rs index 4a9cd9e2f3233..01f65d5736322 100644 --- a/src/librustc_target/spec/linux_base.rs +++ b/src/librustc_target/spec/linux_base.rs @@ -36,7 +36,6 @@ pub fn opts() -> TargetOptions { pre_link_args: args, position_independent_executables: true, relro_level: RelroLevel::Full, - exe_allocation_crate: super::maybe_jemalloc(), has_elf_tls: true, .. Default::default() } diff --git a/src/librustc_target/spec/mips64_unknown_linux_gnuabi64.rs b/src/librustc_target/spec/mips64_unknown_linux_gnuabi64.rs index 1f60d918908d0..ccbea15d74510 100644 --- a/src/librustc_target/spec/mips64_unknown_linux_gnuabi64.rs +++ b/src/librustc_target/spec/mips64_unknown_linux_gnuabi64.rs @@ -29,7 +29,6 @@ pub fn target() -> TargetResult { max_atomic_width: Some(64), // see #36994 - exe_allocation_crate: None, ..super::linux_base::opts() }, diff --git a/src/librustc_target/spec/mips64el_unknown_linux_gnuabi64.rs b/src/librustc_target/spec/mips64el_unknown_linux_gnuabi64.rs index e42fde8d403fb..d8e0d5ab23858 100644 --- a/src/librustc_target/spec/mips64el_unknown_linux_gnuabi64.rs +++ b/src/librustc_target/spec/mips64el_unknown_linux_gnuabi64.rs @@ -29,7 +29,6 @@ pub fn target() -> TargetResult { max_atomic_width: Some(64), // see #36994 - exe_allocation_crate: None, ..super::linux_base::opts() }, diff --git a/src/librustc_target/spec/mips_unknown_linux_gnu.rs b/src/librustc_target/spec/mips_unknown_linux_gnu.rs index 59e15137cf40d..01714c3f704f4 100644 --- a/src/librustc_target/spec/mips_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/mips_unknown_linux_gnu.rs @@ -28,7 +28,6 @@ pub fn target() -> TargetResult { max_atomic_width: Some(32), // see #36994 - exe_allocation_crate: None, ..super::linux_base::opts() }, diff --git a/src/librustc_target/spec/mips_unknown_linux_musl.rs b/src/librustc_target/spec/mips_unknown_linux_musl.rs index 8ee399ba56c32..125025f5f4300 100644 --- a/src/librustc_target/spec/mips_unknown_linux_musl.rs +++ b/src/librustc_target/spec/mips_unknown_linux_musl.rs @@ -16,7 +16,6 @@ pub fn target() -> TargetResult { base.features = "+mips32r2,+soft-float".to_string(); base.max_atomic_width = Some(32); // see #36994 - base.exe_allocation_crate = None; base.crt_static_default = false; Ok(Target { llvm_target: "mips-unknown-linux-musl".to_string(), diff --git a/src/librustc_target/spec/mips_unknown_linux_uclibc.rs b/src/librustc_target/spec/mips_unknown_linux_uclibc.rs index 384ab1e413123..72c1ee6921502 100644 --- a/src/librustc_target/spec/mips_unknown_linux_uclibc.rs +++ b/src/librustc_target/spec/mips_unknown_linux_uclibc.rs @@ -28,7 +28,6 @@ pub fn target() -> TargetResult { max_atomic_width: Some(32), // see #36994 - exe_allocation_crate: None, ..super::linux_base::opts() }, diff --git a/src/librustc_target/spec/mipsel_unknown_linux_gnu.rs b/src/librustc_target/spec/mipsel_unknown_linux_gnu.rs index edd29164caca8..029c1e76f122e 100644 --- a/src/librustc_target/spec/mipsel_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/mipsel_unknown_linux_gnu.rs @@ -29,7 +29,6 @@ pub fn target() -> TargetResult { max_atomic_width: Some(32), // see #36994 - exe_allocation_crate: None, ..super::linux_base::opts() }, diff --git a/src/librustc_target/spec/mipsel_unknown_linux_musl.rs b/src/librustc_target/spec/mipsel_unknown_linux_musl.rs index 1d9378ca1b814..3b520cf8a70a7 100644 --- a/src/librustc_target/spec/mipsel_unknown_linux_musl.rs +++ b/src/librustc_target/spec/mipsel_unknown_linux_musl.rs @@ -16,7 +16,6 @@ pub fn target() -> TargetResult { base.features = "+mips32r2,+soft-float".to_string(); base.max_atomic_width = Some(32); // see #36994 - base.exe_allocation_crate = None; base.crt_static_default = false; Ok(Target { llvm_target: "mipsel-unknown-linux-musl".to_string(), diff --git a/src/librustc_target/spec/mipsel_unknown_linux_uclibc.rs b/src/librustc_target/spec/mipsel_unknown_linux_uclibc.rs index a1db1791bb7ce..e36b774bd78b1 100644 --- a/src/librustc_target/spec/mipsel_unknown_linux_uclibc.rs +++ b/src/librustc_target/spec/mipsel_unknown_linux_uclibc.rs @@ -29,7 +29,6 @@ pub fn target() -> TargetResult { max_atomic_width: Some(32), // see #36994 - exe_allocation_crate: None, ..super::linux_base::opts() }, diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index e6cf1bfc8ec54..7be9f4f6a73e7 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -550,9 +550,6 @@ pub struct TargetOptions { /// `eh_unwind_resume` lang item. pub custom_unwind_resume: bool, - /// If necessary, a different crate to link exe allocators by default - pub exe_allocation_crate: Option, - /// Flag indicating whether ELF TLS (e.g. #[thread_local]) is available for /// this target. pub has_elf_tls: bool, @@ -683,7 +680,6 @@ impl Default for TargetOptions { link_env: Vec::new(), archive_format: "gnu".to_string(), custom_unwind_resume: false, - exe_allocation_crate: None, allow_asm: true, has_elf_tls: false, obj_is_bitcode: false, @@ -940,7 +936,6 @@ impl Target { key!(archive_format); key!(allow_asm, bool); key!(custom_unwind_resume, bool); - key!(exe_allocation_crate, optional); key!(has_elf_tls, bool); key!(obj_is_bitcode, bool); key!(no_integrated_as, bool); @@ -1148,7 +1143,6 @@ impl ToJson for Target { target_option_val!(archive_format); target_option_val!(allow_asm); target_option_val!(custom_unwind_resume); - target_option_val!(exe_allocation_crate); target_option_val!(has_elf_tls); target_option_val!(obj_is_bitcode); target_option_val!(no_integrated_as); @@ -1181,10 +1175,6 @@ impl ToJson for Target { } } -fn maybe_jemalloc() -> Option { - None -} - /// Either a target triple string or a path to a JSON file. #[derive(PartialEq, Clone, Debug, Hash, RustcEncodable, RustcDecodable)] pub enum TargetTriple { diff --git a/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs b/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs index 1959871161343..acaa4676f8b58 100644 --- a/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs @@ -21,7 +21,6 @@ pub fn target() -> TargetResult { base.relro_level = RelroLevel::Partial; // see #36994 - base.exe_allocation_crate = None; Ok(Target { llvm_target: "powerpc64-unknown-linux-gnu".to_string(), diff --git a/src/librustc_target/spec/powerpc64le_unknown_linux_gnu.rs b/src/librustc_target/spec/powerpc64le_unknown_linux_gnu.rs index 39840692dff18..28ec45a5b4df5 100644 --- a/src/librustc_target/spec/powerpc64le_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/powerpc64le_unknown_linux_gnu.rs @@ -17,7 +17,6 @@ pub fn target() -> TargetResult { base.max_atomic_width = Some(64); // see #36994 - base.exe_allocation_crate = None; Ok(Target { llvm_target: "powerpc64le-unknown-linux-gnu".to_string(), diff --git a/src/librustc_target/spec/powerpc_unknown_linux_gnu.rs b/src/librustc_target/spec/powerpc_unknown_linux_gnu.rs index c05b110a75d39..e38164ba32bfb 100644 --- a/src/librustc_target/spec/powerpc_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/powerpc_unknown_linux_gnu.rs @@ -16,7 +16,6 @@ pub fn target() -> TargetResult { base.max_atomic_width = Some(32); // see #36994 - base.exe_allocation_crate = None; Ok(Target { llvm_target: "powerpc-unknown-linux-gnu".to_string(), diff --git a/src/librustc_target/spec/powerpc_unknown_linux_gnuspe.rs b/src/librustc_target/spec/powerpc_unknown_linux_gnuspe.rs index c76c3119c87c5..a60972511e758 100644 --- a/src/librustc_target/spec/powerpc_unknown_linux_gnuspe.rs +++ b/src/librustc_target/spec/powerpc_unknown_linux_gnuspe.rs @@ -16,7 +16,6 @@ pub fn target() -> TargetResult { base.max_atomic_width = Some(32); // see #36994 - base.exe_allocation_crate = None; Ok(Target { llvm_target: "powerpc-unknown-linux-gnuspe".to_string(), diff --git a/src/librustc_target/spec/powerpc_unknown_netbsd.rs b/src/librustc_target/spec/powerpc_unknown_netbsd.rs index c05e40b9c25d7..864e09869fc5a 100644 --- a/src/librustc_target/spec/powerpc_unknown_netbsd.rs +++ b/src/librustc_target/spec/powerpc_unknown_netbsd.rs @@ -16,7 +16,6 @@ pub fn target() -> TargetResult { base.max_atomic_width = Some(32); // see #36994 - base.exe_allocation_crate = None; Ok(Target { llvm_target: "powerpc-unknown-netbsd".to_string(), diff --git a/src/librustc_target/spec/s390x_unknown_linux_gnu.rs b/src/librustc_target/spec/s390x_unknown_linux_gnu.rs index c9a9625ebab95..906b23619c717 100644 --- a/src/librustc_target/spec/s390x_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/s390x_unknown_linux_gnu.rs @@ -20,7 +20,6 @@ pub fn target() -> TargetResult { base.features = "-vector".to_string(); base.max_atomic_width = Some(64); // see #36994 - base.exe_allocation_crate = None; base.min_global_align = Some(16); Ok(Target { diff --git a/src/librustc_target/spec/solaris_base.rs b/src/librustc_target/spec/solaris_base.rs index c14cc3f5bc3be..93b889d5d399e 100644 --- a/src/librustc_target/spec/solaris_base.rs +++ b/src/librustc_target/spec/solaris_base.rs @@ -18,7 +18,6 @@ pub fn opts() -> TargetOptions { has_rpath: true, target_family: Some("unix".to_string()), is_like_solaris: true, - exe_allocation_crate: super::maybe_jemalloc(), .. Default::default() } diff --git a/src/librustc_target/spec/sparc64_unknown_linux_gnu.rs b/src/librustc_target/spec/sparc64_unknown_linux_gnu.rs index f68b5fd24bf75..f2b99aa46d2d0 100644 --- a/src/librustc_target/spec/sparc64_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/sparc64_unknown_linux_gnu.rs @@ -14,7 +14,6 @@ pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); base.cpu = "v9".to_string(); base.max_atomic_width = Some(64); - base.exe_allocation_crate = None; Ok(Target { llvm_target: "sparc64-unknown-linux-gnu".to_string(), diff --git a/src/librustc_target/spec/sparc_unknown_linux_gnu.rs b/src/librustc_target/spec/sparc_unknown_linux_gnu.rs index 4e352374f90b0..81db39cd23f87 100644 --- a/src/librustc_target/spec/sparc_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/sparc_unknown_linux_gnu.rs @@ -15,7 +15,6 @@ pub fn target() -> TargetResult { base.cpu = "v9".to_string(); base.max_atomic_width = Some(64); base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-mv8plus".to_string()); - base.exe_allocation_crate = None; Ok(Target { llvm_target: "sparc-unknown-linux-gnu".to_string(), diff --git a/src/librustc_target/spec/sparcv9_sun_solaris.rs b/src/librustc_target/spec/sparcv9_sun_solaris.rs index 7dea1b75a3c58..dd829a8990fb7 100644 --- a/src/librustc_target/spec/sparcv9_sun_solaris.rs +++ b/src/librustc_target/spec/sparcv9_sun_solaris.rs @@ -16,7 +16,6 @@ pub fn target() -> TargetResult { // llvm calls this "v9" base.cpu = "v9".to_string(); base.max_atomic_width = Some(64); - base.exe_allocation_crate = None; Ok(Target { llvm_target: "sparcv9-sun-solaris".to_string(), diff --git a/src/librustc_target/spec/x86_64_rumprun_netbsd.rs b/src/librustc_target/spec/x86_64_rumprun_netbsd.rs index ed15cfd9036f5..c503bf71664f6 100644 --- a/src/librustc_target/spec/x86_64_rumprun_netbsd.rs +++ b/src/librustc_target/spec/x86_64_rumprun_netbsd.rs @@ -22,7 +22,6 @@ pub fn target() -> TargetResult { base.position_independent_executables = false; base.disable_redzone = true; base.no_default_libraries = false; - base.exe_allocation_crate = None; base.stack_probes = true; Ok(Target { diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 09a4f655e0406..9c4fc73e5c33e 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -43,8 +43,6 @@ build_helper = { path = "../build_helper" } [features] backtrace = [] -debug-jemalloc = [] -jemalloc = [] force_alloc_system = [] panic-unwind = ["panic_unwind"] profiler = ["profiler_builtins"] diff --git a/src/rustc/Cargo.toml b/src/rustc/Cargo.toml index 9ccd37a6a4592..7a31afed8c322 100644 --- a/src/rustc/Cargo.toml +++ b/src/rustc/Cargo.toml @@ -10,6 +10,3 @@ path = "rustc.rs" [dependencies] rustc_target = { path = "../librustc_target" } rustc_driver = { path = "../librustc_driver" } - -[features] -jemalloc = ["rustc_target/jemalloc"] diff --git a/src/tools/tidy/src/cargo.rs b/src/tools/tidy/src/cargo.rs index f40fea60f40a8..13ac58fc6f07d 100644 --- a/src/tools/tidy/src/cargo.rs +++ b/src/tools/tidy/src/cargo.rs @@ -85,8 +85,7 @@ fn verify(tomlfile: &Path, libfile: &Path, bad: &mut bool) { // This is intentional, this dependency just makes the crate available // for others later on. Cover cases - let whitelisted = krate == "alloc_jemalloc"; - let whitelisted = whitelisted || krate.starts_with("panic"); + let whitelisted = krate.starts_with("panic"); if toml.contains("name = \"std\"") && whitelisted { continue } diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 022ef57503aaa..9f36133b38103 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -56,7 +56,6 @@ pub mod libcoretest; fn filter_dirs(path: &Path) -> bool { let skip = [ "src/dlmalloc", - "src/jemalloc", "src/llvm", "src/llvm-emscripten", "src/libbacktrace", diff --git a/src/tools/tidy/src/pal.rs b/src/tools/tidy/src/pal.rs index 8071f07d81195..708510663921a 100644 --- a/src/tools/tidy/src/pal.rs +++ b/src/tools/tidy/src/pal.rs @@ -28,7 +28,6 @@ //! - core may not have platform-specific code //! - libcompiler_builtins may have platform-specific code //! - liballoc_system may have platform-specific code -//! - liballoc_jemalloc may have platform-specific code //! - libpanic_abort may have platform-specific code //! - libpanic_unwind may have platform-specific code //! - libunwind may have platform-specific code @@ -52,7 +51,6 @@ use std::iter::Iterator; // Paths that may contain platform-specific code const EXCEPTION_PATHS: &'static [&'static str] = &[ // std crates - "src/liballoc_jemalloc", "src/liballoc_system", "src/libcompiler_builtins", "src/liblibc", From 54fa990fc942c281f263a2c9a8165c97013614a9 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 3 Jul 2018 16:39:53 +0200 Subject: [PATCH 5/5] Update docs regarding the default global allocator --- src/liballoc_system/lib.rs | 22 +++------------------- src/libstd/alloc.rs | 8 +------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index 64348e05de7db..9d5321990be77 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -48,25 +48,9 @@ use core::ptr::NonNull; /// This is based on `malloc` on Unix platforms and `HeapAlloc` on Windows, /// plus related functions. /// -/// This type can be used in a `static` item -/// with the `#[global_allocator]` attribute -/// to force the global allocator to be the system’s one. -/// (The default is jemalloc for executables, on some platforms.) -/// -/// ```rust -/// use std::alloc::System; -/// -/// #[global_allocator] -/// static A: System = System; -/// -/// fn main() { -/// let a = Box::new(4); // Allocates from the system allocator. -/// println!("{}", a); -/// } -/// ``` -/// -/// It can also be used directly to allocate memory -/// independently of the standard library’s global allocator. +/// This type can be used directly to allocate memory +/// independently of the standard library’s global allocator, +/// which may have been changed with the `#[global_allocator]` attribute. #[stable(feature = "alloc_system_type", since = "1.28.0")] pub struct System; diff --git a/src/libstd/alloc.rs b/src/libstd/alloc.rs index f6cecbea11f8d..5fc2aca9aa30c 100644 --- a/src/libstd/alloc.rs +++ b/src/libstd/alloc.rs @@ -12,14 +12,8 @@ //! //! In a given program, the standard library has one “global” memory allocator //! that is used for example by `Box` and `Vec`. +//! The default global allocator is [`System`]. //! -//! Currently the default global allocator is unspecified. -//! The compiler may link to a version of [jemalloc] on some platforms, -//! but this is not guaranteed. -//! Libraries, however, like `cdylib`s and `staticlib`s are guaranteed -//! to use the [`System`] by default. -//! -//! [jemalloc]: https://github.com/jemalloc/jemalloc //! [`System`]: struct.System.html //! //! # The `#[global_allocator]` attribute