Skip to content

Commit 805f7e1

Browse files
committed
feat(xtask): Add support for aarch64_be
Signed-off-by: Jens Reidel <[email protected]>
1 parent 1819c7b commit 805f7e1

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

xtask/src/arch.rs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub enum Arch {
1111
X86_64,
1212
/// AArch64
1313
Aarch64,
14+
/// AArch64, big-endian
15+
Aarch64Be,
1416
/// 64-bit RISC-V
1517
Riscv64,
1618
}
@@ -21,6 +23,10 @@ impl Arch {
2123
}
2224

2325
pub fn install(&self) -> Result<()> {
26+
if self.tier() > 2 {
27+
return Ok(());
28+
}
29+
2430
let mut rustup = crate::rustup();
2531
rustup.args(["target", "add", self.triple()]);
2632

@@ -42,14 +48,23 @@ impl Arch {
4248
match self {
4349
Self::X86_64 => "x86_64",
4450
Self::Aarch64 => "aarch64",
51+
Self::Aarch64Be => "aarch64_be",
4552
Self::Riscv64 => "riscv64",
4653
}
4754
}
4855

56+
pub fn tier(&self) -> u8 {
57+
match self {
58+
Self::Aarch64Be => 3,
59+
_ => 2,
60+
}
61+
}
62+
4963
pub fn triple(&self) -> &'static str {
5064
match self {
5165
Self::X86_64 => "x86_64-unknown-none",
5266
Self::Aarch64 => "aarch64-unknown-none-softfloat",
67+
Self::Aarch64Be => "aarch64_be-unknown-none-softfloat",
5368
Self::Riscv64 => "riscv64gc-unknown-none-elf",
5469
}
5570
}
@@ -58,6 +73,7 @@ impl Arch {
5873
match self {
5974
Self::X86_64 => "x86_64-unknown-hermit",
6075
Self::Aarch64 => "aarch64-unknown-hermit",
76+
Self::Aarch64Be => "aarch64_be-unknown-hermit",
6177
Self::Riscv64 => "riscv64gc-unknown-hermit",
6278
}
6379
}
@@ -74,6 +90,11 @@ impl Arch {
7490
"-Zbuild-std=core",
7591
"-Zbuild-std-features=compiler-builtins-mem",
7692
],
93+
Self::Aarch64Be => &[
94+
"--target=aarch64_be-unknown-hermit",
95+
"-Zbuild-std=core",
96+
"-Zbuild-std-features=compiler-builtins-mem",
97+
],
7798
Arch::Riscv64 => &[
7899
"--target=riscv64gc-unknown-hermit",
79100
"-Zbuild-std=core",
@@ -92,6 +113,13 @@ impl Arch {
92113
"-Zbuild-std=core,alloc",
93114
"-Zbuild-std-features=compiler-builtins-mem",
94115
],
116+
Self::Aarch64Be => &[
117+
"--target=aarch64_be-unknown-none-softfloat",
118+
// We can't use prebuilt std here because it is built with
119+
// relocation-model=static and we need relocation-model=pic
120+
"-Zbuild-std=core,alloc",
121+
"-Zbuild-std-features=compiler-builtins-mem",
122+
],
95123
Self::Riscv64 => &[
96124
"--target=riscv64gc-unknown-none-elf",
97125
// We can't use prebuilt std here because it is built with
@@ -112,6 +140,10 @@ impl Arch {
112140
"--target=aarch64-unknown-hermit",
113141
"-Zbuild-std=std,panic_abort",
114142
],
143+
Self::Aarch64Be => &[
144+
"--target=aarch64_be-unknown-hermit",
145+
"-Zbuild-std=std,panic_abort",
146+
],
115147
Arch::Riscv64 => &[
116148
"--target=riscv64gc-unknown-hermit",
117149
"-Zbuild-std=std,panic_abort",
@@ -122,10 +154,18 @@ impl Arch {
122154
pub fn rustflags(&self) -> &'static [&'static str] {
123155
match self {
124156
Self::X86_64 => &[],
125-
Self::Aarch64 => &["-Crelocation-model=pic"],
157+
Self::Aarch64 | Self::Aarch64Be => &["-Crelocation-model=pic"],
126158
Self::Riscv64 => &["-Cno-redzone", "-Crelocation-model=pic"],
127159
}
128160
}
161+
162+
pub fn qemu(&self) -> &'static str {
163+
match self {
164+
Self::X86_64 => "x86_64",
165+
Self::Aarch64 | Self::Aarch64Be => "aarch64",
166+
Self::Riscv64 => "riscv64",
167+
}
168+
}
129169
}
130170

131171
impl fmt::Display for Arch {

xtask/src/ci/qemu.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl Qemu {
8888
sh.create_dir("shared/tracedir")?;
8989
}
9090

91-
let qemu = env::var("QEMU").unwrap_or_else(|_| format!("qemu-system-{arch}"));
91+
let qemu = env::var("QEMU").unwrap_or_else(|_| format!("qemu-system-{}", arch.qemu()));
9292
let program = if self.sudo { "sudo" } else { qemu.as_str() };
9393
let arg = self.sudo.then_some(qemu.as_str());
9494
let memory = self.memory(image_name, arch, small);
@@ -208,7 +208,7 @@ impl Qemu {
208208
image_args.push("-initrd".to_string());
209209
image_args.push(image.to_str().unwrap().to_string());
210210
}
211-
Arch::Aarch64 => {
211+
Arch::Aarch64 | Arch::Aarch64Be => {
212212
image_args.push("-device".to_string());
213213
image_args.push(format!(
214214
"guest-loader,addr=0x48000000,initrd={}",
@@ -233,7 +233,7 @@ impl Qemu {
233233
"-nodefaults".to_string(),
234234
"-no-user-config".to_string(),
235235
]
236-
} else if arch == Arch::Aarch64 {
236+
} else if arch == Arch::Aarch64 || arch == Arch::Aarch64Be {
237237
vec!["-machine".to_string(), "virt,gic-version=3".to_string()]
238238
} else if arch == Arch::Riscv64 {
239239
// CadenceGem requires sifive_u
@@ -273,7 +273,7 @@ impl Qemu {
273273
cpu_args.push("isa-debug-exit,iobase=0xf4,iosize=0x04".to_string());
274274
cpu_args
275275
}
276-
Arch::Aarch64 => {
276+
Arch::Aarch64 | Arch::Aarch64Be => {
277277
let mut cpu_args = if self.accel {
278278
todo!()
279279
} else {
@@ -306,7 +306,7 @@ impl Qemu {
306306
32
307307
}
308308
}
309-
Arch::Aarch64 => 144,
309+
Arch::Aarch64 | Arch::Aarch64Be => 144,
310310
Arch::Riscv64 => 40,
311311
};
312312
}

xtask/src/clippy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Clippy {
3838
Arch::X86_64 => {
3939
clippy().arg("--features=shell").run()?;
4040
}
41-
Arch::Aarch64 => {}
41+
Arch::Aarch64 | Arch::Aarch64Be => {}
4242
Arch::Riscv64 => {
4343
clippy()
4444
.arg("--no-default-features")

0 commit comments

Comments
 (0)