Skip to content

Commit 8b216da

Browse files
committed
rustc_target: Add OpenEmbedded/Yocto Linux base targets
Add built-in OpenEmbedded/Yocto Linux targets for x86_64, i686, aarch64, armv7, and riscv64. These targets inherit from the corresponding upstream Linux GNU targets and provide OpenEmbedded-specific target triples and default linker settings. They are intended to serve as base targets for downstream Yocto/OpenEmbedded-generated targets, allowing vendor-specific targets to override metadata (for example, TARGET_VENDOR) while reusing a common target configuration. This reduces duplication in Yocto-based Rust integrations and avoids maintaining downstream copies of largely identical target specifications. Signed-off-by: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
1 parent 029c9e1 commit 8b216da

10 files changed

Lines changed: 157 additions & 0 deletions

File tree

compiler/rustc_target/src/spec/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,12 @@ supported_targets! {
18231823
("x86_64-unknown-linux-gnuasan", x86_64_unknown_linux_gnuasan),
18241824
("x86_64-unknown-linux-gnumsan", x86_64_unknown_linux_gnumsan),
18251825
("x86_64-unknown-linux-gnutsan", x86_64_unknown_linux_gnutsan),
1826+
1827+
("aarch64-oe-linux-gnu", aarch64_oe_linux_gnu),
1828+
("armv7-oe-linux-gnueabihf", armv7_oe_linux_gnueabihf),
1829+
("i686-oe-linux-gnu", i686_oe_linux_gnu),
1830+
("riscv64-oe-linux-gnu", riscv64_oe_linux_gnu),
1831+
("x86_64-oe-linux-gnu", x86_64_oe_linux_gnu),
18261832
}
18271833

