-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Compilation error about RISC-V H extension #111637
Comments
One possible solution is to ensure that your RISC-V target is configured properly to support the "H" extension instructions. You can verify this by checking the configuration files or documentation related to the target you are using. Make sure that the target specification you are using supports the "H" extension. if you have confirmed that, It's worth considering whether there might be compatibility issues or bugs with that specific nightly version. You could try updating to a newer version of the Rust compiler or using a stable release to see if the issue persists |
I tried rolling back the Rust version to 1.68.0-nightly and successfully compiled. I noticed in the change log of Rust 1.70.0 beta that LLVM was updated to version 16, so I suspect it's an issue with the LLVM version. |
@rustbot label C-bug T-compiler |
@rustbot label O-riscv |
This issue seems to be resolved in the newest nightly vetsion. |
I found this error was still there, but the project can still be compiled.
How to remove this error? |
@cylindrical2002 could you please provide a minimal example that reproduces this? |
Seems only happen with global_asm! and opt-level>0, I managed to find a minimal example that fails with latest stable rustc version as well
compiling with rustc gives
but if opt-level is set to 0, the error goes away |
Tried to dig into this. The error comes from LTO. LLVM 16 makes 'h' an extension name instead of privilege level that is always enabled, which uncovers the error from previous warning. llvm/llvm-project@f4c887c . If you try other extensions with 1.68 and llvm 15, it will be an error. The root of the error is LTO uses an empty MCSubtargetInfo to extract global symbols because it doesn't know enabled features for global module asm. llvm/llvm-project#67698, https://discourse.llvm.org/t/rfc-target-cpu-and-features-for-module-level-inline-assembly Perhaps, instead of passing target-feature, you can work around this by using special riscv asm directives
|
cc @kito-cheng @michaelmaitland @robin-randhawa-sifive Is this issue still an active concern? |
I am only seeing a warning, not an error: https://godbolt.org/z/77T9598Wq. Is there a reason this is not part of |
The first reason is usually "no one asked", and the second reason is usually questions about if it winds up somehow affecting the consequent ABI in LLVM (which many features do, though I somewhat expect this one doesn't). |
If you check the |
I'm trying to use Rust to compile the riscv H extension instructions, but an error occurred during compilation, The Rust target I am using is riscv64gc-unknown-none-elf. When I use
rustc --print target-features --target riscv64gc-unknown-none-elf
command to check, I found information about the H extension:Subsequently, I added the following instruction to the compile command:
However, the compilation error remains unresolved:
What is causing this issue? And my target is specified in
.cargo/config.toml
and my rustc version isrustc 1.71.0-nightly (2f2c438dc 2023-05-08)
.Meta
The text was updated successfully, but these errors were encountered: