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

Conversation

Amanieu
Copy link
Member

@Amanieu Amanieu commented Oct 14, 2022

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).

@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 14, 2022
@rust-highfive
Copy link
Collaborator

r? @lcnr

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

@rustbot
Copy link
Collaborator

rustbot commented Oct 14, 2022

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 14, 2022
@lcnr
Copy link
Contributor

lcnr commented Oct 17, 2022

r? compiler

@bors
Copy link
Contributor

bors commented Oct 21, 2022

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

@compiler-errors
Copy link
Member

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

@cjgillot
Copy link
Contributor

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

@rust-highfive rust-highfive assigned bjorn3 and unassigned cjgillot Oct 23, 2022
@bjorn3
Copy link
Member

bjorn3 commented Oct 23, 2022

r=me with merge conflicts fixed.

@Noratrieb
Copy link
Member

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!

@bjorn3
Copy link
Member

bjorn3 commented Oct 25, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Oct 25, 2022

📌 Commit d2352e11fa03ff32cddaf9f7bcad8907007f2539 has been approved by bjorn3

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 25, 2022
@bors
Copy link
Contributor

bors commented Oct 31, 2022

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

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 31, 2022
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
Copy link
Member Author

Amanieu commented Oct 31, 2022

@bors r=bjorn3

@bors
Copy link
Contributor

bors commented Oct 31, 2022

📌 Commit 56074b5 has been approved by bjorn3

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 31, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 1, 2022
Rollup of 6 pull requests

Successful merges:

 - rust-lang#103061 (Rewrite implementation of `#[alloc_error_handler]`)
 - rust-lang#103584 (Remove bounds check when array is indexed by enum)
 - rust-lang#103706 (Fix E0433 No Typo Suggestions)
 - rust-lang#103729 (interpret: fix align_of_val on packed types)
 - rust-lang#103759 (Use `adt_def` during type collection.)
 - rust-lang#103809 (Fix a typo in std::net mod doc comment)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4363467 into rust-lang:master Nov 1, 2022
@rustbot rustbot added this to the 1.67.0 milestone Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants