Skip to content

Commit 4c95c6e

Browse files
authored
Rollup merge of rust-lang#90001 - Fearyncess:master, r=alexcrichton
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. e_flags REF: https://github.com/llvm/llvm-project/blob/e356027016c6365b3d8924f54c33e2c63d931492/llvm/include/llvm/BinaryFormat/ELF.h#L562
2 parents 1bd4fdc + cf36c21 commit 4c95c6e

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

Cargo.lock

+25-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ dependencies = [
2424
"rustc-std-workspace-core",
2525
]
2626

27+
[[package]]
28+
name = "ahash"
29+
version = "0.7.4"
30+
source = "registry+https://github.com/rust-lang/crates.io-index"
31+
checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98"
32+
dependencies = [
33+
"getrandom 0.2.0",
34+
"once_cell",
35+
"version_check",
36+
]
37+
2738
[[package]]
2839
name = "aho-corasick"
2940
version = "0.7.18"
@@ -1549,6 +1560,7 @@ version = "0.11.0"
15491560
source = "registry+https://github.com/rust-lang/crates.io-index"
15501561
checksum = "362385356d610bd1e5a408ddf8d022041774b683f345a1d2cfcb4f60f8ae2db5"
15511562
dependencies = [
1563+
"ahash",
15521564
"compiler_builtins",
15531565
"rustc-std-workspace-alloc",
15541566
"rustc-std-workspace-core",
@@ -2349,8 +2361,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
23492361
checksum = "39f37e50073ccad23b6d09bcb5b263f4e76d3bb6038e4a3c08e52162ffa8abc2"
23502362
dependencies = [
23512363
"compiler_builtins",
2352-
"crc32fast",
2353-
"indexmap",
23542364
"memchr",
23552365
"rustc-std-workspace-alloc",
23562366
"rustc-std-workspace-core",
@@ -2368,6 +2378,18 @@ dependencies = [
23682378
"memchr",
23692379
]
23702380

2381+
[[package]]
2382+
name = "object"
2383+
version = "0.28.1"
2384+
source = "registry+https://github.com/rust-lang/crates.io-index"
2385+
checksum = "7ce8b38d41f9f3618fc23f908faae61510f8d8ce2d99cbe910641e8f1971f084"
2386+
dependencies = [
2387+
"crc32fast",
2388+
"hashbrown",
2389+
"indexmap",
2390+
"memchr",
2391+
]
2392+
23712393
[[package]]
23722394
name = "odht"
23732395
version = "0.3.1"
@@ -3754,7 +3776,7 @@ dependencies = [
37543776
"itertools 0.9.0",
37553777
"jobserver",
37563778
"libc",
3757-
"object 0.26.2",
3779+
"object 0.28.1",
37583780
"pathdiff",
37593781
"regex",
37603782
"rustc_apfloat",

compiler/rustc_codegen_ssa/Cargo.toml

+1-1
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.28.0"
4545
default-features = false
4646
features = ["read_core", "elf", "macho", "pe", "unaligned", "archive", "write"]

compiler/rustc_codegen_ssa/src/back/metadata.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn search_for_metadata<'a>(
9595
.map_err(|e| format!("failed to read {} section in '{}': {}", section, path.display(), e))
9696
}
9797

98-
fn create_object_file(sess: &Session) -> Option<write::Object> {
98+
fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {
9999
let endianness = match sess.target.options.endian {
100100
Endian::Little => Endianness::Little,
101101
Endian::Big => Endianness::Big,
@@ -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") => {

src/tools/tidy/src/deps.rs

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const RESTRICTED_DEPENDENCY_CRATES: &[&str] = &["rustc_driver", "rustc_codegen_l
7373
const PERMITTED_DEPENDENCIES: &[&str] = &[
7474
"addr2line",
7575
"adler",
76+
"ahash",
7677
"aho-corasick",
7778
"annotate-snippets",
7879
"ansi_term",

0 commit comments

Comments
 (0)