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

Correct branch-protection ModFlagBehavior for Aarch64 on LLVM-15 #105932

Merged
merged 2 commits into from
Dec 22, 2022

Conversation

MasterAwesome
Copy link
Contributor

@MasterAwesome MasterAwesome commented Dec 20, 2022

When building with Fat LTO and BTI enabled on aarch64, the BTI is set to Module::Min for alloc shim but is set to Module::Error for the crate. This was fine when we were using LLVM-14 but LLVM-15 changes it's behaviour to support for compiling with different mbranch-protection flags.

Refer:
rust-lang/llvm-project@b0343a3

fixes #102162

When building with Fat LTO and BTI enabled on aarch64, the BTI is set to
`Module::Min` for alloc shim but is set to `Module::Error` for the
crate. This was fine when we were using LLVM-14 but LLVM-15 changes it's
behaviour to support for compiling with different `mbranch-protection`
flags.

Refer:
rust-lang/llvm-project@b0343a3
@rustbot
Copy link
Collaborator

rustbot commented Dec 20, 2022

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) soon.

Please see the contribution instructions for more information.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 20, 2022
@MasterAwesome MasterAwesome changed the title Correct ModFlagBehavior for Aarch64 on LLVM-15 Correct branch-protection ModFlagBehavior for Aarch64 on LLVM-15 Dec 20, 2022
@rust-log-analyzer

This comment has been minimized.

@nikic
Copy link
Contributor

nikic commented Dec 20, 2022

Min is new in LLVM 15, so this will have to be dependent on version.

Either need to pass in Min/Error depending on version, or possibly adjust

extern "C" void LLVMRustAddModuleFlag(
to automatically use Error instead of Min for old versions.

@MasterAwesome
Copy link
Contributor Author

MasterAwesome commented Dec 20, 2022

Ah I see, I'll do an FFI call prior to setting the modflagbehavior to get the version and choose Min if >= 15.

I could add that in the cpp file but I think it might hide future hard to debug issues where the rustc_codegen_llvm chooses Min but it's translated to Error in there.

What do you think?

@nikic
Copy link
Contributor

nikic commented Dec 20, 2022

Either way is fine by me. On the Rust side, there's already a llvm_version variable inside that function, so you can pick based on that (llvm_version >= (15, 0, 0) or so).

CI fails when building with LLVM-13. This raises unknown behavior
constant `8` from IRVerifier.
@nikic
Copy link
Contributor

nikic commented Dec 21, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Dec 21, 2022

📌 Commit 5480ac5 has been approved by nikic

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 Dec 21, 2022
fee1-dead added a commit to fee1-dead-contrib/rust that referenced this pull request Dec 21, 2022
… r=nikic

Correct branch-protection ModFlagBehavior for Aarch64 on LLVM-15

When building with Fat LTO and BTI enabled on aarch64, the BTI is set to `Module::Min` for alloc shim but is set to `Module::Error` for the crate. This was fine when we were using LLVM-14 but LLVM-15 changes it's behaviour to support for compiling with different `mbranch-protection` flags.

Refer:
rust-lang/llvm-project@b0343a3

fixes rust-lang#102162
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 22, 2022
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#105837 (Don't ICE in `check_must_not_suspend_ty` for mismatched tuple arity)
 - rust-lang#105932 (Correct branch-protection ModFlagBehavior for Aarch64 on LLVM-15)
 - rust-lang#105960 (Various cleanups)
 - rust-lang#105985 (Method chain nitpicks)
 - rust-lang#105996 (Test that async blocks are `UnwindSafe`)
 - rust-lang#106012 (Clarify that raw retags are not permitted in Mir)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 924a1d4 into rust-lang:master Dec 22, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 22, 2022
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#105837 (Don't ICE in `check_must_not_suspend_ty` for mismatched tuple arity)
 - rust-lang#105932 (Correct branch-protection ModFlagBehavior for Aarch64 on LLVM-15)
 - rust-lang#105960 (Various cleanups)
 - rust-lang#105985 (Method chain nitpicks)
 - rust-lang#105996 (Test that async blocks are `UnwindSafe`)
 - rust-lang#106012 (Clarify that raw retags are not permitted in Mir)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[aarch64] Regression with BTI after nightly-2022-08-14
6 participants