rust icon indicating copy to clipboard operation
rust copied to clipboard

Rewrite implementation of `#[alloc_error_handler]`

Open Amanieu opened this issue 1 year ago • 3 comments

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 (#102318).

Amanieu avatar Oct 14 '22 18:10 Amanieu

r? @lcnr

(rust-highfive has picked a reviewer for you, use r? to override)

rust-highfive avatar Oct 14 '22 18:10 rust-highfive

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

rustc_error_messages was changed

cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

rustbot avatar Oct 14 '22 18:10 rustbot

r? compiler

lcnr avatar Oct 17 '22 08:10 lcnr

:umbrella: The latest upstream changes (presumably #103310) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Oct 21 '22 13:10 bors

r? compiler not sure if I'm the best person to review this

compiler-errors avatar Oct 22 '22 21:10 compiler-errors

r? @bjorn3 as you've been working on this recently

cjgillot avatar Oct 23 '22 09:10 cjgillot

r=me with merge conflicts fixed.

bjorn3 avatar Oct 23 '22 10:10 bjorn3

Hi, I've seen you changed some diagnostic structs in your PR. After #103345, the way we refer to fluent messages changed. They are now in a flat namespace with the same identifier as in the fluent file. For example, parser::cool_thing is now parser_cool_thing and parser::suggestion just suggestion. You should rebase to the latest master and change your fluent message references as described above. Thanks!

Nilstrieb avatar Oct 23 '22 11:10 Nilstrieb

@bors r+

bjorn3 avatar Oct 25 '22 15:10 bjorn3

:pushpin: Commit d2352e11fa03ff32cddaf9f7bcad8907007f2539 has been approved by bjorn3

It is now in the queue for this repository.

bors avatar Oct 25 '22 15:10 bors

:umbrella: The latest upstream changes (presumably #103797) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Oct 31 '22 16:10 bors

@bors r=bjorn3

Amanieu avatar Oct 31 '22 16:10 Amanieu

:pushpin: Commit 56074b5231ceef266a1097ea355f62c951e1b468 has been approved by bjorn3

It is now in the queue for this repository.

bors avatar Oct 31 '22 16:10 bors