Skip to content
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

Add x86_64-unknown-linux-none target #125023

Merged
merged 5 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>]>
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
}
}
1 change: 1 addition & 0 deletions src/doc/rustc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 40 additions & 0 deletions src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# `x86_64-unknown-linux-none`

**Tier: 3**

Freestanding x86-64 linux binary with no depedency on libc.
morr0ne marked this conversation as resolved.
Show resolved Hide resolved

## 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.
morr0ne marked this conversation as resolved.
Show resolved Hide resolved

## 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
3 changes: 3 additions & 0 deletions tests/assembly/targets/targets-elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading