From 9d25ccf0e8dd69f4086ad8b59bb8785318926b05 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 11 Oct 2020 18:01:32 -0400 Subject: [PATCH] Change built-in kernel targets to be os = none throughout Whether for Rust's own `target_os`, LLVM's triples, or GNU config's, the OS-related have fields have been for code running *on* that OS, not code that is *part* of the OS. The difference is huge, as syscall interfaces are nothing like freestanding interfaces. Kernels are (hypervisors and other more exotic situations aside) freestanding programs that use the interfaces provided by the hardware. It's *those* interfaces, the ones external to the program being built and its software dependencies, that are the content of the target. For the Linux Kernel in particular, `target_env: "gnu"` is removed for the same reason: that `-gnu` refers to glibc or GNU/linux, neither of which applies to the kernel itself. Relates to #74247 Thanks @ojeda for catching some things. --- compiler/rustc_target/src/spec/mod.rs | 5 +++-- ...ermit_kernel.rs => x86_64_unknown_none_hermitkernel.rs} | 2 +- ..._linux_kernel.rs => x86_64_unknown_none_linuxkernel.rs} | 7 +++++-- library/unwind/src/lib.rs | 2 +- src/doc/rustc/src/platform-support.md | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) rename compiler/rustc_target/src/spec/{x86_64_unknown_hermit_kernel.rs => x86_64_unknown_none_hermitkernel.rs} (91%) rename compiler/rustc_target/src/spec/{x86_64_linux_kernel.rs => x86_64_unknown_none_linuxkernel.rs} (76%) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 039e9a8b2745f..eb1916637529b 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -679,7 +679,7 @@ supported_targets! { ("thumbv7neon-linux-androideabi", thumbv7neon_linux_androideabi), ("aarch64-linux-android", aarch64_linux_android), - ("x86_64-linux-kernel", x86_64_linux_kernel), + ("x86_64-unknown-none-linuxkernel", x86_64_unknown_none_linuxkernel), ("aarch64-unknown-freebsd", aarch64_unknown_freebsd), ("armv6-unknown-freebsd", armv6_unknown_freebsd), @@ -777,7 +777,8 @@ supported_targets! { ("aarch64-unknown-hermit", aarch64_unknown_hermit), ("x86_64-unknown-hermit", x86_64_unknown_hermit), - ("x86_64-unknown-hermit-kernel", x86_64_unknown_hermit_kernel), + + ("x86_64-unknown-none-hermitkernel", x86_64_unknown_none_hermitkernel), ("riscv32i-unknown-none-elf", riscv32i_unknown_none_elf), ("riscv32imc-unknown-none-elf", riscv32imc_unknown_none_elf), diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_hermit_kernel.rs b/compiler/rustc_target/src/spec/x86_64_unknown_none_hermitkernel.rs similarity index 91% rename from compiler/rustc_target/src/spec/x86_64_unknown_hermit_kernel.rs rename to compiler/rustc_target/src/spec/x86_64_unknown_none_hermitkernel.rs index 9fcfe4e6c14bf..a357def190b83 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_hermit_kernel.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_none_hermitkernel.rs @@ -10,7 +10,7 @@ pub fn target() -> Target { base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) }; Target { - llvm_target: "x86_64-unknown-hermit".to_string(), + 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(), diff --git a/compiler/rustc_target/src/spec/x86_64_linux_kernel.rs b/compiler/rustc_target/src/spec/x86_64_unknown_none_linuxkernel.rs similarity index 76% rename from compiler/rustc_target/src/spec/x86_64_linux_kernel.rs rename to compiler/rustc_target/src/spec/x86_64_unknown_none_linuxkernel.rs index 43e683ddbcc84..68d80205e1472 100644 --- a/compiler/rustc_target/src/spec/x86_64_linux_kernel.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_none_linuxkernel.rs @@ -14,8 +14,11 @@ pub fn target() -> Target { base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string()); Target { - // FIXME: Some dispute, the linux-on-clang folks think this should use "Linux" - llvm_target: "x86_64-elf".to_string(), + // FIXME: Some dispute, the linux-on-clang folks think this should use + // "Linux". We disagree because running *on* Linux is nothing like + // running *as" linux, and historically the "os" component as has always + // been used to mean the "on" part. + 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(), diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs index d145c6767ec26..be5e56c71e36f 100644 --- a/library/unwind/src/lib.rs +++ b/library/unwind/src/lib.rs @@ -15,7 +15,7 @@ cfg_if::cfg_if! { target_os = "none", ))] { // These "unix" family members do not have unwinder. - // Note this also matches x86_64-linux-kernel. + // Note this also matches x86_64-unknown-none-linuxkernel. } else if #[cfg(any( unix, windows, diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index d3b88c019f019..611117788da88 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -217,13 +217,13 @@ target | std | host | notes `thumbv4t-none-eabi` | * | | ARMv4T T32 `x86_64-apple-ios-macabi` | ✓ | | Apple Catalyst on x86_64 `x86_64-apple-tvos` | * | | x86 64-bit tvOS -`x86_64-linux-kernel` | * | | Linux kernel modules +`x86_64-unknown-none-linuxkernel` | * | | Linux kernel modules `x86_64-sun-solaris` | ? | | Deprecated target for 64-bit Solaris 10/11, illumos `x86_64-pc-windows-msvc` | ✓ | | 64-bit Windows XP support `x86_64-unknown-dragonfly` | ✓ | ✓ | 64-bit DragonFlyBSD `x86_64-unknown-haiku` | ✓ | ✓ | 64-bit Haiku `x86_64-unknown-hermit` | ? | | -`x86_64-unknown-hermit-kernel` | ? | | HermitCore kernel +`x86_64-unknown-none-hermitkernel` | ? | | HermitCore kernel `x86_64-unknown-l4re-uclibc` | ? | | `x86_64-unknown-openbsd` | ✓ | ✓ | 64-bit OpenBSD `x86_64-unknown-uefi` | ? | |