Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,10 @@ supported_targets! {
("riscv64-oe-linux-gnu", riscv64_oe_linux_gnu),
("x86_64-oe-linux-gnu", x86_64_oe_linux_gnu),

("aarch64-vega-linux-gnu", aarch64_vega_linux_gnu),
("armv7-vega-linux-gnueabihf", armv7_vega_linux_gnueabihf),
("x86_64-vega-linux-gnu", x86_64_vega_linux_gnu),

("aarch64-unknown-hyperlight", aarch64_unknown_hyperlight),
("x86_64-unknown-hyperlight", x86_64_unknown_hyperlight),
}
Expand Down
16 changes: 16 additions & 0 deletions compiler/rustc_target/src/spec/targets/aarch64_vega_linux_gnu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use crate::spec::{Target, TargetMetadata, TargetOptions};

pub(crate) fn target() -> Target {
let mut base = super::aarch64_unknown_linux_gnu::target();

base.metadata = TargetMetadata {
description: Some("ARM64 Vega OS (glibc 2.35)".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
};

base.options = TargetOptions { vendor: "vega".into(), ..base.options };

base
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use crate::spec::{Target, TargetMetadata, TargetOptions};

// The Vega OS armv7 userspace, including the SDK sysroot, is built for Cortex-A7
// with NEON and VFPv4, so unlike armv7-unknown-linux-gnueabihf this target
// assumes both.

pub(crate) fn target() -> Target {
let mut base = super::armv7_unknown_linux_gnueabihf::target();

base.metadata = TargetMetadata {
description: Some("Armv7-A Vega OS, hardfloat, Cortex-A7 with NEON (glibc 2.35)".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
};

base.options = TargetOptions {
vendor: "vega".into(),
cpu: "cortex-a7".into(),
features: "+v7,+db,+dsp,+aclass,+perfmon,+vfp4,+neon,+thumb2".into(),
..base.options
};

base
}
16 changes: 16 additions & 0 deletions compiler/rustc_target/src/spec/targets/x86_64_vega_linux_gnu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use crate::spec::{Target, TargetMetadata, TargetOptions};

pub(crate) fn target() -> Target {
let mut base = super::x86_64_unknown_linux_gnu::target();

base.metadata = TargetMetadata {
description: Some("64-bit Vega OS (glibc 2.35)".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
};

base.options = TargetOptions { vendor: "vega".into(), ..base.options };

base
}
13 changes: 11 additions & 2 deletions library/unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ unsafe extern "C" {}
target_os = "linux",
any(target_env = "gnu", target_env = "uclibc"),
not(feature = "llvm-libunwind"),
not(feature = "system-llvm-libunwind")
not(feature = "system-llvm-libunwind"),
not(target_vendor = "vega")
))]
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
unsafe extern "C" {}
Expand All @@ -180,11 +181,19 @@ unsafe extern "C" {}
target_os = "linux",
any(target_env = "gnu", target_env = "uclibc"),
not(feature = "llvm-libunwind"),
feature = "system-llvm-libunwind"
feature = "system-llvm-libunwind",
not(target_vendor = "vega")
))]
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
unsafe extern "C" {}

// Vega OS has no shared `libgcc_s` for apps, so it always links LLVM's libunwind
// statically. With `llvm-libunwind`, that is the in-tree copy (see `libunwind.rs`).
// Otherwise, such as with `-Zbuild-std`, it is the `libunwind.a` in the Vega sysroot.
#[cfg(all(target_vendor = "vega", not(feature = "llvm-libunwind")))]
#[link(name = "unwind", kind = "static", modifiers = "-bundle")]
unsafe extern "C" {}

