Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default_alloc_error_handler requires the linker to omit __rg_oom from liballoc #95113

Closed
bjorn3 opened this issue Mar 19, 2022 · 1 comment
Closed
Labels
A-cranelift Things relevant to the [future] cranelift backend C-bug Category: This is a bug.

Comments

@bjorn3
Copy link
Member

bjorn3 commented Mar 19, 2022

__rg_oom calls the rust_oom symbol (aka the "oom" weak lang item). This symbol is not defined when using default_alloc_error_handler.

// if there is an `#[alloc_error_handler]`
#[rustc_std_internal_symbol]
pub unsafe extern "C-unwind" fn __rg_oom(size: usize, align: usize) -> ! {
let layout = unsafe { Layout::from_size_align_unchecked(size, align) };
extern "Rust" {
#[lang = "oom"]
fn oom_impl(layout: Layout) -> !;
}
unsafe { oom_impl(layout) }
}

This causes https://github.com/rust-lang/rust/blob/31535841701e0bf7ef33998024376f2cedd8b3e3/src/test/ui/allocator/no_std-alloc-error-handler-default.rs to fail with cg_clif as it uses -Zfunction-sections=no by default. I suspect it would also cause it to fail for windows as windows has this default too.

Applying the approach of #86844 to the alloc error handler too should trivially fix this. This PR is still pending decision if it should be done or not.

@bjorn3
Copy link
Member Author

bjorn3 commented Nov 22, 2022

Fixed by #103061.

@bjorn3 bjorn3 closed this as completed Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cranelift Things relevant to the [future] cranelift backend C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

1 participant