Skip to content

Commit 683ca74

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 a22971d commit 683ca74

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

library/alloc/src/alloc.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,28 @@ mod tests;
1717

1818
extern "Rust" {
1919
// These are the magic symbols to call the global allocator. rustc generates
20-
// them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute
20+
// them to call the global allocator if there is a `#[global_allocator]` attribute
2121
// (the code expanding that attribute macro generates those functions), or to call
2222
// the default implementations in std (`__rdl_alloc` etc. in `library/std/src/alloc.rs`)
2323
// otherwise.
24-
// The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them
25-
// like `malloc`, `realloc`, and `free`, respectively.
2624
#[rustc_allocator]
2725
#[rustc_nounwind]
26+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
2827
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
2928
#[rustc_deallocator]
3029
#[rustc_nounwind]
30+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
3131
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
3232
#[rustc_reallocator]
3333
#[rustc_nounwind]
34+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
3435
fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8;
3536
#[rustc_allocator_zeroed]
3637
#[rustc_nounwind]
38+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
3739
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
3840

41+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
3942
static __rust_no_alloc_shim_is_unstable: u8;
4043
}
4144

@@ -342,6 +345,7 @@ extern "Rust" {
342345
// This is the magic symbol to call the global alloc error handler. rustc generates
343346
// it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the
344347
// default implementations below (`__rdl_oom`) otherwise.
348+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
345349
fn __rust_alloc_error_handler(size: usize, align: usize) -> !;
346350
}
347351

@@ -411,6 +415,7 @@ pub mod __alloc_error_handler {
411415
extern "Rust" {
412416
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
413417
// Its value depends on the -Zoom={panic,abort} compiler option.
418+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
414419
static __rust_alloc_error_handler_should_panic: u8;
415420
}
416421

library/panic_unwind/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ cfg_if::cfg_if! {
8787
extern "C" {
8888
/// Handler in std called when a panic object is dropped outside of
8989
/// `catch_unwind`.
90+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
9091
fn __rust_drop_panic() -> !;
9192

9293
/// Handler in std called when a foreign exception is caught.
94+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
9395
fn __rust_foreign_exception() -> !;
9496
}
9597

library/std/src/alloc.rs

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

library/std/src/panicking.rs

+2
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ use realstd::io::try_set_output_capture;
4242
// hook up these functions, but it is not this day!
4343
#[allow(improper_ctypes)]
4444
extern "C" {
45+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
4546
fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static);
4647
}
4748

4849
extern "Rust" {
4950
/// `PanicPayload` lazily performs allocation only when needed (this avoids
5051
/// allocations when using the "abort" panic runtime).
52+
#[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]
5153
fn __rust_start_panic(payload: &mut dyn PanicPayload) -> u32;
5254
}
5355

0 commit comments

Comments
 (0)