-
Notifications
You must be signed in to change notification settings - Fork 13.3k
LLVM ERROR: Cannot select: intrinsic %llvm.x86.aesni.aesenc #94326
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
Comments
I believe this is happening due to the |
Well, in fact I am not very familiar with rust. So this may not be a bug of rustc ? Just a bug of a crate? |
Possibly. Can't say for sure at the moment, it might be an error in how we steer inlining and feature annotations in general. Also, what's weird is that an i7-4790 CPU has AESNI support, so there's no clear reason why building it natively shouldn't work. |
Got it. If more information needed, please let me know. |
Does this happen during the first build or the post-profiling one that does PGO? If PGO is not relevant, that's more worrying - but also, I'm surprised the LLVM devs didn't bring up PGO. |
This occurs in second build, I mean the post-profiling one that does PGO, with thin LTO |
And yes, every steps ran on the same CPU. I build |
Oh. I don't believe the Rust toolchain has anything to do with PGO or ThinLTO except sometimes turning it on via flags, am I wrong? |
I think thin LTO is handled by lld, and PGO is handled by LLVM. And |
What happens if you replace all occurrences of "native" with the appropriate value? ( Right now I'm expecting either |
Ok, I will have a try. |
And I mentioned, same environment (clang, rustc and so on with same version, and using |
Well, with stable rust version |
Well, with rust |
Tried again and now I can confirm that with |
Finally I am sure |
Thanks! It would be useful to get an "expansion" of what Sadly, I'm not sure how to do this, as both builds are probably deeply nested within Firefox's build system. |
The global attributes obtained from rust/compiler/rustc_codegen_llvm/src/attributes.rs Lines 412 to 423 in 6f681a8
The global attributes are still in effect, since target machine configuration includes them. At the same time the global attributes are not persisted with LLVM bitcode, so if loaded with a different set of target features the bitcode will be misinterpreted. For example, I can reproduce this issue by:
cc @nagisa |
rust/compiler/rustc_codegen_llvm/src/attributes.rs Lines 191 to 199 in 6f681a8
and rust/compiler/rustc_codegen_llvm/src/attributes.rs Lines 333 to 336 in 6f681a8
I initially thought that perhaps the In which case the only plausible explanation I have is that there's at least 1 specific point in the compilation process where the target machine isn't created with the native target-cpu, like it ought to. Given that the error occurs while linking I'm inclined to blame the linker invocation…? If you're using |
While the detected CPU is encoded as a function attribute, the target machine configuration additionally includes the features returned by |
This should be fixed by #94579. @smsxgli it would be great if you could confirm if this fixes the issue for you as well. The toolchain containing the fix can be installed with rustup-toolchain-install-master tool: $ rustup-toolchain-install-master cdc3d6a5be595fadb021df096cfc2149de5b686e
$ cargo +cdc3d6a5be595fadb021df096cfc2149de5b686e build ...
$ rustc +cdc3d6a5be595fadb021df096cfc2149de5b686e ... |
Thanks! I will try it later. |
I am closing this issue on the assumption that it is resolved. |
Related issue in LLVM
Compiling firefox with rustc and clang, failed during PGO while linking
libxul.so
with thin LTOI expected to see this happen: compile succeed
Instead, this happened: compile failed
Meta
build with stable rust, rustc version
1.58.1
And same error in freebsd can be found here
OS:
arch linux
.llvm, clang and lld version:
13.0.1
CPU:
Intel(R) Core(TM) i7-4790 CPU, haswell
CFLAGS:
-march=native -mtune=native -O2 -pipe -fno-plt -fexceptions -fasynchronous-unwind-tables -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-protector-strong -fstack-clash-protection -fcf-protection
CXXFLAGS:
$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS
LDFLAGS:
-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now,-z,noexecstack
RUSTFLAGS:
-C opt-level=2 -C target-cpu=native
Building with same configuration succeed with
Intel(R) Core(TM) i7-11800H CPU tigerlake
The LLVM developer's opinion can be found here, please take a look.
The text was updated successfully, but these errors were encountered: