diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-12-02 13:52:47 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-03-17 14:06:56 +0000 |
| commit | 42de015549ad6e60d6f0e603daf0948259a2840d (patch) | |
| tree | 624e29f89b18f3bac4c05342f3a08975b0d1d0c0 | |
| parent | 60b785fc8d2ca002189c7c4956f46e3ebe66fb63 (diff) | |
| download | rust-42de015549ad6e60d6f0e603daf0948259a2840d.tar.gz rust-42de015549ad6e60d6f0e603daf0948259a2840d.zip | |
Mark imports of #[rustc_std_internal_symbol] items with this attribute
This ensures that they will be correctly mangled in a future commit.
| -rw-r--r-- | library/alloc/src/alloc.rs | 11 | ||||
| -rw-r--r-- | library/panic_unwind/src/lib.rs | 2 | ||||
| -rw-r--r-- | library/std/src/alloc.rs | 1 | ||||
| -rw-r--r-- | library/std/src/panicking.rs | 2 |
4 files changed, 13 insertions, 3 deletions
diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index 2f752f6eb39..1e03a191276 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -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; } diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs index a284633ea2f..e5c1d6bdb3b 100644 --- a/library/panic_unwind/src/lib.rs +++ b/library/panic_unwind/src/lib.rs @@ -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() -> !; } diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index 99d105a2454..5d2a304b41c 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -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; } diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index b47b41d4bc5..b35549c92ad 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -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; } |
