-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Some mixes of Rust with C/C++ are broken for arm64 mac and windows #92885
Comments
It should be off by default. My first guess is that the problem is that we set the module flag unconditionally, but with a true/false value, so perhaps a false value is not equivalent to an unset value. If that is the problem then there might be something deeper to investigate here, like some BTI mismatch between the Rust and C/C++ code that wasn't previously spotted. It would be interesting to know if the C/C++ code is compiled with BTI enabled. I don't have Firefox (or recent Rust) build environment on my M1 Mac so it'll take me a while to reproduce. I'll make a start, but if others can get there first and unblock this quickly, then please do! We could also revert #88354 from beta whilst we investigate. I'm not sure of the process there. |
It most probably involves linker-plugin-lto. A default firefox build wouldn't enable that. I suspect it's reproducible with a simple testcase that has both C and C++ code with linker-plugin-lto enabled. |
(beware of #60059 if you try to use linker-plugin-lto) |
Ok, I was also able to reproduce locally with a Linux aarch64 cross-build (modulo https://bugzilla.mozilla.org/show_bug.cgi?id=1749852) and it turns out the rust llvm-ir has:
while the clang llvm-ir has:
llvm-ir from older versions of rust didn't have them at all. |
Nor does the llvm-ir from older versions of clang — at least the one I have pre-built — so the simple idea of marking them as |
why do you think so? the llvm-ir that doesn't contain these flags at all links fine with the llvm-ir that does (even with behavior set to Error). |
It was my own (naive) assumption, based on how BTI itself works: it's not correct to treat non-BTI machine code as BTI because if it lacks the BTI instructions it will be impossible to call any of its functions. However, that's not particularly relevant as this logic is all resolved before code generation. That leaves two candidate solutions, then:
Given the behaviour you described, and the LTO compatibility statement — "Best results are achieved by using a I'll start working on that today. |
Assigning priority as discussed in the Zulip thread of the Prioritization Working Group. @rustbot label -I-prioritize +P-high |
…petrochenkov Use error-on-mismatch policy for PAuth module flags. This agrees with Clang, and avoids an error when using LTO with mixed C/Rust. LLVM considers different behaviour flags to be a mismatch, even when the flag value itself is the same. This also makes the flag setting explicit for all uses of LLVMRustAddModuleFlag. ---- I believe that this fixes rust-lang#92885, but have only reproduced it locally on Linux hosts so cannot confirm that it fixes the issue as reported. I have not included a test for this because it is covered by an existing test (`src/test/run-make-fulldeps/cross-lang-lto-clang`). It is not without its problems, though: * The test requires Clang and `--run-clang-based-tests-with=...` to run, and this is not the case on the CI. * Any test I add would have a similar requirement. * With this patch applied, the test gets further, but it still fails (for other reasons). I don't think that affects rust-lang#92885.
This reverts commit d331cb7, reversing changes made to 78fd0f6. This is a fix for rust-lang#92885 as discussed on Zulip[1]. [1] https://zulip-archive.rust-lang.org/stream/238009-t-compiler/meetings/topic/.5Bweekly.5D.202022-01-27.20.2354818.html#269588396
Reopening to track beta fix (proposed in #93523). |
… r=Mark-Simulacrum beta: Revert -Zbranch-protection This reverts commit d331cb7, reversing changes made to 78fd0f6. This fixes rust-lang#92885 as discussed on Zulip[1]. [1] https://zulip-archive.rust-lang.org/stream/238009-t-compiler/meetings/topic/.5Bweekly.5D.202022-01-27.20.2354818.html#269588396 r? `@Mark-Simulacrum`
After #88354, Firefox builds fail with e.g:
This happens when targeting arm64 macos or arm64 windows.
Not only did the default change and now diverges from clang (causing the above error when mixing objects from clang and rust), but it's also apparently not possible to disable the feature.
Note this also now reached beta.
Cc: @jacobbramley, @Jmc18134, @nagisa
The text was updated successfully, but these errors were encountered: