From 8aad5f45d57ca5e2e51176c9d6aa22583b6cf91d Mon Sep 17 00:00:00 2001 From: Mike Leany <55358344+mikeleany@users.noreply.github.com> Date: Fri, 17 Sep 2021 23:03:59 -0600 Subject: [PATCH] Add new target: `x86_64-unknown-none-elf` --- compiler/rustc_target/src/spec/mod.rs | 2 ++ .../src/spec/x86_64_unknown_none_elf.rs | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_none_elf.rs diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index ff5dfa3f746..4b357b3cca1 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -954,6 +954,8 @@ fn $module() { ("armv6k-nintendo-3ds", armv6k_nintendo_3ds), ("armv7-unknown-linux-uclibceabihf", armv7_unknown_linux_uclibceabihf), + + ("x86_64-unknown-none-elf", x86_64_unknown_none_elf), } /// Warnings encountered when parsing the target `json`. diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_none_elf.rs b/compiler/rustc_target/src/spec/x86_64_unknown_none_elf.rs new file mode 100644 index 00000000000..2086a1a8d5b --- /dev/null +++ b/compiler/rustc_target/src/spec/x86_64_unknown_none_elf.rs @@ -0,0 +1,29 @@ +// Generic AArch64 target for bare-metal code - Floating point disabled +// +// Can be used in conjunction with the `target-feature` and +// `target-cpu` compiler flags to opt-in more hardware-specific +// features. +// +// For example, `-C target-cpu=cortex-a53`. + +use super::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions}; + +pub fn target() -> Target { + let opts = TargetOptions { + abi: "softfloat".to_string(), + linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), + linker: Some("rust-lld".to_owned()), + features: "-mmx,-sse,+soft-float".to_string(), + executables: true, + disable_redzone: true, + panic_strategy: PanicStrategy::Abort, + ..Default::default() + }; + Target { + llvm_target: "x86_64-unknown-none-elf".to_string(), + pointer_width: 64, + 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(), + options: opts, + } +}