#[cfg(target_os = "redox")]
#[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1963,9 +1963,11 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to
.unwrap_or(
if target.contains("fuchsia")
|| (target.contains("hexagon") && !target.contains("qurt"))
|| target.contains("vega")
{
// Fuchsia and Hexagon Linux use in-tree llvm-libunwind.
// Fuchsia, Hexagon Linux and Vega OS use in-tree llvm-libunwind.
// Hexagon QuRT uses libc_eh from the Hexagon SDK instead.
// Vega OS has no shared libgcc_s for apps.
LlvmLibunwind::InTree
} else {
LlvmLibunwind::No
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/src/core/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pub struct Finder {
const STAGE0_MISSING_TARGETS: &[&str] = &[
// just a dummy comment so the list doesn't get onelined
"aarch64-unknown-qtee",
"aarch64-vega-linux-gnu",
"armv7-vega-linux-gnueabihf",
"x86_64-vega-linux-gnu",
];

/// Minimum version threshold for libstdc++ required when using prebuilt LLVM
Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
- [\*-unknown-openbsd](platform-support/openbsd.md)
- [\*-unknown-redox](platform-support/redox.md)
- [\*-unknown-uefi](platform-support/unknown-uefi.md)
- [\*-vega-linux-gnu\*](platform-support/vega-linux-gnu.md)
- [\*-pc-windows-msvc](platform-support/windows-msvc.md)
- [\*-uwp-windows-msvc](platform-support/uwp-windows-msvc.md)
- [\*-wrs-vxworks](platform-support/vxworks.md)
Expand Down
3 changes: 3 additions & 0 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ target | std | host | notes
[`aarch64-unknown-qtee`](platform-support/aarch64-unknown-qtee.md) | ? | | ARM64 QTEE |
[`aarch64-unknown-trusty`](platform-support/trusty.md) | ✓ | |
[`aarch64-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | |
[`aarch64-vega-linux-gnu`](platform-support/vega-linux-gnu.md) | ✓ | | ARM64 Vega OS (glibc 2.35)
[`aarch64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | ARM64 VxWorks OS
[`aarch64v8r-unknown-none`](platform-support/aarch64v8r-unknown-none.md) | * | | Bare Armv8-R in AArch64 mode, hardfloat
[`aarch64v8r-unknown-none-softfloat`](platform-support/aarch64v8r-unknown-none.md) | * | | Bare Armv8-R in AArch64 mode, softfloat
Expand Down Expand Up @@ -325,6 +326,7 @@ target | std | host | notes
[`armv7-unknown-linux-uclibceabihf`](platform-support/armv7-unknown-linux-uclibceabihf.md) | ✓ | ? | Armv7-A Linux with uClibc, hardfloat
[`armv7-unknown-netbsd-eabihf`](platform-support/netbsd.md) | ✓ | ✓ | Armv7-A NetBSD w/hard-float
[`armv7-unknown-trusty`](platform-support/trusty.md) | ✓ | |
[`armv7-vega-linux-gnueabihf`](platform-support/vega-linux-gnu.md) | ✓ | | Armv7-A Vega OS, hardfloat, Cortex-A7 with NEON (glibc 2.35)
[`armv7-wrs-vxworks-eabihf`](platform-support/vxworks.md) | ✓ | | Armv7-A for VxWorks
[`armv7a-kmc-solid_asp3-eabi`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3
[`armv7a-kmc-solid_asp3-eabihf`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3, hardfloat
Expand Down Expand Up @@ -473,6 +475,7 @@ target | std | host | notes
[`x86_64-unknown-trusty`](platform-support/trusty.md) | ✓ | |
`x86_64-uwp-windows-gnu` | ✓ | |
[`x86_64-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | |
[`x86_64-vega-linux-gnu`](platform-support/vega-linux-gnu.md) | ✓ | | 64-bit Vega OS (glibc 2.35)
[`x86_64-win7-windows-gnu`](platform-support/win7-windows-gnu.md) | ✓ | | 64-bit Windows 7 support
[`x86_64-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | ✓ | 64-bit Windows 7 support
[`x86_64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | |
Expand Down
105 changes: 105 additions & 0 deletions src/doc/rustc/src/platform-support/vega-linux-gnu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# `*-vega-linux-gnu*`

**Tier: 3**

Targets for [Vega OS], Amazon's Linux-based OS for Fire TV and other devices.

[Vega OS]: https://developer.amazon.com/docs/vega/vega

Target triplets available:

- `aarch64-vega-linux-gnu`
- `armv7-vega-linux-gnueabihf`
- `x86_64-vega-linux-gnu`

## Target maintainers

[@aliiupeng](https://github.com/aliiupeng)
[@altrieu-amazon](https://github.com/altrieu-amazon)

## Requirements

These targets only support cross-compilation. They support `std`.

Vega OS is glibc-based Linux. Binaries built for these targets use the same Linux kernel
interface, glibc ABI, ELF format and `extern "C"` calling convention as the corresponding
`*-unknown-linux-gnu*` targets.

- glibc 2.35 or newer.
- There is no shared `libgcc_s`, so `std` for these targets links LLVM `libunwind`
statically: the in-tree copy when built with bootstrap (the default), or the Vega
sysroot's `libunwind.a` with `build-std`.
- Every Rust shared library (`cdylib` or `dylib`) and the executable get their own copy of
the unwinder, so unwinding across a `.so` boundary isn't supported.
- `armv7-vega-linux-gnueabihf` targets Cortex-A7 with NEON and VFPv4, which is what the
Vega OS userspace itself is built for. `armv7-unknown-linux-gnueabihf` assumes neither.

The `cfg` values are the same as for the corresponding `*-unknown-linux-gnu*` targets but
with `target_vendor = "vega"`, so code written that only checks os("linux") and env
("gnu") for glibc Linux works as before.

## Building the targets

Add the targets to the `target` list in `bootstrap.toml`. Point each target's C toolchain
at a clang that targets the Vega sysroot, such as the one in the Vega SDK:

```toml
[build]
target = ["aarch64-vega-linux-gnu", "armv7-vega-linux-gnueabihf", "x86_64-vega-linux-gnu"]

[target.aarch64-vega-linux-gnu]
cc = "/path/to/vega-clang-aarch64"
cxx = "/path/to/vega-clang++-aarch64"
ar = "/path/to/llvm-ar"
linker = "/path/to/vega-clang-aarch64"
```

`llvm-libunwind` defaults to `"in-tree"` for these targets.

## Building Rust programs

Rust does not yet ship pre-compiled artifacts for these targets. To compile for these
targets, you will either need to build Rust with the targets enabled (see "Building the
targets" above), or build your own copy of `std` by using `build-std` or similar.

The Vega SDK provides a clang toolchain and sysroot for each architecture, and a Cargo
configuration that sets the linker and sysroot. See [Install the Vega SDK].

[Install the Vega SDK]: https://developer.amazon.com/docs/vega/0.24/install-vega-sdk

To link without the SDK's configuration, use clang with these flags: `--target=<llvm-triple>
--sysroot=<sysroot> -fuse-ld=lld -rtlib=compiler-rt -B<gcc-dir> -L<gcc-dir>`

`<llvm-triple>` is the matching upstream triple (`aarch64-unknown-linux-gnu`,
`armv7-unknown-linux-gnueabihf` or `x86_64-unknown-linux-gnu`).
`<gcc-dir>` is the sysroot directory that holds GCC's `crtbeginS.o` and `libgcc.a`, which
the sysroot keeps in an OpenEmbedded-style path,
`<sysroot>/usr/lib/<oe-triple>/<gcc-version>/`.

## Testing

`x86_64-vega-linux-gnu` binaries run on a Linux x86_64 host using the host's glibc.
`aarch64-vega-linux-gnu` and `armv7-vega-linux-gnueabihf` binaries run under
`qemu-aarch64` / `qemu-arm` user-mode emulation with `-L` pointing at a Vega sysroot.

Binaries can also run on the Vega Virtual Device (in the Vega SDK) when the binary's
architecture matches the host's, or on Fire TV devices running Vega OS.

The Rust test suite has not been run against these targets.

## Cross-compilation toolchains and C code

The targets support C and C++ code. Compile it with clang using the same `--target` and
`--sysroot` as above. C++ code uses the sysroot's `libc++`.
When Cargo builds C code through the `cc` crate, set these for each target (below is
an example for `aarch64-vega-linux-gnu`):

```sh
CC_aarch64_vega_linux_gnu=/path/to/clang
AR_aarch64_vega_linux_gnu=/path/to/llvm-ar
CFLAGS_aarch64_vega_linux_gnu="--sysroot=<vega-sysroot-aarch64>"
```

`cc` passes `--target=<Rust target name>` to clang, which accepts the `vega` vendor.
For `armv7-vega-linux-gnueabihf`, also add `-mcpu=cortex-a7 -mfpu=neon-vfpv4` to
`CFLAGS_armv7_vega_linux_gnueabihf`.
9 changes: 9 additions & 0 deletions tests/assembly-llvm/targets/targets-elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
//@ revisions: aarch64_unknown_none_softfloat
//@ [aarch64_unknown_none_softfloat] compile-flags: --target aarch64-unknown-none-softfloat
//@ [aarch64_unknown_none_softfloat] needs-llvm-components: aarch64
//@ revisions: aarch64_vega_linux_gnu
//@ [aarch64_vega_linux_gnu] compile-flags: --target aarch64-vega-linux-gnu
//@ [aarch64_vega_linux_gnu] needs-llvm-components: aarch64
//@ revisions: aarch64v8r_unknown_none
//@ [aarch64v8r_unknown_none] compile-flags: --target aarch64v8r-unknown-none
//@ [aarch64v8r_unknown_none] needs-llvm-components: aarch64
Expand Down Expand Up @@ -217,6 +220,9 @@
//@ revisions: armv7_unknown_trusty
//@ [armv7_unknown_trusty] compile-flags: --target armv7-unknown-trusty
//@ [armv7_unknown_trusty] needs-llvm-components: arm
//@ revisions: armv7_vega_linux_gnueabihf
//@ [armv7_vega_linux_gnueabihf] compile-flags: --target armv7-vega-linux-gnueabihf
//@ [armv7_vega_linux_gnueabihf] needs-llvm-components: arm
//@ revisions: armv7_wrs_vxworks_eabihf
//@ [armv7_wrs_vxworks_eabihf] compile-flags: --target armv7-wrs-vxworks-eabihf
//@ [armv7_wrs_vxworks_eabihf] needs-llvm-components: arm
Expand Down Expand Up @@ -784,6 +790,9 @@
//@ revisions: x86_64_unknown_trusty
//@ [x86_64_unknown_trusty] compile-flags: --target x86_64-unknown-trusty
//@ [x86_64_unknown_trusty] needs-llvm-components: x86
//@ revisions: x86_64_vega_linux_gnu
//@ [x86_64_vega_linux_gnu] compile-flags: --target x86_64-vega-linux-gnu
//@ [x86_64_vega_linux_gnu] needs-llvm-components: x86
//@ revisions: x86_64_wrs_vxworks
//@ [x86_64_wrs_vxworks] compile-flags: --target x86_64-wrs-vxworks
//@ [x86_64_wrs_vxworks] needs-llvm-components: x86
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ warning: unexpected `cfg` condition value: `value`
LL | #[cfg(target_vendor = "value")]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs`
= note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vega`, `vex`, `win7`, and `wrs`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `feature`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/exhaustive-names-values.feature.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ warning: unexpected `cfg` condition value: `value`
LL | #[cfg(target_vendor = "value")]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs`
= note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vega`, `vex`, `win7`, and `wrs`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `unk`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/exhaustive-names-values.full.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ warning: unexpected `cfg` condition value: `value`
LL | #[cfg(target_vendor = "value")]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs`
= note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vega`, `vex`, `win7`, and `wrs`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `unk`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/well-known-values.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
LL | target_vendor = "_UNEXPECTED_VALUE",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs`
= note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vega`, `vex`, `win7`, and `wrs`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
Expand Down