18281834
/// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::spec::{Target, TargetMetadata};
2+
3+
pub(crate) fn target() -> Target {
4+
let mut base = super::aarch64_unknown_linux_gnu::target();
5+
6+
base.metadata = TargetMetadata {
7+
description: Some("64-bit Linux (kernel 3.2+, glibc 2.17+) for yocto".into()),
8+
tier: Some(3),
9+
host_tools: Some(false),
10+
std: Some(true),
11+
};
12+
13+
base.llvm_target = "aarch64-oe-linux-gnu".into();
14+
base.options.linker = Some("aarch64-oe-linux-gcc".into());
15+
16+
base
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::spec::{Target, TargetMetadata};
2+
3+
pub(crate) fn target() -> Target {
4+
let mut base = super::armv7_unknown_linux_gnueabihf::target();
5+
6+
base.metadata = TargetMetadata {
7+
description: Some("Armv7-A Linux, hardfloat (kernel 3.2, glibc 2.17) for yocto".into()),
8+
tier: Some(3),
9+
host_tools: Some(false),
10+
std: Some(true),
11+
};
12+
13+
base.llvm_target = "armv7-oe-linux-gnueabihf".into();
14+
base.options.linker = Some("arm-oe-linux-gnueabi-gcc".into());
15+
16+
base
17+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use crate::spec::{Target, TargetMetadata};
2+
3+
pub(crate) fn target() -> Target {
4+
let mut base = super::i686_unknown_linux_gnu::target();
5+
6+
base.metadata = TargetMetadata {
7+
description: Some("32-bit Linux (kernel 3.2, glibc 2.17+) for yocto".into()),
8+
tier: Some(3),
9+
host_tools: Some(false),
10+
std: Some(true),
11+
};
12+
13+
base.llvm_target = "i686-oe-linux-gnu".into();
14+
15+
base.options.linker = Some("i686-oe-linux-gcc".into());
16+
17+
base.options.cpu = "core2".into();
18+
base.options.features = "+sse3".into();
19+
20+
base
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::spec::{Target, TargetMetadata};
2+
3+
pub(crate) fn target() -> Target {
4+
let mut base = super::riscv64gc_unknown_linux_gnu::target();
5+
6+
base.metadata = TargetMetadata {
7+
description: Some("RISC-V Linux (kernel 4.20, glibc 2.29) for yocto".into()),
8+
tier: Some(3),
9+
host_tools: Some(false),
10+
std: Some(true),
11+
};
12+
13+
base.llvm_target = "riscv64-oe-linux-gnu".into();
14+
base.options.linker = Some("riscv64-oe-linux-gcc".into());
15+
16+
base
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::spec::{Target, TargetMetadata};
2+
3+
pub(crate) fn target() -> Target {
4+
let mut base = super::x86_64_unknown_linux_gnu::target();
5+
6+
base.metadata = TargetMetadata {
7+
description: Some("64-bit Linux (kernel 3.2+, glibc 2.17+) for yocto".into()),
8+
tier: Some(3),
9+
host_tools: Some(false),
10+
std: Some(true),
11+
};
12+
13+
base.llvm_target = "x86_64-oe-linux-gnu".into();
14+
base.options.linker = Some("x86_64-oe-linux-gcc".into());
15+
16+
base
17+
}

src/doc/rustc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
- [mips\*-mti-none-elf](platform-support/mips-mti-none-elf.md)
104104
- [mipsisa\*r6\*-unknown-linux-gnu\*](platform-support/mips-release-6.md)
105105
- [nvptx64-nvidia-cuda](platform-support/nvptx64-nvidia-cuda.md)
106+
- [\*-oe-linux-gnu](platform-support/oe-linux-gnu.md)
106107
- [powerpc-unknown-openbsd](platform-support/powerpc-unknown-openbsd.md)
107108
- [powerpc-unknown-linux-gnuspe](platform-support/powerpc-unknown-linux-gnuspe.md)
108109
- [powerpc-unknown-linux-muslspe](platform-support/powerpc-unknown-linux-muslspe.md)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ target | std | host | notes
266266
-------|:---:|:----:|-------
267267
[`aarch64-kmc-solid_asp3`](platform-support/kmc-solid.md) | ✓ | | ARM64 SOLID with TOPPERS/ASP3
268268
[`aarch64-nintendo-switch-freestanding`](platform-support/aarch64-nintendo-switch-freestanding.md) | * | | ARM64 Nintendo Switch, Horizon
269+
[`aarch64-oe-linux-gnu`](platform-support/oe-linux-gnu.md) | ✓ | | ARM64 OpenEmbedded/Yocto Linux (GNU)
269270
[`aarch64-unknown-freebsd`](platform-support/freebsd.md) | ✓ | ✓ | ARM64 FreeBSD
270271
[`aarch64-unknown-helenos`](platform-support/helenos.md) | ✓ | | ARM64 HelenOS
271272
[`aarch64-unknown-hermit`](platform-support/hermit.md) | ✓ | | ARM64 Hermit
@@ -309,6 +310,7 @@ target | std | host | notes
309310
[`armv6-unknown-freebsd`](platform-support/freebsd.md) | ✓ | ✓ | Armv6 FreeBSD
310311
[`armv6-unknown-netbsd-eabihf`](platform-support/netbsd.md) | ✓ | ✓ | Armv6 NetBSD w/hard-float
311312
[`armv6k-nintendo-3ds`](platform-support/armv6k-nintendo-3ds.md) | ? | | Armv6k Nintendo 3DS, Horizon (Requires devkitARM toolchain)
313+
[`armv7-oe-linux-gnueabihf`](platform-support/oe-linux-gnu.md) | ✓ | | ARMv7 OpenEmbedded/Yocto Linux (GNU)
312314
[`armv7-rtems-eabihf`](platform-support/armv7-rtems-eabihf.md) | ? | | RTEMS OS for ARM BSPs
313315
[`armv7-sony-vita-newlibeabihf`](platform-support/armv7-sony-vita-newlibeabihf.md) | ✓ | | Armv7-A Cortex-A9 Sony PlayStation Vita (requires VITASDK toolchain)
314316
[`armv7-unknown-freebsd`](platform-support/freebsd.md) | ✓ | ✓ | Armv7-A FreeBSD
@@ -336,6 +338,7 @@ target | std | host | notes
336338
[`i586-unknown-netbsd`](platform-support/netbsd.md) | ✓ | | 32-bit x86 (original Pentium) [^x86_32-floats-x87]
337339
[`i586-unknown-redox`](platform-support/redox.md) | ✓ | | 32-bit x86 Redox OS (PentiumPro) [^x86_32-floats-x87]
338340
[`i686-apple-darwin`](platform-support/apple-darwin.md) | ✓ | ✓ | 32-bit macOS (10.12+, Sierra+, Penryn) [^x86_32-floats-return-ABI]
341+
[`i686-oe-linux-gnu`](platform-support/oe-linux-gnu.md) | ✓ | | 32-bit x86 OpenEmbedded/Yocto Linux (GNU)
339342
[`i686-pc-nto-qnx700`](platform-support/nto-qnx.md) | * | | 32-bit x86 QNX Neutrino 7.0 RTOS (Pentium 4) [^x86_32-floats-return-ABI]
340343
`i686-unknown-haiku` | ✓ | ✓ | 32-bit Haiku (Pentium 4) [^x86_32-floats-return-ABI]
341344
[`i686-unknown-helenos`](platform-support/helenos.md) | ✓ | | HelenOS IA-32 (see docs for pending issues)
@@ -404,6 +407,7 @@ target | std | host | notes
404407
[`riscv32imc-esp-espidf`](platform-support/esp-idf.md) | ✓ | | RISC-V ESP-IDF
405408
[`riscv32imc-unknown-nuttx-elf`](platform-support/nuttx.md) | ✓ | | RISC-V 32bit with NuttX
406409
[`riscv64-linux-android`](platform-support/android.md) | ? | | RISC-V 64-bit Android
410+
[`riscv64-oe-linux-gnu`](platform-support/oe-linux-gnu.md) | ✓ | | RISC-V OpenEmbedded/Yocto Linux (GNU)
407411
[`riscv64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | |
408412
`riscv64gc-unknown-freebsd` | ? | | RISC-V FreeBSD
409413
`riscv64gc-unknown-fuchsia` | ? | | RISC-V Fuchsia
@@ -441,6 +445,7 @@ target | std | host | notes
441445
[`x86_64-apple-tvos`](platform-support/apple-tvos.md) | ✓ | | x86 64-bit tvOS
442446
[`x86_64-apple-watchos-sim`](platform-support/apple-watchos.md) | ✓ | | x86 64-bit Apple WatchOS simulator
443447
[`x86_64-lynx-lynxos178`](platform-support/lynxos178.md) | | | x86_64 LynxOS-178
448+
[`x86_64-oe-linux-gnu`](platform-support/oe-linux-gnu.md) | ✓ | | x86 64-bit OpenEmbedded/Yocto Linux (GNU)
444449
[`x86_64-pc-cygwin`](platform-support/x86_64-pc-cygwin.md) | ✓ | | 64-bit x86 Cygwin |
445450
[`x86_64-pc-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS with default network stack (io-pkt) |
446451
[`x86_64-pc-nto-qnx710_iosock`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS with new network stack (io-sock) |
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# `*-oe-linux-gnu`
2+
3+
**Tier: 3**
4+
5+
Targets for OpenEmbedded/Yocto-based Linux systems.
6+
7+
Target triplets available:
8+
9+
* `x86_64-oe-linux-gnu`
10+
* `aarch64-oe-linux-gnu`
11+
* `i686-oe-linux-gnu`
12+
* `armv7-oe-linux-gnueabihf`
13+
* `riscv64-oe-linux-gnu`
14+
15+
## Target maintainers
16+
17+
[@DeepeshWR](https://github.com/DeepeshWR)
18+
19+
## Requirements
20+
21+
### Operating System
22+
23+
These targets are intended for Linux systems built using the OpenEmbedded and Yocto Project build systems.
24+
25+
### C Toolchain
26+
27+
The targets use the architecture-specific OpenEmbedded GCC driver as the default linker and therefore require the corresponding OpenEmbedded cross-compilation toolchain to be available in the build environment.
28+
29+
## Building
30+
31+
These targets are intended for use with the OpenEmbedded/Yocto build system. They provide base target definitions from which downstream Yocto-generated targets may inherit.
32+
33+
## Building Rust programs
34+
35+
Rust does not currently ship precompiled artifacts for these targets.
36+
37+
Downstream Yocto-generated targets may inherit from these base OpenEmbedded targets and customize metadata or vendor-specific configuration as needed.
38+
39+
## Cross-compilation toolchains and C code
40+
41+
The targets support linking with C code through the corresponding OpenEmbedded cross-compilation toolchains.

tests/assembly-llvm/targets/targets-elf.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
//@ revisions: aarch64_nintendo_switch_freestanding
2929
//@ [aarch64_nintendo_switch_freestanding] compile-flags: --target aarch64-nintendo-switch-freestanding
3030
//@ [aarch64_nintendo_switch_freestanding] needs-llvm-components: aarch64
31+
//@ revisions: aarch64_oe_linux_gnu
32+
//@ [aarch64_oe_linux_gnu] compile-flags: --target aarch64-oe-linux-gnu
33+
//@ [aarch64_oe_linux_gnu] needs-llvm-components: aarch64
3134
//@ revisions: aarch64_unknown_freebsd
3235
//@ [aarch64_unknown_freebsd] compile-flags: --target aarch64-unknown-freebsd
3336
//@ [aarch64_unknown_freebsd] needs-llvm-components: aarch64
@@ -163,6 +166,9 @@
163166
//@ revisions: armv7_linux_androideabi
164167
//@ [armv7_linux_androideabi] compile-flags: --target armv7-linux-androideabi
165168
//@ [armv7_linux_androideabi] needs-llvm-components: arm
169+
//@ revisions: armv7_oe_linux_gnueabihf
170+
//@ [armv7_oe_linux_gnueabihf] compile-flags: --target armv7-oe-linux-gnueabihf
171+
//@ [armv7_oe_linux_gnueabihf] needs-llvm-components: arm
166172
//@ revisions: armv7_rtems_eabihf
167173
//@ [armv7_rtems_eabihf] compile-flags: --target armv7-rtems-eabihf
168174
//@ [armv7_rtems_eabihf] needs-llvm-components: arm
@@ -268,6 +274,9 @@
268274
//@ revisions: i686_linux_android
269275
//@ [i686_linux_android] compile-flags: --target i686-linux-android
270276
//@ [i686_linux_android] needs-llvm-components: x86
277+
//@ revisions: i686_oe_linux_gnu
278+
//@ [i686_oe_linux_gnu] compile-flags: --target i686-oe-linux-gnu
279+
//@ [i686_oe_linux_gnu] needs-llvm-components: x86
271280
//@ revisions: i686_unknown_freebsd
272281
//@ [i686_unknown_freebsd] compile-flags: --target i686-unknown-freebsd
273282
//@ [i686_unknown_freebsd] needs-llvm-components: x86
@@ -496,6 +505,9 @@
496505
//@ revisions: riscv64_linux_android
497506
//@ [riscv64_linux_android] compile-flags: --target riscv64-linux-android
498507
//@ [riscv64_linux_android] needs-llvm-components: riscv
508+
//@ revisions: riscv64_oe_linux_gnu
509+
//@ [riscv64_oe_linux_gnu] compile-flags: --target riscv64-oe-linux-gnu
510+
//@ [riscv64_oe_linux_gnu] needs-llvm-components: riscv
499511
//@ revisions: riscv64_wrs_vxworks
500512
//@ [riscv64_wrs_vxworks] compile-flags: --target riscv64-wrs-vxworks
501513
//@ [riscv64_wrs_vxworks] needs-llvm-components: riscv
@@ -658,6 +670,9 @@
658670
//@ revisions: x86_64_lynx_lynxos178
659671
//@ [x86_64_lynx_lynxos178] compile-flags: --target x86_64-lynx-lynxos178
660672
//@ [x86_64_lynx_lynxos178] needs-llvm-components: x86
673+
//@ revisions: x86_64_oe_linux_gnu
674+
//@ [x86_64_oe_linux_gnu] compile-flags: --target x86_64-oe-linux-gnu
675+
//@ [x86_64_oe_linux_gnu] needs-llvm-components: x86
661676
//@ revisions: x86_64_pc_nto_qnx710
662677
//@ [x86_64_pc_nto_qnx710] compile-flags: --target x86_64-pc-nto-qnx710
663678
//@ [x86_64_pc_nto_qnx710] needs-llvm-components: x86

0 commit comments

Comments
 (0)