From a3ef01b1fc14fb4b4af00f8437c4a462db8af9ab Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Sun, 24 Mar 2024 15:33:00 +0100 Subject: [PATCH 1/5] Add x86_64-unknown-linux-none target --- compiler/rustc_target/src/spec/mod.rs | 3 +++ .../spec/targets/x86_64_unknown_linux_none.rs | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_none.rs diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 8307803676e1c..8ba945e193c1b 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1774,6 +1774,9 @@ supported_targets! { ("aarch64-unknown-linux-ohos", aarch64_unknown_linux_ohos), ("armv7-unknown-linux-ohos", armv7_unknown_linux_ohos), ("x86_64-unknown-linux-ohos", x86_64_unknown_linux_ohos), + + ("x86_64-unknown-linux-none", x86_64_unknown_linux_none), + } /// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]> diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_none.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_none.rs new file mode 100644 index 0000000000000..b6e331bd85453 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_none.rs @@ -0,0 +1,25 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::linux::opts(); + base.cpu = "x86-64".into(); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::Inline; + base.linker_flavor = LinkerFlavor::Gnu(Cc::No, Lld::Yes); + base.linker = Some("rust-lld".into()); + + Target { + llvm_target: "x86_64-unknown-linux-none".into(), + metadata: crate::spec::TargetMetadata { + description: None, + tier: None, + host_tools: None, + std: None, + }, + pointer_width: 64, + data_layout: + "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), + arch: "x86_64".into(), + options: base, + } +} From 9cf080099d230fc6602d51df37c8bbd5cf4a8e8e Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Sat, 11 May 2024 20:51:54 +0200 Subject: [PATCH 2/5] docs: Document x86_64-unknown-linux-none target --- src/doc/rustc/src/SUMMARY.md | 1 + src/doc/rustc/src/platform-support.md | 1 + .../x86_64-unknown-linux-none.md | 40 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index c9c0ee4067f1b..c7e3293e35ade 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -74,6 +74,7 @@ - [wasm64-unknown-unknown](platform-support/wasm64-unknown-unknown.md) - [\*-win7-windows-msvc](platform-support/win7-windows-msvc.md) - [x86_64-fortanix-unknown-sgx](platform-support/x86_64-fortanix-unknown-sgx.md) + - [x86_64-unknown-linux-none.md](platform-support/x86_64-unknown-linux-none.md) - [x86_64-unknown-none](platform-support/x86_64-unknown-none.md) - [x86_64h-apple-darwin](platform-support/x86_64h-apple-darwin.md) - [Targets](targets/index.md) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 764798a80e6d2..8adc410455eda 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -382,5 +382,6 @@ target | std | host | notes [`x86_64-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 64-bit Windows 7 support `x86_64-wrs-vxworks` | ? | | [`x86_64h-apple-darwin`](platform-support/x86_64h-apple-darwin.md) | ✓ | ✓ | macOS with late-gen Intel (at least Haswell) +[`x86_64-unknown-linux-none`](platform-support/x86_64-unknown-linux-none.md) | * | | 64-bit Linux with no libc [runs on NVIDIA GPUs]: https://github.com/japaric-archived/nvptx#targets diff --git a/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md b/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md new file mode 100644 index 0000000000000..ef8fd3aa2e384 --- /dev/null +++ b/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md @@ -0,0 +1,40 @@ +# `x86_64-unknown-linux-none` + +**Tier: 3** + +Freestanding x86-64 linux binary with no depedency on libc. + +## Target maintainers + +- [morr0ne](https://github.com/morr0ne/) + +## Requirements + +This target is cross compiled and can be built from any host. + +This target has no support for host tools, std and alloc. + +## Building the target + +The target can be built by enabling it for a `rustc` build: + +```toml +[build] +build-stage = 1 +target = ["x86_64-unknown-linux-none"] +``` + +## Building Rust programs + +Rust does not yet ship pre-compiled artifacts for this target. To compile for +this target, you will either need to build Rust with the target enabled (see +"Building the target" above), or build your own copy of `core` by using +`build-std` or similar. + +## Testing + +Created binaries will run on linux without any external requirements + +## Cross-compilation toolchains and C code + +Support for C code is currently untested From 923cdb35aa7099a20e06662ddc871e384c49cbc9 Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Sun, 12 May 2024 01:25:11 +0200 Subject: [PATCH 3/5] test: Add assembly tests for x86_64-unknown-linux-none target --- tests/assembly/targets/targets-elf.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/assembly/targets/targets-elf.rs b/tests/assembly/targets/targets-elf.rs index 3563aec6d8078..0db2a35800269 100644 --- a/tests/assembly/targets/targets-elf.rs +++ b/tests/assembly/targets/targets-elf.rs @@ -555,6 +555,9 @@ //@ revisions: x86_64_unknown_linux_ohos //@ [x86_64_unknown_linux_ohos] compile-flags: --target x86_64-unknown-linux-ohos //@ [x86_64_unknown_linux_ohos] needs-llvm-components: x86 +//@ revisions: x86_64_unknown_linux_none +//@ [x86_64_unknown_linux_none] compile-flags: --target x86_64-unknown-linux-none +//@ [x86_64_unknown_linux_none] needs-llvm-components: x86 //@ revisions: x86_64_unknown_netbsd //@ [x86_64_unknown_netbsd] compile-flags: --target x86_64-unknown-netbsd //@ [x86_64_unknown_netbsd] needs-llvm-components: x86 From a6f237ca85f7f614ade936dbbc73e0908f6b3df2 Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Sun, 12 May 2024 19:07:11 +0200 Subject: [PATCH 4/5] docs: fix typo in platform-support docs --- src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md b/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md index ef8fd3aa2e384..90bafa7e4fba8 100644 --- a/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md +++ b/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md @@ -2,7 +2,7 @@ **Tier: 3** -Freestanding x86-64 linux binary with no depedency on libc. +Freestanding x86-64 linux binary with no dependency on libc. ## Target maintainers From 68407f90491972e10cf5f3a400c07a0566217c5a Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Tue, 14 May 2024 10:28:00 +0200 Subject: [PATCH 5/5] fix typo in x86_64-unknown-linux-none docs Co-authored-by: Trevor Gross --- src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md b/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md index 90bafa7e4fba8..5608b5cb77811 100644 --- a/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md +++ b/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md @@ -12,7 +12,7 @@ Freestanding x86-64 linux binary with no dependency on libc. This target is cross compiled and can be built from any host. -This target has no support for host tools, std and alloc. +This target has no support for host tools, std, or alloc. ## Building the target