Skip to content

Commit 2fca27c

Browse files
committed
Add bare metal riscv32 target.
1 parent c86f3ac commit 2fca27c

File tree

6 files changed

+40
-1
lines changed

6 files changed

+40
-1
lines changed

compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,7 @@ supported_targets! {
16211621
("riscv32i-unknown-none-elf", riscv32i_unknown_none_elf),
16221622
("riscv32im-risc0-zkvm-elf", riscv32im_risc0_zkvm_elf),
16231623
("riscv32im-unknown-none-elf", riscv32im_unknown_none_elf),
1624+
("riscv32ima-unknown-none-elf", riscv32ima_unknown_none_elf),
16241625
("riscv32imc-unknown-none-elf", riscv32imc_unknown_none_elf),
16251626
("riscv32imc-esp-espidf", riscv32imc_esp_espidf),
16261627
("riscv32imac-esp-espidf", riscv32imac_esp_espidf),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
2+
3+
pub fn target() -> Target {
4+
Target {
5+
data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(),
6+
llvm_target: "riscv32".into(),
7+
metadata: crate::spec::TargetMetadata {
8+
description: None,
9+
tier: None,
10+
host_tools: None,
11+
std: None,
12+
},
13+
pointer_width: 32,
14+
arch: "riscv32".into(),
15+
16+
options: TargetOptions {
17+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
18+
linker: Some("rust-lld".into()),
19+
cpu: "generic-rv32".into(),
20+
max_atomic_width: Some(32),
21+
features: "+m,+a".into(),
22+
panic_strategy: PanicStrategy::Abort,
23+
relocation_model: RelocModel::Static,
24+
emit_debug_gdb_scripts: false,
25+
eh_frame_header: false,
26+
..Default::default()
27+
},
28+
}
29+
}

src/doc/rustc/src/platform-support.md

+1
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ target | std | host | notes
339339
`riscv32gc-unknown-linux-gnu` | | | RISC-V Linux (kernel 5.4, glibc 2.33)
340340
`riscv32gc-unknown-linux-musl` | | | RISC-V Linux (kernel 5.4, musl 1.2.3 + RISCV32 support patches)
341341
[`riscv32im-risc0-zkvm-elf`](platform-support/riscv32im-risc0-zkvm-elf.md) | ? | | RISC Zero's zero-knowledge Virtual Machine (RV32IM ISA)
342+
[`riscv32ima-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | | Bare RISC-V (RV32IMA ISA)
342343
[`riscv32imac-unknown-xous-elf`](platform-support/riscv32imac-unknown-xous-elf.md) | ? | | RISC-V Xous (RV32IMAC ISA)
343344
[`riscv32imc-esp-espidf`](platform-support/esp-idf.md) | ✓ | | RISC-V ESP-IDF
344345
[`riscv32imac-esp-espidf`](platform-support/esp-idf.md) | ✓ | | RISC-V ESP-IDF

src/doc/rustc/src/platform-support/riscv32-unknown-none-elf.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
# `riscv32{i,im,imc,imac,imafc}-unknown-none-elf`
1+
# `riscv32{i,im,ima,imc,imac,imafc}-unknown-none-elf`
22

33
**Tier: 2**
44

55
Bare-metal target for RISC-V CPUs with the RV32I, RV32IM, RV32IMC, RV32IMAFC and RV32IMAC ISAs.
66

7+
**Tier: 3**
8+
9+
Bare-metal target for RISC-V CPUs with the RV32IMA ISA.
10+
711
## Target maintainers
812

913
* Rust Embedded Working Group, [RISC-V team](https://github.com/rust-embedded/wg#the-risc-v-team)

src/tools/build-manifest/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ static TARGETS: &[&str] = &[
126126
"riscv32i-unknown-none-elf",
127127
"riscv32im-risc0-zkvm-elf",
128128
"riscv32im-unknown-none-elf",
129+
"riscv32ima-unknown-none-elf",
129130
"riscv32imc-unknown-none-elf",
130131
"riscv32imac-unknown-none-elf",
131132
"riscv32imafc-unknown-none-elf",

tests/assembly/targets/targets-elf.rs

+3
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@
369369
//@ revisions: riscv32im_unknown_none_elf
370370
//@ [riscv32im_unknown_none_elf] compile-flags: --target riscv32im-unknown-none-elf
371371
//@ [riscv32im_unknown_none_elf] needs-llvm-components: riscv
372+
//@ revisions: riscv32ima_unknown_none_elf
373+
//@ [riscv32ima_unknown_none_elf] compile-flags: --target riscv32ima-unknown-none-elf
374+
//@ [riscv32ima_unknown_none_elf] needs-llvm-components: riscv
372375
//@ revisions: riscv32imac_esp_espidf
373376
//@ [riscv32imac_esp_espidf] compile-flags: --target riscv32imac-esp-espidf
374377
//@ [riscv32imac_esp_espidf] needs-llvm-components: riscv

0 commit comments

Comments
 (0)