Skip to content

Commit 9763acd

Browse files
committed
Add riscv*gc-sel4*.json target specs
Signed-off-by: Nick Spinale <nick@nickspinale.com>
1 parent 1405e2a commit 9763acd

File tree

3 files changed

+84
-7
lines changed

3 files changed

+84
-7
lines changed

crates/sel4-generate-target-specs/src/main.rs

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,28 @@ struct Config {
2828
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
2929
enum Arch {
3030
AArch64,
31-
Riscv64,
32-
Riscv32,
31+
Riscv64(RiscVArch),
32+
Riscv32(RiscVArch),
3333
X86_64,
3434
}
3535

36+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
37+
enum RiscVArch {
38+
IMAC,
39+
IMAFC,
40+
GC,
41+
}
42+
43+
impl RiscVArch {
44+
fn arch_suffix_for_target_name(&self) -> String {
45+
match self {
46+
Self::IMAFC => "imafc".to_owned(),
47+
Self::IMAC => "imac".to_owned(),
48+
Self::GC => "gc".to_owned(),
49+
}
50+
}
51+
}
52+
3653
impl Config {
3754
fn target_spec(&self) -> Target {
3855
let mut target = match &self.arch {
@@ -56,8 +73,14 @@ impl Config {
5673
)]);
5774
target
5875
}
59-
Arch::Riscv64 => builtin("riscv64imac-unknown-none-elf"),
60-
Arch::Riscv32 => builtin("riscv32imac-unknown-none-elf"),
76+
Arch::Riscv64(riscv_arch) => builtin(&format!(
77+
"riscv64{}-unknown-none-elf",
78+
riscv_arch.arch_suffix_for_target_name()
79+
)),
80+
Arch::Riscv32(riscv_arch) => builtin(&format!(
81+
"riscv32{}-unknown-none-elf",
82+
riscv_arch.arch_suffix_for_target_name()
83+
)),
6184
Arch::X86_64 => {
6285
let mut target = builtin("x86_64-unknown-none");
6386
let options = &mut target.options;
@@ -132,8 +155,12 @@ impl Arch {
132155
fn name(&self) -> String {
133156
match self {
134157
Self::AArch64 => "aarch64".to_owned(),
135-
Self::Riscv64 => "riscv64imac".to_owned(),
136-
Self::Riscv32 => "riscv32imac".to_owned(),
158+
Self::Riscv64(riscv_arch) => {
159+
format!("riscv64{}", riscv_arch.arch_suffix_for_target_name())
160+
}
161+
Self::Riscv32(riscv_arch) => {
162+
format!("riscv32{}", riscv_arch.arch_suffix_for_target_name())
163+
}
137164
Self::X86_64 => "x86_64".to_owned(),
138165
}
139166
}
@@ -146,7 +173,14 @@ impl Arch {
146173
}
147174

148175
fn all() -> Vec<Self> {
149-
vec![Self::AArch64, Self::Riscv64, Self::Riscv32, Self::X86_64]
176+
let mut v = vec![];
177+
v.push(Self::AArch64);
178+
v.push(Self::Riscv64(RiscVArch::IMAC));
179+
v.push(Self::Riscv64(RiscVArch::GC));
180+
v.push(Self::Riscv32(RiscVArch::IMAC));
181+
// v.push(Self::Riscv32(RiscVArch::IMAFC)); # TODO add after bumping Rust toolchain
182+
v.push(Self::X86_64);
183+
v
150184
}
151185
}
152186

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"arch": "riscv64",
3+
"code-model": "medium",
4+
"cpu": "generic-rv64",
5+
"data-layout": "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128",
6+
"eh-frame-header": false,
7+
"emit-debug-gdb-scripts": false,
8+
"env": "sel4",
9+
"exe-suffix": ".elf",
10+
"features": "+m,+a,+f,+d,+c",
11+
"linker": "rust-lld",
12+
"linker-flavor": "ld.lld",
13+
"llvm-abiname": "lp64d",
14+
"llvm-target": "riscv64",
15+
"max-atomic-width": 64,
16+
"panic-strategy": "abort",
17+
"relocation-model": "static",
18+
"supported-sanitizers": [
19+
"kernel-address"
20+
],
21+
"target-pointer-width": "64"
22+
}

support/targets/riscv64gc-sel4.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"arch": "riscv64",
3+
"code-model": "medium",
4+
"cpu": "generic-rv64",
5+
"data-layout": "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128",
6+
"emit-debug-gdb-scripts": false,
7+
"env": "sel4",
8+
"exe-suffix": ".elf",
9+
"features": "+m,+a,+f,+d,+c",
10+
"has-thread-local": true,
11+
"linker": "rust-lld",
12+
"linker-flavor": "ld.lld",
13+
"llvm-abiname": "lp64d",
14+
"llvm-target": "riscv64",
15+
"max-atomic-width": 64,
16+
"relocation-model": "static",
17+
"supported-sanitizers": [
18+
"kernel-address"
19+
],
20+
"target-pointer-width": "64"
21+
}

0 commit comments

Comments
 (0)