Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 579e8bc

Browse files
committed
Make rlib metadata strip works with MIPSr6 architecture
Because MIPSr6 has many differences with previous MIPSr2 arch, the previous rlib metadata stripping code in `rustc_codegen_ssa` is only for MIPSr2/r3/r5 (which share the same elf e_flags). This commit fixed this problem. It makes `rustc_codegen_ssa` happy when compiling rustc for MIPSr6 target or hosts.
1 parent e012a19 commit 579e8bc

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

compiler/rustc_codegen_ssa/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ rustc_target = { path = "../rustc_target" }
4141
rustc_session = { path = "../rustc_session" }
4242

4343
[dependencies.object]
44-
version = "0.26.2"
44+
version = "0.27.0"
4545
default-features = false
4646
features = ["read_core", "elf", "macho", "pe", "unaligned", "archive", "write"]

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,24 @@ fn create_object_file(sess: &Session) -> Option<write::Object> {
135135
Architecture::Mips => {
136136
// copied from `mipsel-linux-gnu-gcc foo.c -c` and
137137
// inspecting the resulting `e_flags` field.
138-
let e_flags = elf::EF_MIPS_ARCH_32R2 | elf::EF_MIPS_CPIC | elf::EF_MIPS_PIC;
138+
let e_flags = elf::EF_MIPS_CPIC
139+
| elf::EF_MIPS_PIC
140+
| if sess.target.options.cpu.contains("r6") {
141+
elf::EF_MIPS_ARCH_32R6 | elf::EF_MIPS_NAN2008
142+
} else {
143+
elf::EF_MIPS_ARCH_32R2
144+
};
139145
file.flags = FileFlags::Elf { e_flags };
140146
}
141147
Architecture::Mips64 => {
142148
// copied from `mips64el-linux-gnuabi64-gcc foo.c -c`
143-
let e_flags = elf::EF_MIPS_ARCH_64R2 | elf::EF_MIPS_CPIC | elf::EF_MIPS_PIC;
149+
let e_flags = elf::EF_MIPS_CPIC
150+
| elf::EF_MIPS_PIC
151+
| if sess.target.options.cpu.contains("r6") {
152+
elf::EF_MIPS_ARCH_64R6 | elf::EF_MIPS_NAN2008
153+
} else {
154+
elf::EF_MIPS_ARCH_64R2
155+
};
144156
file.flags = FileFlags::Elf { e_flags };
145157
}
146158
Architecture::Riscv64 if sess.target.options.features.contains("+d") => {

0 commit comments

Comments
 (0)