-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
[RISCV] Code model other than medium does not work with lto #139479
Comments
@rustbot label +O-riscv +A-LTO +A-LLVM +S-has-mcve |
@rustbot label +regression-from-stable-to-stable |
This regression is first introduced in 1.52.0. |
cargo-bisect-rustc:
So it is probably this one: #83044 |
- Use large code model to workaround "relocation truncated to fit" - Disable LTO because setting code model to anything other than medium fails to build with LTO. - Bisected and reported as rust-lang/rust#139479
Probably related to https://github.com/rust-lang/rust/blob/master/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_gnu.rs#L18 riscv is among the architectures with |
#83044 was a while ago, unsure if something changed for the riscv64gc-unknown-linux-gnu compile target. cc: riscv maintainers in case they have an opinion (sorry for the mass mention) @kito-cheng |
The code model for that target has always been "medium". Rust 1.52.0 contains an LLVM upgrade. I bet the "regression" here is actually a fix from llvm/llvm-project#32653 |
- Use large code model to workaround "relocation truncated to fit" - Disable LTO because setting code model to anything other than medium fails to build with LTO. - Bisected and reported as rust-lang/rust#139479
#83044 probably only reveals this bug instead of causing it.
There is an unnamed module carrying the medium code model, which is causing this bug. Any idea on how to find out what it is? The large code model from codegen options seems not applied to it. |
Could be the allocator shim: rust/compiler/rustc_codegen_llvm/src/lib.rs Lines 116 to 122 in c6c1796
|
I think I get it. When However, when So I think #83044 is an incomplete fix and thus unfortunately using non-default code model with LTO is not possible in Rust without building std and all dependencies from source again. |
I see that there is a None code model.
If not setting code model does not mean using the default code model and instead bitcode without code model makes sense. I think we should compile target rust sysroot without specifying the code model. Thoughts? |
I tried this code:
I expected to see this happen: code compiles without error
Instead, this happened: failed to load bitcode of module "addr2line-*"
on riscv64, archrv rust:
On x86_64, latest stable from rustup:
On x86_64, Nightly:
Meta
rustc --version --verbose
:This is specific to RISC-V. The same code works fine for x86_64 and aarch64 target. e.g.
The text was updated successfully, but these errors were encountered: