Skip to content

Commit 7ef7005

Browse files
authored
Rollup merge of #66713 - hermitcore:hermit, r=alexcrichton
introduce a target to build the kernel of the unikernel HermitCore We are developing the unikernel HermitCore, where the kernel is written in Rust and is already supported by the Rust Standard Library. To compile the kernel with the new build flag "-Z build-std", we introduce a new target, which avoids the usage of SSE & AVX within the kernel.
2 parents 9e2802b + 55ce5c0 commit 7ef7005

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use crate::spec::{LldFlavor, LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions};
2+
use std::default::Default;
3+
4+
pub fn opts() -> TargetOptions {
5+
let mut pre_link_args = LinkArgs::new();
6+
pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Ld), vec![
7+
"--build-id".to_string(),
8+
"--hash-style=gnu".to_string(),
9+
"--Bstatic".to_string(),
10+
]);
11+
12+
TargetOptions {
13+
disable_redzone: true,
14+
linker: Some("rust-lld".to_owned()),
15+
executables: true,
16+
has_elf_tls: true,
17+
linker_is_gnu: true,
18+
pre_link_args,
19+
no_default_libraries: true,
20+
panic_strategy: PanicStrategy::Abort,
21+
position_independent_executables: true,
22+
relocation_model: "static".to_string(),
23+
target_family: None,
24+
tls_model: "initial-exec".to_string(),
25+
.. Default::default()
26+
}
27+
}

src/librustc_target/spec/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ mod dragonfly_base;
5454
mod freebsd_base;
5555
mod haiku_base;
5656
mod hermit_base;
57+
mod hermit_kernel_base;
5758
mod linux_base;
5859
mod linux_kernel_base;
5960
mod linux_musl_base;
@@ -481,6 +482,7 @@ supported_targets! {
481482

482483
("aarch64-unknown-hermit", aarch64_unknown_hermit),
483484
("x86_64-unknown-hermit", x86_64_unknown_hermit),
485+
("x86_64-unknown-hermit-kernel", x86_64_unknown_hermit_kernel),
484486

485487
("riscv32i-unknown-none-elf", riscv32i_unknown_none_elf),
486488
("riscv32imc-unknown-none-elf", riscv32imc_unknown_none_elf),
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use crate::spec::{LldFlavor, LinkerFlavor, Target, TargetResult};
2+
3+
pub fn target() -> TargetResult {
4+
let mut base = super::hermit_kernel_base::opts();
5+
base.cpu = "x86-64".to_string();
6+
base.max_atomic_width = Some(64);
7+
base.features =
8+
"-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float"
9+
.to_string();
10+
base.stack_probes = true;
11+
12+
Ok(Target {
13+
llvm_target: "x86_64-unknown-hermit".to_string(),
14+
target_endian: "little".to_string(),
15+
target_pointer_width: "64".to_string(),
16+
target_c_int_width: "32".to_string(),
17+
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
18+
arch: "x86_64".to_string(),
19+
target_os: "hermit".to_string(),
20+
target_env: String::new(),
21+
target_vendor: "unknown".to_string(),
22+
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
23+
options: base,
24+
})
25+
}

0 commit comments

Comments
 (0)