Rollup merge of #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: e356027016/llvm/include/llvm/BinaryFormat/ELF.h (L562)
This commit is contained in:
commit
c7ada001ec
4 changed files with 42 additions and 7 deletions
|
@ -95,7 +95,7 @@ fn search_for_metadata<'a>(
|
|||
.map_err(|e| format!("failed to read {} section in '{}': {}", section, path.display(), e))
|
||||
}
|
||||
|
||||
fn create_object_file(sess: &Session) -> Option<write::Object> {
|
||||
fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {
|
||||
let endianness = match sess.target.options.endian {
|
||||
Endian::Little => Endianness::Little,
|
||||
Endian::Big => Endianness::Big,
|
||||
|
@ -135,12 +135,24 @@ fn create_object_file(sess: &Session) -> Option<write::Object> {
|
|||
Architecture::Mips => {
|
||||
// copied from `mipsel-linux-gnu-gcc foo.c -c` and
|
||||
// inspecting the resulting `e_flags` field.
|
||||
let e_flags = elf::EF_MIPS_ARCH_32R2 | elf::EF_MIPS_CPIC | elf::EF_MIPS_PIC;
|
||||
let e_flags = elf::EF_MIPS_CPIC
|
||||
| elf::EF_MIPS_PIC
|
||||
| if sess.target.options.cpu.contains("r6") {
|
||||
elf::EF_MIPS_ARCH_32R6 | elf::EF_MIPS_NAN2008
|
||||
} else {
|
||||
elf::EF_MIPS_ARCH_32R2
|
||||
};
|
||||
file.flags = FileFlags::Elf { e_flags };
|
||||
}
|
||||
Architecture::Mips64 => {
|
||||
// copied from `mips64el-linux-gnuabi64-gcc foo.c -c`
|
||||
let e_flags = elf::EF_MIPS_ARCH_64R2 | elf::EF_MIPS_CPIC | elf::EF_MIPS_PIC;
|
||||
let e_flags = elf::EF_MIPS_CPIC
|
||||
| elf::EF_MIPS_PIC
|
||||
| if sess.target.options.cpu.contains("r6") {
|
||||
elf::EF_MIPS_ARCH_64R6 | elf::EF_MIPS_NAN2008
|
||||
} else {
|
||||
elf::EF_MIPS_ARCH_64R2
|
||||
};
|
||||
file.flags = FileFlags::Elf { e_flags };
|
||||
}
|
||||
Architecture::Riscv64 if sess.target.options.features.contains("+d") => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue