Skip to content

Commit 2bdf37a

Browse files
committed
Mark imports of #[rustc_std_internal_symbol] items with this attribute
This ensures that they will be correctly mangled in a future commit.
1 parent 9bd6997 commit 2bdf37a

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

library/alloc/src/alloc.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,28 @@ use core::ptr::{self, NonNull};
1212

1313
unsafe extern "Rust" {
1414
// These are the magic symbols to call the global allocator. rustc generates
15-
// them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute
15+
// them to call the global allocator if there is a `#[global_allocator]` attribute
1616
// (the code expanding that attribute macro generates those functions), or to call
1717
// the default implementations in std (`__rdl_alloc` etc. in `library/std/src/alloc.rs`)
1818
// otherwise.
19-
// The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them
20-
// like `malloc`, `realloc`, and `free`, respectively.
2119
#[rustc_allocator]
2220
#[rustc_nounwind]
21+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
2322
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
2423
#[rustc_deallocator]
2524
#[rustc_nounwind]
25+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
2626
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
2727
#[rustc_reallocator]
2828
#[rustc_nounwind]
29+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
2930
fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8;
3031
#[rustc_allocator_zeroed]
3132
#[rustc_nounwind]
33+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
3234
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
3335

36+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
3437
static __rust_no_alloc_shim_is_unstable: u8;
3538
}
3639

@@ -359,6 +362,7 @@ unsafe extern "Rust" {
359362
// This is the magic symbol to call the global alloc error handler. rustc generates
360363
// it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the
361364
// default implementations below (`__rdl_oom`) otherwise.
365+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
362366
fn __rust_alloc_error_handler(size: usize, align: usize) -> !;
363367
}
364368

@@ -429,6 +433,7 @@ pub mod __alloc_error_handler {
429433
unsafe extern "Rust" {
430434
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
431435
// Its value depends on the -Zoom={panic,abort} compiler option.
436+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
432437
static __rust_alloc_error_handler_should_panic: u8;
433438
}
434439

library/panic_unwind/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,11 @@ cfg_if::cfg_if! {
7979
unsafe extern "C" {
8080
/// Handler in std called when a panic object is dropped outside of
8181
/// `catch_unwind`.
82+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
8283
fn __rust_drop_panic() -> !;
8384

8485
/// Handler in std called when a foreign exception is caught.
86+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
8587
fn __rust_foreign_exception() -> !;
8688
}
8789

library/std/src/alloc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ fn default_alloc_error_hook(layout: Layout) {
348348
unsafe extern "Rust" {
349349
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
350350
// Its value depends on the -Zoom={panic,abort} compiler option.
351+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
351352
static __rust_alloc_error_handler_should_panic: u8;
352353
}
353354

library/std/src/panicking.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ pub static EMPTY_PANIC: fn(&'static str) -> ! =
5555
// hook up these functions, but it is not this day!
5656
#[allow(improper_ctypes)]
5757
unsafe extern "C" {
58+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
5859
fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static);
5960
}
6061

6162
unsafe extern "Rust" {
6263
/// `PanicPayload` lazily performs allocation only when needed (this avoids
6364
/// allocations when using the "abort" panic runtime).
65+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
6466
fn __rust_start_panic(payload: &mut dyn PanicPayload) -> u32;
6567
}
6668

0 commit comments

Comments
 (0)