Skip to content

Support for Harvey. Harvey is Plan 9 with GPL. #74038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/librustc_target/spec/harvey_base.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use crate::spec::{LinkArgs, LinkerFlavor, RelroLevel, TargetOptions};

pub fn opts() -> TargetOptions {
let mut args = LinkArgs::new();
args.insert(
LinkerFlavor::Gcc,
vec![
// We want to be able to strip as much executable code as possible
// from the linker command line, and this flag indicates to the
// linker that it can avoid linking in dynamic libraries that don't
// actually satisfy any symbols up to that point (as with many other
// resolutions the linker does). This option only applies to all
// following libraries so we're sure to pass it as one of the first
// arguments.
"-Wl,--as-needed".to_string(),
// Always enable NX protection when it is available
"-Wl,-z,noexecstack".to_string(),
],
);

TargetOptions {
dynamic_linking: false,
executables: true,
target_family: Some("unix".to_string()),
linker_is_gnu: true,
has_rpath: true,
pre_link_args: args,
position_independent_executables: true,
relro_level: RelroLevel::Full,
has_elf_tls: false,
..Default::default()
}
}
3 changes: 3 additions & 0 deletions src/librustc_target/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ mod freebsd_base;
mod freestanding_base;
mod fuchsia_base;
mod haiku_base;
mod harvey_base;
mod hermit_base;
mod hermit_kernel_base;
mod illumos_base;
Expand Down Expand Up @@ -574,6 +575,8 @@ supported_targets! {
("i686-unknown-haiku", i686_unknown_haiku),
("x86_64-unknown-haiku", x86_64_unknown_haiku),

("x86_64-unknown-harvey", x86_64_unknown_harvey),

("x86_64-apple-darwin", x86_64_apple_darwin),
("i686-apple-darwin", i686_apple_darwin),

Expand Down
32 changes: 32 additions & 0 deletions src/librustc_target/spec/x86_64_harvey.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// This defines the x86_64 target for the Harvey Kernel. See the harvey-kernel-base module for
// generic Harvey kernel options. Note that in Harvey, as in Plan 9 and Go, we call x86_64
// amd64.

use crate::spec::{CodeModel, LinkerFlavor, Target, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::harvey_kernel_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = Some(64);
base.features =
"-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float"
.to_string();
base.code_model = Some(CodeModel::Kernel);
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());

Ok(Target {
llvm_target: "x86_64-elf".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
.to_string(),
target_os: "none".to_string(),
target_env: "gnu".to_string(),
target_vendor: "unknown".to_string(),
arch: "x86_64".to_string(),
linker_flavor: LinkerFlavor::Gcc,

options: base,
})
}
24 changes: 24 additions & 0 deletions src/librustc_target/spec/x86_64_unknown_harvey.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use crate::spec::{LinkerFlavor, Target, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::harvey_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = Some(64);
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
base.stack_probes = true;

Ok(Target {
llvm_target: "x86_64-unknown-harvey-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
.to_string(),
arch: "x86_64".to_string(),
target_os: "harvey".to_string(),
target_env: "gnu".to_string(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
})
}