Mark imports of #[rustc_std_internal_symbol] items with this attribute

This ensures that they will be correctly mangled in a future commit.
This commit is contained in:
bjorn3 2023-12-02 13:52:47 +00:00
parent 60b785fc8d
commit 42de015549
4 changed files with 13 additions and 3 deletions

View file

@ -10,25 +10,28 @@ use core::ptr::{self, NonNull};
unsafe extern "Rust" {
// These are the magic symbols to call the global allocator. rustc generates
// them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute
// them to call the global allocator if there is a `#[global_allocator]` attribute
// (the code expanding that attribute macro generates those functions), or to call
// the default implementations in std (`__rdl_alloc` etc. in `library/std/src/alloc.rs`)
// otherwise.
// The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them
// like `malloc`, `realloc`, and `free`, respectively.
#[rustc_allocator]
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
#[rustc_deallocator]
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
#[rustc_reallocator]
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8;
#[rustc_allocator_zeroed]
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
static __rust_no_alloc_shim_is_unstable: u8;
}
@ -357,6 +360,7 @@ unsafe extern "Rust" {
// This is the magic symbol to call the global alloc error handler. rustc generates
// it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the
// default implementations below (`__rdl_oom`) otherwise.
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
fn __rust_alloc_error_handler(size: usize, align: usize) -> !;
}
@ -423,6 +427,7 @@ pub mod __alloc_error_handler {
unsafe extern "Rust" {
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
// Its value depends on the -Zoom={panic,abort} compiler option.
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
static __rust_alloc_error_handler_should_panic: u8;
}

View file

@ -79,9 +79,11 @@ cfg_if::cfg_if! {
unsafe extern "C" {
/// Handler in std called when a panic object is dropped outside of
/// `catch_unwind`.
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
fn __rust_drop_panic() -> !;
/// Handler in std called when a foreign exception is caught.
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
fn __rust_foreign_exception() -> !;
}

View file

@ -348,6 +348,7 @@ fn default_alloc_error_hook(layout: Layout) {
unsafe extern "Rust" {
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
// Its value depends on the -Zoom={panic,abort} compiler option.
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
static __rust_alloc_error_handler_should_panic: u8;
}

View file

@ -55,12 +55,14 @@ pub static EMPTY_PANIC: fn(&'static str) -> ! =
// hook up these functions, but it is not this day!
#[allow(improper_ctypes)]
unsafe extern "C" {
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static);
}
unsafe extern "Rust" {
/// `PanicPayload` lazily performs allocation only when needed (this avoids
/// allocations when using the "abort" panic runtime).
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
fn __rust_start_panic(payload: &mut dyn PanicPayload) -> u32;
}