Skip to content

Commit 9a81dc9

Browse files
compiler: Set target_abi = "ilp32e" on all riscv32e targets
This allows compile-time configuration based on this. In the near future we should do this across all RISCV targets, probably, but this cfg is essential for building software usable on these targets.
1 parent c26db43 commit 9a81dc9

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
22

33
pub(crate) fn target() -> Target {
4+
let abi = "ilp32e";
45
Target {
56
// The below `data_layout` is explicitly specified by the ilp32e ABI in LLVM. See also
67
// `options.llvm_abiname`.
@@ -16,11 +17,12 @@ pub(crate) fn target() -> Target {
1617
arch: "riscv32".into(),
1718

1819
options: TargetOptions {
20+
abi: abi.into(),
1921
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
2022
linker: Some("rust-lld".into()),
2123
cpu: "generic-rv32".into(),
2224
// The ilp32e ABI specifies the `data_layout`
23-
llvm_abiname: "ilp32e".into(),
25+
llvm_abiname: abi.into(),
2426
max_atomic_width: Some(32),
2527
atomic_cas: false,
2628
features: "+e,+forced-atomics".into(),

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
22

33
pub(crate) fn target() -> Target {
4+
let abi = "ilp32e";
45
Target {
56
// The below `data_layout` is explicitly specified by the ilp32e ABI in LLVM. See also
67
// `options.llvm_abiname`.
@@ -16,11 +17,12 @@ pub(crate) fn target() -> Target {
1617
arch: "riscv32".into(),
1718

1819
options: TargetOptions {
20+
abi: abi.into(),
1921
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
2022
linker: Some("rust-lld".into()),
2123
cpu: "generic-rv32".into(),
2224
// The ilp32e ABI specifies the `data_layout`
23-
llvm_abiname: "ilp32e".into(),
25+
llvm_abiname: abi.into(),
2426
max_atomic_width: Some(32),
2527
atomic_cas: false,
2628
features: "+e,+m,+forced-atomics".into(),

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
22

33
pub(crate) fn target() -> Target {
4+
let abi = "ilp32e";
45
Target {
56
// The below `data_layout` is explicitly specified by the ilp32e ABI in LLVM. See also
67
// `options.llvm_abiname`.
@@ -16,11 +17,12 @@ pub(crate) fn target() -> Target {
1617
arch: "riscv32".into(),
1718

1819
options: TargetOptions {
20+
abi: abi.into(),
1921
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
2022
linker: Some("rust-lld".into()),
2123
cpu: "generic-rv32".into(),
2224
// The ilp32e ABI specifies the `data_layout`
23-
llvm_abiname: "ilp32e".into(),
25+
llvm_abiname: abi.into(),
2426
max_atomic_width: Some(32),
2527
atomic_cas: false,
2628
features: "+e,+m,+c,+forced-atomics".into(),

tests/ui/check-cfg/well-known-values.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
129129
LL | target_abi = "_UNEXPECTED_VALUE",
130130
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131131
|
132-
= note: expected values for `target_abi` are: ``, `abi64`, `abiv2`, `abiv2hf`, `eabi`, `eabihf`, `fortanix`, `ilp32`, `llvm`, `macabi`, `sim`, `softfloat`, `spe`, `uwp`, `vec-extabi`, and `x32`
132+
= note: expected values for `target_abi` are: ``, `abi64`, `abiv2`, `abiv2hf`, `eabi`, `eabihf`, `fortanix`, `ilp32`, `ilp32e`, `llvm`, `macabi`, `sim`, `softfloat`, `spe`, `uwp`, `vec-extabi`, and `x32`
133133
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
134134

135135
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`

0 commit comments

Comments
 (0)