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

Rewrite implementation of #[alloc_error_handler] #103061

Merged
merged 1 commit into from
Nov 1, 2022

Commits on Oct 31, 2022

  1. Rewrite implementation of #[alloc_error_handler]

    The new implementation doesn't use weak lang items and instead changes
    `#[alloc_error_handler]` to an attribute macro just like
    `#[global_allocator]`.
    
    The attribute will generate the `__rg_oom` function which is called by
    the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom`
    function is defined in any crate then the compiler shim will call
    `__rdl_oom` in the alloc crate which will simply panic.
    
    This also fixes link errors with `-C link-dead-code` with
    `default_alloc_error_handler`: `__rg_oom` was previously defined in the
    alloc crate and would attempt to reference the `oom` lang item, even if
    it didn't exist. This worked as long as `__rg_oom` was excluded from
    linking since it was not called.
    
    This is a prerequisite for the stabilization of
    `default_alloc_error_handler` (rust-lang#102318).
    Amanieu committed Oct 31, 2022
    Configuration menu
    Copy the full SHA
    56074b5 View commit details
    Browse the repository at this point in the history