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

Fix codegen test suite for bare-metal-like targets #111878

Merged
merged 4 commits into from
Jun 3, 2023

Conversation

pietroalbini
Copy link
Member

For Ferrocene I needed to run the test suite for custom target with no unwinding and static relocation. Running the tests uncovered ~20 failures due to the test suite not accounting for these options. This PR fixes them by:

  • Fixing CHECKs to account for functions having extra LLVM IR attributes (in this case nounwind).
  • Fixing CHECKs to account for the dso_local LLVM IR modifier, which is added to every item when relocation is static.
  • Fixing CHECKs to account for missing uwtables attributes.
  • Added the needs-unwind attributes for tests that are designed to check unwinding.

There is no part of Rust CI that checks this unfortunately, and testing whether the PR works locally is kinda hard because you need a target with std enabled but no unwinding and static relocations. Still, this works in my local testing, and if future PRs accidentally break this Ferrocene will take care of sending followup PRs.

When compiling with panic=abort (or using a target that doesn't have
unwinding support), the compiler adds the "nounwind" attribute to
functions. This results in a different LLVM IR, which results in a #NNN
added after the function name:

    tail call void @bar() rust-lang#13, !dbg !467
    attributes rust-lang#13 = { nounwind }

...instead of:

    tail call void @bar(), !dbg !467

This commit changes the matchers to swallow the #NNN, as it's not needed
for these specific tests.
The attribute is injected into most items when static relocation is
enabled in a target.
The attribute is not emitted on targets without unwinding tables.
@rustbot
Copy link
Collaborator

rustbot commented May 23, 2023

r? @Mark-Simulacrum

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 23, 2023
@Mark-Simulacrum
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jun 3, 2023

📌 Commit 5f0b677 has been approved by Mark-Simulacrum

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 Jun 3, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 3, 2023
…-Simulacrum

Fix codegen test suite for bare-metal-like targets

For Ferrocene I needed to run the test suite for custom target with no unwinding and static relocation. Running the tests uncovered ~20 failures due to the test suite not accounting for these options. This PR fixes them by:

* Fixing `CHECK`s to account for functions having extra LLVM IR attributes (in this case `nounwind`).
* Fixing `CHECK`s to account for the `dso_local` LLVM IR modifier, which is [added to every item when relocation is static](https://github.com/rust-lang/rust/blob/f3d597b31c0f101a02c230798afa31a36bdacbc6/compiler/rustc_codegen_llvm/src/mono_item.rs#L139-L142).
* Fixing `CHECK`s to account for missing `uwtables` attributes.
* Added the `needs-unwind` attributes for tests that are designed to check unwinding.

There is no part of Rust CI that checks this unfortunately, and testing whether the PR works locally is kinda hard because you need a target with std enabled but no unwinding and static relocations. Still, this works in my local testing, and if future PRs accidentally break this Ferrocene will take care of sending followup PRs.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 3, 2023
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#111659 (suggest `Option::as_deref(_mut)` on type mismatch in option combinator if it passes typeck)
 - rust-lang#111702 (Option::map_or_else: Show an example of integrating with Result)
 - rust-lang#111878 (Fix codegen test suite for bare-metal-like targets)
 - rust-lang#111969 (bootstrap: Make `clean` respect `dry-run`)
 - rust-lang#111998 (Add other workspaces to `linkedProjects` in rust_analyzer_settings)
 - rust-lang#112215 (only suppress coercion error if type is definitely unsized)
 - rust-lang#112231 (Make sure the build.rustc version is either the same or 1 apart (revised))

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit bdf9ed4 into rust-lang:master Jun 3, 2023
@rustbot rustbot added this to the 1.72.0 milestone Jun 3, 2023
@pietroalbini pietroalbini deleted the pa-codegen-tests branch June 4, 2023 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants