Skip to content

Commit 8dfd5c3

Browse files
committed
[RISCV] Add riscv32imc-unknown-none-elf target.
1 parent cd862a8 commit 8dfd5c3

File tree

6 files changed

+76
-14
lines changed

6 files changed

+76
-14
lines changed

src/ci/docker/dist-various-1/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ ENV TARGETS=$TARGETS,thumbv6m-none-eabi
102102
ENV TARGETS=$TARGETS,thumbv7m-none-eabi
103103
ENV TARGETS=$TARGETS,thumbv7em-none-eabi
104104
ENV TARGETS=$TARGETS,thumbv7em-none-eabihf
105+
ENV TARGETS=$TARGETS,riscv32imc-unknown-none-elf
105106
ENV TARGETS=$TARGETS,riscv32imac-unknown-none-elf
106107
ENV TARGETS=$TARGETS,armebv7r-none-eabi
107108
ENV TARGETS=$TARGETS,armebv7r-none-eabihf

src/librustc_target/spec/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ mod thumb_base;
7474
mod l4re_base;
7575
mod fuchsia_base;
7676
mod redox_base;
77+
mod riscv_base;
7778

7879
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash,
7980
RustcEncodable, RustcDecodable)]
@@ -406,6 +407,7 @@ supported_targets! {
406407
("aarch64-unknown-hermit", aarch64_unknown_hermit),
407408
("x86_64-unknown-hermit", x86_64_unknown_hermit),
408409

410+
("riscv32imc-unknown-none-elf", riscv32imc_unknown_none_elf),
409411
("riscv32imac-unknown-none-elf", riscv32imac_unknown_none_elf),
410412

411413
("aarch64-unknown-none", aarch64_unknown_none),

src/librustc_target/spec/riscv32imac_unknown_none_elf.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use spec::{LinkerFlavor, LldFlavor, PanicStrategy,
1212
Target, TargetOptions, TargetResult};
13-
use spec::abi::{Abi};
1413

1514
pub fn target() -> TargetResult {
1615
Ok(Target {
@@ -35,19 +34,7 @@ pub fn target() -> TargetResult {
3534
panic_strategy: PanicStrategy::Abort,
3635
relocation_model: "static".to_string(),
3736
emit_debug_gdb_scripts: false,
38-
abi_blacklist: vec![
39-
Abi::Cdecl,
40-
Abi::Stdcall,
41-
Abi::Fastcall,
42-
Abi::Vectorcall,
43-
Abi::Thiscall,
44-
Abi::Aapcs,
45-
Abi::Win64,
46-
Abi::SysV64,
47-
Abi::PtxKernel,
48-
Abi::Msp430Interrupt,
49-
Abi::X86Interrupt,
50-
],
37+
abi_blacklist: super::riscv_base::abi_blacklist(),
5138
.. Default::default()
5239
},
5340
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use spec::{LinkerFlavor, LldFlavor, PanicStrategy,
12+
Target, TargetOptions, TargetResult};
13+
14+
pub fn target() -> TargetResult {
15+
Ok(Target {
16+
data_layout: "e-m:e-p:32:32-i64:64-n32-S128".to_string(),
17+
llvm_target: "riscv32".to_string(),
18+
target_endian: "little".to_string(),
19+
target_pointer_width: "32".to_string(),
20+
target_c_int_width: "32".to_string(),
21+
target_os: "none".to_string(),
22+
target_env: String::new(),
23+
target_vendor: "unknown".to_string(),
24+
arch: "riscv32".to_string(),
25+
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
26+
27+
options: TargetOptions {
28+
linker: Some("rust-lld".to_string()),
29+
cpu: "generic-rv32".to_string(),
30+
max_atomic_width: Some(32),
31+
atomic_cas: false,
32+
features: "+m,+c".to_string(),
33+
executables: true,
34+
panic_strategy: PanicStrategy::Abort,
35+
relocation_model: "static".to_string(),
36+
emit_debug_gdb_scripts: false,
37+
abi_blacklist: super::riscv_base::abi_blacklist(),
38+
.. Default::default()
39+
},
40+
})
41+
}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use spec::abi::Abi;
12+
13+
// All the calling conventions trigger an assertion(Unsupported calling
14+
// convention) in llvm on RISCV
15+
pub fn abi_blacklist() -> Vec<Abi> {
16+
vec![
17+
Abi::Cdecl,
18+
Abi::Stdcall,
19+
Abi::Fastcall,
20+
Abi::Vectorcall,
21+
Abi::Thiscall,
22+
Abi::Aapcs,
23+
Abi::Win64,
24+
Abi::SysV64,
25+
Abi::PtxKernel,
26+
Abi::Msp430Interrupt,
27+
Abi::X86Interrupt,
28+
Abi::AmdGpuKernel,
29+
]
30+
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ static TARGETS: &'static [&'static str] = &[
9292
"powerpc64-unknown-linux-gnu",
9393
"powerpc64le-unknown-linux-gnu",
9494
"powerpc64le-unknown-linux-musl",
95+
"riscv32imc-unknown-none-elf",
9596
"riscv32imac-unknown-none-elf",
9697
"s390x-unknown-linux-gnu",
9798
"sparc-unknown-linux-gnu",

0 commit comments

Comments
 (0)