Skip to content

Commit 8b811b9

Browse files
committed
Use global Rust jemalloc
1 parent 913e4be commit 8b811b9

5 files changed

Lines changed: 24 additions & 2 deletions

File tree

‎Cargo.lock‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681"
756756
dependencies = [
757757
"serde",
758758
"termcolor",
759-
"unicode-width 0.1.14",
759+
"unicode-width 0.2.2",
760760
]
761761

762762
[[package]]
@@ -3837,6 +3837,7 @@ dependencies = [
38373837
"rustc_target",
38383838
"serde_json",
38393839
"shlex",
3840+
"tikv-jemallocator",
38403841
"tracing",
38413842
"windows 0.61.3",
38423843
]
@@ -5551,6 +5552,16 @@ dependencies = [
55515552
"libc",
55525553
]
55535554

5555+
[[package]]
5556+
name = "tikv-jemallocator"
5557+
version = "0.6.1"
5558+
source = "registry+https://github.com/rust-lang/crates.io-index"
5559+
checksum = "0359b4327f954e0567e69fb191cf1436617748813819c94b8cd4a431422d053a"
5560+
dependencies = [
5561+
"libc",
5562+
"tikv-jemalloc-sys",
5563+
]
5564+
55545565
[[package]]
55555566
name = "tinystr"
55565567
version = "0.8.2"

‎compiler/rustc/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ features = ['override_allocator_on_supported_platforms']
3535
[features]
3636
# tidy-alphabetical-start
3737
check_only = ['rustc_driver_impl/check_only']
38-
jemalloc = ['dep:tikv-jemalloc-sys']
38+
jemalloc = ['dep:tikv-jemalloc-sys', 'rustc_driver_impl/jemalloc']
3939
llvm = ['rustc_driver_impl/llvm']
4040
llvm_enzyme = ['rustc_driver_impl/llvm_enzyme']
4141
llvm_offload = ['rustc_driver_impl/llvm_offload']

‎compiler/rustc_driver_impl/Cargo.toml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ features = [
5555
ctrlc = "3.4.4"
5656
# tidy-alphabetical-end
5757

58+
[dependencies.tikv-jemallocator]
59+
version = "0.6.1"
60+
optional = true
61+
features = ['override_allocator_on_supported_platforms']
62+
5863
[features]
5964
# tidy-alphabetical-start
6065
check_only = ['rustc_interface/check_only']
66+
jemalloc = ['dep:tikv-jemallocator']
6167
llvm = ['rustc_interface/llvm']
6268
llvm_enzyme = ['rustc_interface/llvm_enzyme']
6369
llvm_offload = ['rustc_interface/llvm_offload']

‎compiler/rustc_driver_impl/src/lib.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ use rustc_target::json::ToJson;
6363
use rustc_target::spec::{Target, TargetTuple};
6464
use tracing::trace;
6565

66+
#[cfg(feature = "jemalloc")]
67+
#[global_allocator]
68+
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
69+
6670
#[allow(unused_macros)]
6771
macro do_not_use_print($($t:tt)*) {
6872
std::compile_error!(

‎src/tools/tidy/src/deps.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
442442
"thorin-dwp",
443443
"thread_local",
444444
"tikv-jemalloc-sys",
445+
"tikv-jemallocator",
445446
"tinystr",
446447
"tinyvec",
447448
"tinyvec_macros",

0 commit comments

Comments
 (0)