-
Notifications
You must be signed in to change notification settings - Fork 13.7k
rustc_codegen_ssa: More comprehensive RISC-V ELF flags #145840
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
rustc_codegen_ssa: More comprehensive RISC-V ELF flags #145840
Conversation
Some changes occurred in compiler/rustc_codegen_ssa |
Is |
And are these elf flags documented anywhere? (I would like to learn more about the context here) |
Yes. I tested so that targets only with And from ("c", Stable, &["zca"]), Let me give some time to answer your second question. |
I think following quotes from two documents should be sufficient (as a supplement, I show that RISC-V ELF Specification
RISC-V ISA Manual (version 20240411)
and (bold range is marked by me):
GNU BinutilsI show
|
This commit implements more conformant, more comprehensive RISC-V ELF flags handling when generating certain object files directly from rustc. * Use "zca" instead of "c" The "Zca" extension (a subset of "C") is the minimal configuration for compressed instructions to set `EF_RISCV_RVC` flag. * Set TSO flag from "ztso" The "Ztso" extension denotes that the program depends on the RVTSO (Total Store Ordering) memory consistency model, which is stronger than the standard RVWMO (Weak Memory Ordering) consistency model and on ELF targets, we need to set `EF_RISCV_TSO` flag.
5bcf295
to
cb8c905
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Made a rebase along with a few commit message fixes (no code changes). |
For instance, this change affects ELF flags of // src/lib.rs
// (no_core empty library to generate lib.rmeta in minimum effort (without adding targets to compile))
#![feature(no_core)]
#![no_core] # Cargo.toml
[package]
name = "test"
version = "0.0.0"
edition = "2024"
[lib]
crate-type = ["rlib"] cargo clean
# Test TSO flag
RUSTFLAGS='-Ctarget-feature=+ztso' cargo build --target riscv32imafc-unknown-none-elf
# # Test RVC flag
# RUSTFLAGS='-Ctarget-feature=+zca' cargo build --target riscv32ima-unknown-none-elf
# Extract `lib*.rlib` on the target directory (removing temporary `*.o`).
rm *.o; ar x target/riscv32*-unknown-none-elf/debug/libtest.rlib Before this PR
After this PR
|
r? @WaffleLapkin maybe :3 |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@a4lg thanks for extensive references (and the PR)!
@bors r+ rollup |
Rollup of 9 pull requests Successful merges: - #144499 (ci: Begin running ui tests with `rust.debuginfo-level-tests=1`) - #145790 (Improve dist for gnullvm hosts) - #145792 (Use attribute name in message for "outer attr used as inner attr" errors) - #145840 (rustc_codegen_ssa: More comprehensive RISC-V ELF flags) - #145876 (Enable building/disting standard library in stage 0) - #145887 (bootstrap: Don't panic if codegen-backends is set to empty) - #145888 (platform-support: Fix LoongArch32 host column) - #145892 (add a flag to codegen fn attrs for foreign items) - #145901 (Fix typo in comment of library/alloc/src/raw_vec/mod.rs) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #145840 - a4lg:riscv-elf-flags-for-internal-objs, r=WaffleLapkin rustc_codegen_ssa: More comprehensive RISC-V ELF flags This change implements more conformant, more comprehensive RISC-V ELF flags handling when generating certain object files directly from rustc. * Use `"zca"` instead of `"c"` The "Zca" extension (a subset of "C") is the minimal configuration for compressed instructions to set `EF_RISCV_RVC` flag. * Set TSO flag from `"ztso"` The "Ztso" extension denotes that the program depends on the RVTSO (Total Store Ordering) memory consistency model, which is stronger than the standard RVWMO (Weak Memory Ordering) consistency model and on ELF targets, we need to set `EF_RISCV_TSO` flag.
Rollup of 9 pull requests Successful merges: - rust-lang/rust#144499 (ci: Begin running ui tests with `rust.debuginfo-level-tests=1`) - rust-lang/rust#145790 (Improve dist for gnullvm hosts) - rust-lang/rust#145792 (Use attribute name in message for "outer attr used as inner attr" errors) - rust-lang/rust#145840 (rustc_codegen_ssa: More comprehensive RISC-V ELF flags) - rust-lang/rust#145876 (Enable building/disting standard library in stage 0) - rust-lang/rust#145887 (bootstrap: Don't panic if codegen-backends is set to empty) - rust-lang/rust#145888 (platform-support: Fix LoongArch32 host column) - rust-lang/rust#145892 (add a flag to codegen fn attrs for foreign items) - rust-lang/rust#145901 (Fix typo in comment of library/alloc/src/raw_vec/mod.rs) r? `@ghost` `@rustbot` modify labels: rollup
This change implements more conformant, more comprehensive RISC-V ELF flags handling when generating certain object files directly from rustc.
"zca"
instead of"c"
The "Zca" extension (a subset of "C") is the minimal configuration for compressed instructions to set
EF_RISCV_RVC
flag."ztso"
The "Ztso" extension denotes that the program depends on the RVTSO (Total Store Ordering) memory consistency model, which is stronger than the standard RVWMO (Weak Memory Ordering) consistency model and on ELF targets, we need to set
EF_RISCV_TSO
flag.@rustbot label +O-riscv