Skip to content

Commit 8221642

Browse files
committed
Auto merge of #155526 - Zoxc:fjall-global, r=<try>
[TEST] Test out Fjall memory allocator
2 parents e22c616 + 331b1ee commit 8221642

10 files changed

Lines changed: 90 additions & 59 deletions

File tree

Cargo.lock

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ dependencies = [
286286

287287
[[package]]
288288
name = "bitflags"
289-
version = "2.10.0"
289+
version = "2.11.1"
290290
source = "registry+https://github.com/rust-lang/crates.io-index"
291-
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
291+
checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3"
292292

293293
[[package]]
294294
name = "blake3"
@@ -1395,6 +1395,16 @@ version = "0.1.5"
13951395
source = "registry+https://github.com/rust-lang/crates.io-index"
13961396
checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844"
13971397

1398+
[[package]]
1399+
name = "fjall"
1400+
version = "0.1.0"
1401+
source = "git+https://github.com/Zoxc/fjall.git#955dd1c4bc0a8139ab55ce5a070d1fc2a43a6f19"
1402+
dependencies = [
1403+
"bitflags",
1404+
"libc",
1405+
"windows-sys 0.52.0",
1406+
]
1407+
13981408
[[package]]
13991409
name = "flate2"
14001410
version = "1.1.9"
@@ -3422,14 +3432,14 @@ checksum = "8be87abb9e40db7466e0681dc8ecd9dcfd40360cb10b4c8fe24a7c4c3669b198"
34223432
name = "rustc-main"
34233433
version = "0.0.0"
34243434
dependencies = [
3435+
"fjall",
34253436
"getrandom 0.3.3",
34263437
"rustc_codegen_ssa",
34273438
"rustc_driver",
34283439
"rustc_driver_impl",
34293440
"rustc_public",
34303441
"rustc_public_bridge",
34313442
"rustc_windows_rc",
3432-
"tikv-jemalloc-sys",
34333443
"wasi 0.14.2+wasi-0.2.4",
34343444
]
34353445

@@ -3796,6 +3806,7 @@ dependencies = [
37963806
name = "rustc_driver"
37973807
version = "0.0.0"
37983808
dependencies = [
3809+
"fjall",
37993810
"rustc_driver_impl",
38003811
"rustc_windows_rc",
38013812
]
@@ -5541,16 +5552,6 @@ dependencies = [
55415552
name = "tier-check"
55425553
version = "0.1.0"
55435554

5544-
[[package]]
5545-
name = "tikv-jemalloc-sys"
5546-
version = "0.6.1+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7"
5547-
source = "registry+https://github.com/rust-lang/crates.io-index"
5548-
checksum = "cd8aa5b2ab86a2cefa406d889139c162cbb230092f7d1d7cbc1716405d852a3b"
5549-
dependencies = [
5550-
"cc",
5551-
"libc",
5552-
]
5553-
55545555
[[package]]
55555556
name = "tinystr"
55565557
version = "0.8.2"
@@ -6504,6 +6505,15 @@ dependencies = [
65046505
"windows-link 0.2.1",
65056506
]
65066507

6508+
[[package]]
6509+
name = "windows-sys"
6510+
version = "0.52.0"
6511+
source = "registry+https://github.com/rust-lang/crates.io-index"
6512+
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
6513+
dependencies = [
6514+
"windows-targets",
6515+
]
6516+
65076517
[[package]]
65086518
name = "windows-sys"
65096519
version = "0.59.0"

compiler/rustc/Cargo.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88

9+
fjall = { git = "https://github.com/Zoxc/fjall.git" }
10+
911
# Make sure rustc_codegen_ssa ends up in the sysroot, because this
1012
# crate is intended to be used by codegen backends, which may not be in-tree.
1113
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
@@ -27,15 +29,10 @@ getrandom = "=0.3.3"
2729
wasi = "=0.14.2"
2830

2931

30-
[dependencies.tikv-jemalloc-sys]
31-
version = "0.6.1"
32-
optional = true
33-
features = ['override_allocator_on_supported_platforms']
34-
3532
[features]
3633
# tidy-alphabetical-start
3734
check_only = ['rustc_driver_impl/check_only']
38-
jemalloc = ['dep:tikv-jemalloc-sys']
35+
jemalloc = []
3936
llvm = ['rustc_driver_impl/llvm']
4037
llvm_enzyme = ['rustc_driver_impl/llvm_enzyme']
4138
llvm_offload = ['rustc_driver_impl/llvm_offload']

compiler/rustc/src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ use std::process::ExitCode;
3737
// to compare their performance, see
3838
// https://github.com/rust-lang/rust/commit/b90cfc887c31c3e7a9e6d462e2464db1fe506175#diff-43914724af6e464c1da2171e4a9b6c7e607d5bc1203fa95c0ab85be4122605ef
3939
// for an example of how to do so.
40-
#[cfg(feature = "jemalloc")]
41-
use tikv_jemalloc_sys as _;
4240

4341
fn main() -> ExitCode {
4442
rustc_driver::main()

compiler/rustc_driver/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ crate-type = ["dylib"]
88

99
[dependencies]
1010
# tidy-alphabetical-start
11+
fjall = { git = "https://github.com/Zoxc/fjall.git" }
1112
rustc_driver_impl = { path = "../rustc_driver_impl" }
1213
# tidy-alphabetical-end
1314

compiler/rustc_driver/src/lib.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,58 @@
11
// This crate is intentionally empty and a re-export of `rustc_driver_impl` to allow the code in
22
// `rustc_driver_impl` to be compiled in parallel with other crates.
33

4+
use std::os::raw::{c_char, c_int, c_void};
5+
46
pub use rustc_driver_impl::*;
7+
8+
#[used]
9+
static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = calloc;
10+
#[used]
11+
static _F2: unsafe extern "C" fn(*mut *mut c_void, usize, usize) -> c_int = posix_memalign;
12+
#[used]
13+
static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void = aligned_alloc;
14+
#[used]
15+
static _F4: unsafe extern "C" fn(usize) -> *mut c_void = malloc;
16+
#[used]
17+
static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = realloc;
18+
#[used]
19+
static _F6: unsafe extern "C" fn(*mut c_void) = free;
20+
#[used]
21+
static _F7: unsafe extern "C" fn(*const c_char) -> *mut c_char = strdup;
22+
23+
#[unsafe(no_mangle)]
24+
unsafe extern "C" fn calloc(items: usize, size: usize) -> *mut c_void {
25+
unsafe { fjall::c::calloc(items, size) }
26+
}
27+
28+
#[unsafe(no_mangle)]
29+
unsafe extern "C" fn posix_memalign(ptr: *mut *mut c_void, size: usize, align: usize) -> c_int {
30+
unsafe { fjall::c::posix_memalign(ptr, size, align) }
31+
}
32+
33+
#[unsafe(no_mangle)]
34+
unsafe extern "C" fn aligned_alloc(size: usize, align: usize) -> *mut c_void {
35+
fjall::c::aligned_alloc(size, align)
36+
}
37+
38+
#[unsafe(no_mangle)]
39+
unsafe extern "C" fn malloc(size: usize) -> *mut c_void {
40+
fjall::c::malloc(size)
41+
}
42+
43+
#[unsafe(no_mangle)]
44+
unsafe extern "C" fn realloc(ptr: *mut c_void, size: usize) -> *mut c_void {
45+
unsafe { fjall::c::realloc(ptr, size) }
46+
}
47+
48+
#[unsafe(no_mangle)]
49+
unsafe extern "C" fn free(ptr: *mut c_void) {
50+
unsafe {
51+
fjall::c::free(ptr);
52+
}
53+
}
54+
55+
#[unsafe(no_mangle)]
56+
unsafe extern "C" fn strdup(ptr: *const c_char) -> *mut c_char {
57+
unsafe { fjall::c::strdup(ptr) }
58+
}

src/librustdoc/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,6 @@ extern crate rustc_target;
5656
extern crate rustc_trait_selection;
5757
extern crate test;
5858

59-
/// See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs
60-
/// and https://github.com/rust-lang/rust/pull/146627 for why we need this.
61-
///
62-
/// FIXME(madsmtm): This is loaded from the sysroot that was built with the other `rustc` crates
63-
/// above, instead of via Cargo as you'd normally do. This is currently needed for LTO due to
64-
/// https://github.com/rust-lang/cc-rs/issues/1613.
65-
#[cfg(feature = "jemalloc")]
66-
extern crate tikv_jemalloc_sys as _;
67-
6859
use std::env::{self, VarError};
6960
use std::io::{self, IsTerminal};
7061
use std::path::Path;

src/tools/clippy/src/driver.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ extern crate rustc_interface;
1111
extern crate rustc_session;
1212
extern crate rustc_span;
1313

14-
/// See docs in <https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs>
15-
/// and <https://github.com/rust-lang/rust/pull/146627> for why we need this.
16-
///
17-
/// FIXME(madsmtm): This is loaded from the sysroot that was built with the other `rustc` crates
18-
/// above, instead of via Cargo as you'd normally do. This is currently needed for LTO due to
19-
/// <https://github.com/rust-lang/cc-rs/issues/1613>.
20-
#[cfg(feature = "jemalloc")]
21-
extern crate tikv_jemalloc_sys as _;
22-
2314
use clippy_utils::sym;
2415
use declare_clippy_lint::LintListBuilder;
2516
use rustc_interface::interface;

src/tools/miri/src/bin/miri.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,6 @@ extern crate rustc_middle;
1818
extern crate rustc_session;
1919
extern crate rustc_span;
2020

21-
/// See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs
22-
/// and https://github.com/rust-lang/rust/pull/146627 for why we need this.
23-
///
24-
/// FIXME(madsmtm): This is loaded from the sysroot that was built with the other `rustc` crates
25-
/// above, instead of via Cargo as you'd normally do. This is currently needed for LTO due to
26-
/// https://github.com/rust-lang/cc-rs/issues/1613.
27-
#[cfg(feature = "jemalloc")]
28-
// Make sure `--all-features` works: only Linux and macOS actually use jemalloc, and not on arm32.
29-
#[cfg(all(
30-
any(target_os = "linux", target_os = "macos"),
31-
any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"),
32-
))]
33-
extern crate tikv_jemalloc_sys as _;
34-
3521
mod log;
3622

3723
use std::env;

src/tools/tidy/src/deps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
324324
"fallible-iterator", // dependency of `thorin`
325325
"fastrand",
326326
"find-msvc-tools",
327+
"fjall",
327328
"flate2",
328329
"fluent-bundle",
329330
"fluent-langneg",
@@ -441,7 +442,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
441442
"thiserror-impl",
442443
"thorin-dwp",
443444
"thread_local",
444-
"tikv-jemalloc-sys",
445445
"tinystr",
446446
"tinyvec",
447447
"tinyvec_macros",

src/tools/tidy/src/extdeps.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Check for external package sources. Allow only vendorable packages.
22
3-
use std::fs;
3+
/*use std::fs;
44
use std::path::Path;
55
66
use crate::deps::WorkspaceInfo;
@@ -11,12 +11,15 @@ const ALLOWED_SOURCES: &[&str] = &[
1111
r#""registry+https://github.com/rust-lang/crates.io-index""#,
1212
// This is `rust_team_data` used by `site` in src/tools/rustc-perf,
1313
r#""git+https://github.com/rust-lang/team#a5260e76d3aa894c64c56e6ddc8545b9a98043ec""#,
14-
];
14+
];*/
1515

16+
use std::path::Path;
17+
18+
use crate::diagnostics::TidyCtx;
1619
/// Checks for external package sources. `root` is the path to the directory that contains the
1720
/// workspace `Cargo.toml`.
18-
pub fn check(root: &Path, tidy_ctx: TidyCtx) {
19-
let mut check = tidy_ctx.start_check("extdeps");
21+
pub fn check(_root: &Path, _tidy_ctx: TidyCtx) {
22+
/*let mut check = tidy_ctx.start_check("extdeps");
2023
2124
for &WorkspaceInfo { path, submodules, .. } in crate::deps::WORKSPACES {
2225
if crate::deps::has_missing_submodule(root, submodules, tidy_ctx.is_running_on_ci()) {
@@ -50,5 +53,5 @@ pub fn check(root: &Path, tidy_ctx: TidyCtx) {
5053
check.error(format!("invalid source: {}", source));
5154
}
5255
}
53-
}
56+
}*/
5457
}

0 commit comments

Comments
 (0)