Skip to content

Commit e2f6f45

Browse files
committed
mips32: require LLVM ABI to be explicitly set, but also allow n32
1 parent c4fb58f commit e2f6f45

13 files changed

Lines changed: 20 additions & 6 deletions

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {
300300
"o32" if is_32bit => e_flags |= elf::EF_MIPS_ABI_O32,
301301
"n32" if !is_32bit => e_flags |= elf::EF_MIPS_ABI2,
302302
"n64" if !is_32bit => {}
303-
"" if is_32bit => e_flags |= elf::EF_MIPS_ABI_O32,
304-
"" => sess.dcx().fatal("LLVM ABI must be specified for 64-bit MIPS targets"),
303+
"" => sess.dcx().fatal("LLVM ABI must be specified for MIPS targets"),
305304
s if is_32bit => {
306305
sess.dcx().fatal(format!("invalid LLVM ABI `{}` for 32-bit MIPS target", s))
307306
}

compiler/rustc_target/src/spec/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,9 +3407,10 @@ impl Target {
34073407
check!(self.rustc_abi.is_none(), "`rustc_abi` is unused on MIPS");
34083408
check_matches!(
34093409
(&*self.llvm_abiname, &self.abi),
3410-
// FIXME: we should force it to always be non-empty.
3410+
// No in-tree targets use "n32" but at least for now we let out-of-tree targets
3411+
// experiment with that.
34113412
("o32", Abi::Unspecified | Abi::Other(_))
3412-
| ("", Abi::Unspecified | Abi::Other(_)),
3413+
| ("n32", Abi::Unspecified | Abi::Other(_)),
34133414
"invalid MIPS ABI name and `cfg(target_abi)` combination:\n\
34143415
ABI name: {}\n\
34153416
cfg(target_abi): {}",

compiler/rustc_target/src/spec/targets/mips_mti_none_elf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub(crate) fn target() -> Target {
2424
endian: Endian::Big,
2525
cpu: "mips32r2".into(),
2626

27+
llvm_abiname: "o32".into(),
2728
max_atomic_width: Some(32),
2829

2930
features: "+mips32r2,+soft-float,+noabicalls".into(),

compiler/rustc_target/src/spec/targets/mips_unknown_linux_gnu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub(crate) fn target() -> Target {
1818
endian: Endian::Big,
1919
cpu: "mips32r2".into(),
2020
features: "+mips32r2,+fpxx,+nooddspreg".into(),
21+
llvm_abiname: "o32".into(),
2122
max_atomic_width: Some(32),
2223
mcount: "_mcount".into(),
2324

compiler/rustc_target/src/spec/targets/mips_unknown_linux_musl.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ pub(crate) fn target() -> Target {
1818
pointer_width: 32,
1919
data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(),
2020
arch: Arch::Mips,
21-
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
21+
options: TargetOptions {
22+
endian: Endian::Big,
23+
llvm_abiname: "o32".into(),
24+
mcount: "_mcount".into(),
25+
..base
26+
},
2227
}
2328
}

compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub(crate) fn target() -> Target {
1818
endian: Endian::Big,
1919
cpu: "mips32r2".into(),
2020
features: "+mips32r2,+soft-float".into(),
21+
llvm_abiname: "o32".into(),
2122
max_atomic_width: Some(32),
2223
mcount: "_mcount".into(),
2324

compiler/rustc_target/src/spec/targets/mipsel_mti_none_elf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub(crate) fn target() -> Target {
2424
endian: Endian::Little,
2525
cpu: "mips32r2".into(),
2626

27+
llvm_abiname: "o32".into(),
2728
max_atomic_width: Some(32),
2829

2930
features: "+mips32r2,+soft-float,+noabicalls".into(),

compiler/rustc_target/src/spec/targets/mipsel_sony_psp.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub(crate) fn target() -> Target {
3636

3737
// PSP does not support trap-on-condition instructions.
3838
llvm_args: cvs!["-mno-check-zero-division"],
39+
llvm_abiname: "o32".into(),
3940
pre_link_args,
4041
link_script: Some(LINKER_SCRIPT.into()),
4142
..Default::default()

compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_gnu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub(crate) fn target() -> Target {
1616
options: TargetOptions {
1717
cpu: "mips32r2".into(),
1818
features: "+mips32r2,+fpxx,+nooddspreg".into(),
19+
llvm_abiname: "o32".into(),
1920
max_atomic_width: Some(32),
2021
mcount: "_mcount".into(),
2122

compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_musl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ pub(crate) fn target() -> Target {
1616
pointer_width: 32,
1717
data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(),
1818
arch: Arch::Mips,
19-
options: TargetOptions { mcount: "_mcount".into(), ..base },
19+
options: TargetOptions { llvm_abiname: "o32".into(), mcount: "_mcount".into(), ..base },
2020
}
2121
}

0 commit comments

Comments
 (0)