Skip to content

Commit 7a6a4e8

Browse files
authored
Merge pull request #4687 from rust-lang/rustup-2025-11-14
Automatic Rustup
2 parents 4894162 + 1c1caab commit 7a6a4e8

File tree

4 files changed

+45
-9
lines changed

4 files changed

+45
-9
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ serde_json = { version = "1.0", optional = true }
3333
# But only for some targets, it fails for others. Rustc configures this in its CI, but we can't
3434
# easily use that since we support of-tree builds.
3535
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies.tikv-jemalloc-sys]
36-
version = "0.6.1"
37-
features = ['override_allocator_on_supported_platforms']
36+
version = "0.6.0"
37+
features = ['unprefixed_malloc_on_supported_platforms']
3838

3939
[target.'cfg(unix)'.dependencies]
4040
libc = "0.2"

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0b329f801a09004dacb19aaf09d5cb8b4c51d3f8
1+
7a72c5459dd58f81b0e1a0e5436d145485889375

src/bin/miri.rs

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ extern crate rustc_middle;
2020
extern crate rustc_session;
2121
extern crate rustc_span;
2222

23-
/// See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs
24-
/// and https://github.com/rust-lang/rust/pull/146627 for why we need this `use` statement.
25-
#[cfg(any(target_os = "linux", target_os = "macos"))]
26-
use tikv_jemalloc_sys as _;
27-
2823
mod log;
2924

3025
use std::env;
@@ -397,7 +392,48 @@ fn parse_range(val: &str) -> Result<Range<u32>, &'static str> {
397392
Ok(from..to)
398393
}
399394

395+
#[cfg(any(target_os = "linux", target_os = "macos"))]
396+
fn jemalloc_magic() {
397+
// These magic runes are copied from
398+
// <https://github.com/rust-lang/rust/blob/e89bd9428f621545c979c0ec686addc6563a394e/compiler/rustc/src/main.rs#L39>.
399+
// See there for further comments.
400+
use std::os::raw::{c_int, c_void};
401+
402+
use tikv_jemalloc_sys as jemalloc_sys;
403+
404+
#[used]
405+
static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::calloc;
406+
#[used]
407+
static _F2: unsafe extern "C" fn(*mut *mut c_void, usize, usize) -> c_int =
408+
jemalloc_sys::posix_memalign;
409+
#[used]
410+
static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::aligned_alloc;
411+
#[used]
412+
static _F4: unsafe extern "C" fn(usize) -> *mut c_void = jemalloc_sys::malloc;
413+
#[used]
414+
static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = jemalloc_sys::realloc;
415+
#[used]
416+
static _F6: unsafe extern "C" fn(*mut c_void) = jemalloc_sys::free;
417+
418+
// On OSX, jemalloc doesn't directly override malloc/free, but instead
419+
// registers itself with the allocator's zone APIs in a ctor. However,
420+
// the linker doesn't seem to consider ctors as "used" when statically
421+
// linking, so we need to explicitly depend on the function.
422+
#[cfg(target_os = "macos")]
423+
{
424+
unsafe extern "C" {
425+
fn _rjem_je_zone_register();
426+
}
427+
428+
#[used]
429+
static _F7: unsafe extern "C" fn() = _rjem_je_zone_register;
430+
}
431+
}
432+
400433
fn main() {
434+
#[cfg(any(target_os = "linux", target_os = "macos"))]
435+
jemalloc_magic();
436+
401437
let early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
402438

403439
// Snapshot a copy of the environment before `rustc` starts messing with it.

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#![feature(derive_coerce_pointee)]
1818
#![feature(arbitrary_self_types)]
1919
#![feature(iter_advance_by)]
20-
#![feature(duration_from_nanos_u128)]
20+
#![cfg_attr(bootstrap, feature(duration_from_nanos_u128))]
2121
// Configure clippy and other lints
2222
#![allow(
2323
clippy::collapsible_else_if,

0 commit comments

Comments
 (0)