Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

gccrs#4556: Add allocator attrs

Link: Rust-GCC/gccrs#4556

Objective

This PR introduces three new built-in compiler attributes (rustc_std_internal_symbol, rustc_allocator, and rustc_allocator_nounwind) required for alloc crate integration.

Changes Made

Added parsing and handling support for these three attributes in the compiler.

Why is this needed for alloc?

rustc_std_internal_symbol: Prevents name mangling for internal runtime symbols.

rustc_allocator and rustc_allocator_nounwind: Instruct the GCC backend to apply malloc and nothrow.

Test Case

#![allow(unused)]
fn main() {
#[rustc_allocator]
#[rustc_allocator_nounwind]
pub fn foo() -> *mut u8 {
    0 as *mut u8
}

#[rustc_std_internal_symbol]
pub fn bar() -> i32 {
    0
}
}