Skip to content

Commit 5614e05

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 9955eb0 commit 5614e05

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
@@ -15,25 +15,28 @@ mod tests;
1515

1616
extern "Rust" {
1717
// These are the magic symbols to call the global allocator. rustc generates
18-
// them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute
18+
// them to call the global allocator if there is a `#[global_allocator]` attribute
1919
// (the code expanding that attribute macro generates those functions), or to call
2020
// the default implementations in std (`__rdl_alloc` etc. in `library/std/src/alloc.rs`)
2121
// otherwise.
22-
// The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them
23-
// like `malloc`, `realloc`, and `free`, respectively.
2422
#[rustc_allocator]
2523
#[rustc_nounwind]
24+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
2625
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
2726
#[rustc_deallocator]
2827
#[rustc_nounwind]
28+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
2929
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
3030
#[rustc_reallocator]
3131
#[rustc_nounwind]
32+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
3233
fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8;
3334
#[rustc_allocator_zeroed]
3435
#[rustc_nounwind]
36+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
3537
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
3638

39+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
3740
static __rust_no_alloc_shim_is_unstable: u8;
3841
}
3942

@@ -359,6 +362,7 @@ 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
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
@@ -76,9 +76,11 @@ cfg_if::cfg_if! {
7676
extern "C" {
7777
/// Handler in std called when a panic object is dropped outside of
7878
/// `catch_unwind`.
79+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
7980
fn __rust_drop_panic() -> !;
8081

8182
/// Handler in std called when a foreign exception is caught.
83+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
8284
fn __rust_foreign_exception() -> !;
8385
}
8486

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
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
@@ -39,12 +39,14 @@ use crate::{fmt, intrinsics, process, thread};
3939
// hook up these functions, but it is not this day!
4040
#[allow(improper_ctypes)]
4141
extern "C" {
42+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
4243
fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static);
4344
}
4445

4546
extern "Rust" {
4647
/// `PanicPayload` lazily performs allocation only when needed (this avoids
4748
/// allocations when using the "abort" panic runtime).
49+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
4850
fn __rust_start_panic(payload: &mut dyn PanicPayload) -> u32;
4951
}
5052

0 commit comments

Comments
 (0)