Skip to content

Commit 48abc56

Browse files
authored
Rollup merge of rust-lang#77916 - QuiltOS:kernel-code-targets-os-none, r=joshtriplett
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 hat 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 rust-lang#74247
2 parents 69b53bc + 9d25ccf commit 48abc56

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

compiler/rustc_target/src/spec/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ supported_targets! {
679679
("thumbv7neon-linux-androideabi", thumbv7neon_linux_androideabi),
680680
("aarch64-linux-android", aarch64_linux_android),
681681

682-
("x86_64-linux-kernel", x86_64_linux_kernel),
682+
("x86_64-unknown-none-linuxkernel", x86_64_unknown_none_linuxkernel),
683683

684684
("aarch64-unknown-freebsd", aarch64_unknown_freebsd),
685685
("armv6-unknown-freebsd", armv6_unknown_freebsd),
@@ -777,7 +777,8 @@ supported_targets! {
777777

778778
("aarch64-unknown-hermit", aarch64_unknown_hermit),
779779
("x86_64-unknown-hermit", x86_64_unknown_hermit),
780-
("x86_64-unknown-hermit-kernel", x86_64_unknown_hermit_kernel),
780+
781+
("x86_64-unknown-none-hermitkernel", x86_64_unknown_none_hermitkernel),
781782

782783
("riscv32i-unknown-none-elf", riscv32i_unknown_none_elf),
783784
("riscv32imc-unknown-none-elf", riscv32imc_unknown_none_elf),

compiler/rustc_target/src/spec/x86_64_unknown_hermit_kernel.rs compiler/rustc_target/src/spec/x86_64_unknown_none_hermitkernel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn target() -> Target {
1010
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
1111

1212
Target {
13-
llvm_target: "x86_64-unknown-hermit".to_string(),
13+
llvm_target: "x86_64-unknown-none-elf".to_string(),
1414
pointer_width: 64,
1515
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
1616
.to_string(),

compiler/rustc_target/src/spec/x86_64_linux_kernel.rs compiler/rustc_target/src/spec/x86_64_unknown_none_linuxkernel.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ pub fn target() -> Target {
1414
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
1515

1616
Target {
17-
// FIXME: Some dispute, the linux-on-clang folks think this should use "Linux"
18-
llvm_target: "x86_64-elf".to_string(),
17+
// FIXME: Some dispute, the linux-on-clang folks think this should use
18+
// "Linux". We disagree because running *on* Linux is nothing like
19+
// running *as" linux, and historically the "os" component as has always
20+
// been used to mean the "on" part.
21+
llvm_target: "x86_64-unknown-none-elf".to_string(),
1922
pointer_width: 64,
2023
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
2124
.to_string(),

library/unwind/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cfg_if::cfg_if! {
1515
target_os = "none",
1616
))] {
1717
// These "unix" family members do not have unwinder.
18-
// Note this also matches x86_64-linux-kernel.
18+
// Note this also matches x86_64-unknown-none-linuxkernel.
1919
} else if #[cfg(any(
2020
unix,
2121
windows,

src/doc/rustc/src/platform-support.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ target | std | host | notes
217217
`thumbv4t-none-eabi` | * | | ARMv4T T32
218218
`x86_64-apple-ios-macabi` | ✓ | | Apple Catalyst on x86_64
219219
`x86_64-apple-tvos` | * | | x86 64-bit tvOS
220-
`x86_64-linux-kernel` | * | | Linux kernel modules
220+
`x86_64-unknown-none-linuxkernel` | * | | Linux kernel modules
221221
`x86_64-sun-solaris` | ? | | Deprecated target for 64-bit Solaris 10/11, illumos
222222
`x86_64-pc-windows-msvc` | ✓ | | 64-bit Windows XP support
223223
`x86_64-unknown-dragonfly` | ✓ | ✓ | 64-bit DragonFlyBSD
224224
`x86_64-unknown-haiku` | ✓ | ✓ | 64-bit Haiku
225225
`x86_64-unknown-hermit` | ? | |
226-
`x86_64-unknown-hermit-kernel` | ? | | HermitCore kernel
226+
`x86_64-unknown-none-hermitkernel` | ? | | HermitCore kernel
227227
`x86_64-unknown-l4re-uclibc` | ? | |
228228
`x86_64-unknown-openbsd` | ✓ | ✓ | 64-bit OpenBSD
229229
`x86_64-unknown-uefi` | ? | |

0 commit comments

Comments
 (0)