From 485e90f1a73bd2024a4a280708ec5b3b8ca8dbe7 Mon Sep 17 00:00:00 2001 From: B I Mohammed Abbas Date: Fri, 20 Sep 2024 16:15:49 +0530 Subject: [PATCH 1/4] Add Vxworks RISC-V targets --- compiler/rustc_target/src/spec/mod.rs | 2 ++ .../src/spec/targets/riscv32_wrs_vxworks.rs | 24 +++++++++++++++++++ .../src/spec/targets/riscv64_wrs_vxworks.rs | 24 +++++++++++++++++++ src/doc/rustc/src/platform-support.md | 2 ++ src/doc/rustc/src/platform-support/vxworks.md | 2 ++ tests/assembly/targets/targets-elf.rs | 6 +++++ 6 files changed, 60 insertions(+) create mode 100644 compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index f12e3e595ad..5a7d86991a2 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1842,6 +1842,8 @@ supported_targets! { ("powerpc-wrs-vxworks", powerpc_wrs_vxworks), ("powerpc-wrs-vxworks-spe", powerpc_wrs_vxworks_spe), ("powerpc64-wrs-vxworks", powerpc64_wrs_vxworks), + ("riscv32-wrs-vxworks", riscv32_wrs_vxworks), + ("riscv64-wrs-vxworks", riscv64_wrs_vxworks), ("aarch64-kmc-solid_asp3", aarch64_kmc_solid_asp3), ("armv7a-kmc-solid_asp3-eabi", armv7a_kmc_solid_asp3_eabi), diff --git a/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs new file mode 100644 index 00000000000..4a6f7950b87 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs @@ -0,0 +1,24 @@ +use crate::spec::{base, StackProbeType, Target, TargetOptions}; + +pub(crate) fn target() -> Target { + Target { + llvm_target: "riscv32".into(), + metadata: crate::spec::TargetMetadata { + description: None, + tier: Some(3), + host_tools: Some(false), + std: None, // STD is a work in progress for this target arch + }, + pointer_width: 32, + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + arch: "riscv32".into(), + options: TargetOptions { + cpu: "generic-rv32".into(), + llvm_abiname: "ilp32d".into(), + max_atomic_width: Some(32), + features: "+m,+a,+f,+d,+c,+zicsr".into(), + stack_probes: StackProbeType::Inline, + ..base::vxworks::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs new file mode 100644 index 00000000000..b0914871a64 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs @@ -0,0 +1,24 @@ +use crate::spec::{base, StackProbeType, Target, TargetOptions}; + +pub(crate) fn target() -> Target { + Target { + llvm_target: "riscv64".into(), + metadata: crate::spec::TargetMetadata { + description: None, + tier: Some(3), + host_tools: Some(false), + std: None, // STD is a work in progress for this target arch + }, + pointer_width: 64, + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + arch: "riscv64".into(), + options: TargetOptions { + cpu: "generic-rv64".into(), + llvm_abiname: "lp64d".into(), + max_atomic_width: Some(64), + features: "+m,+a,+f,+d,+c,+zicsr".into(), + stack_probes: StackProbeType::Inline, + ..base::vxworks::opts() + }, + } +} diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 9a35b35af71..76b7dad8f18 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -358,12 +358,14 @@ target | std | host | notes [`riscv32imc-esp-espidf`](platform-support/esp-idf.md) | ✓ | | RISC-V ESP-IDF [`riscv32imac-esp-espidf`](platform-support/esp-idf.md) | ✓ | | RISC-V ESP-IDF [`riscv32imafc-esp-espidf`](platform-support/esp-idf.md) | ✓ | | RISC-V ESP-IDF +[`riscv32-wrs-vxworks`](platform-support/vxworks.md) | ? | | [`riscv64gc-unknown-hermit`](platform-support/hermit.md) | ✓ | | RISC-V Hermit `riscv64gc-unknown-freebsd` | | | RISC-V FreeBSD `riscv64gc-unknown-fuchsia` | | | RISC-V Fuchsia [`riscv64gc-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | RISC-V NetBSD [`riscv64gc-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/riscv64 [`riscv64-linux-android`](platform-support/android.md) | | | RISC-V 64-bit Android +[`riscv64-wrs-vxworks`](platform-support/vxworks.md) | ? | | `s390x-unknown-linux-musl` | | | S390x Linux (kernel 3.2, musl 1.2.3) `sparc-unknown-linux-gnu` | ✓ | | 32-bit SPARC Linux [`sparc-unknown-none-elf`](./platform-support/sparc-unknown-none-elf.md) | * | | Bare 32-bit SPARC V7+ diff --git a/src/doc/rustc/src/platform-support/vxworks.md b/src/doc/rustc/src/platform-support/vxworks.md index f1860346c8f..6aa3d8b7361 100644 --- a/src/doc/rustc/src/platform-support/vxworks.md +++ b/src/doc/rustc/src/platform-support/vxworks.md @@ -14,6 +14,8 @@ Target triplets available: - `powerpc-wrs-vxworks` - `powerpc64-wrs-vxworks` - `powerpc-wrs-vxworks-spe` +- `riscv32-wrs-vxworks` +- `riscv64-wrs-vxworks` ## Target maintainers diff --git a/tests/assembly/targets/targets-elf.rs b/tests/assembly/targets/targets-elf.rs index 4e1c5e6806e..70747484603 100644 --- a/tests/assembly/targets/targets-elf.rs +++ b/tests/assembly/targets/targets-elf.rs @@ -372,6 +372,9 @@ //@ revisions: powerpc_wrs_vxworks_spe //@ [powerpc_wrs_vxworks_spe] compile-flags: --target powerpc-wrs-vxworks-spe //@ [powerpc_wrs_vxworks_spe] needs-llvm-components: powerpc +//@ revisions: riscv32_wrs_vxworks +//@ [riscv32_wrs_vxworks] compile-flags: --target riscv32-wrs-vxworks +//@ [riscv32_wrs_vxworks] needs-llvm-components: riscv //@ revisions: riscv32gc_unknown_linux_gnu //@ [riscv32gc_unknown_linux_gnu] compile-flags: --target riscv32gc-unknown-linux-gnu //@ [riscv32gc_unknown_linux_gnu] needs-llvm-components: riscv @@ -414,6 +417,9 @@ //@ revisions: riscv64_linux_android //@ [riscv64_linux_android] compile-flags: --target riscv64-linux-android //@ [riscv64_linux_android] needs-llvm-components: riscv +//@ revisions: riscv64_wrs_vxworks +//@ [riscv64_wrs_vxworks] compile-flags: --target riscv64-wrs-vxworks +//@ [riscv64_wrs_vxworks] needs-llvm-components: riscv //@ revisions: riscv64gc_unknown_freebsd //@ [riscv64gc_unknown_freebsd] compile-flags: --target riscv64gc-unknown-freebsd //@ [riscv64gc_unknown_freebsd] needs-llvm-components: riscv From eb6a52c2f6add6b8afa0736f914e6d212d5af95d Mon Sep 17 00:00:00 2001 From: B I Mohammed Abbas Date: Fri, 20 Sep 2024 17:23:49 +0530 Subject: [PATCH 2/4] Update std support for all vxworks target archs --- compiler/rustc_target/src/spec/targets/aarch64_wrs_vxworks.rs | 2 +- compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs | 2 +- .../rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs | 2 +- compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks.rs | 2 +- compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs | 2 +- compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs | 2 +- compiler/rustc_target/src/spec/targets/x86_64_wrs_vxworks.rs | 2 +- src/doc/rustc/src/platform-support.md | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/aarch64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/aarch64_wrs_vxworks.rs index 3c0f92fa31f..f3d7a96e82f 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_wrs_vxworks.rs @@ -7,7 +7,7 @@ pub(crate) fn target() -> Target { description: None, tier: Some(3), host_tools: Some(false), - std: None, // ? + std: Some(true), }, pointer_width: 64, data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), diff --git a/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs index ba669334e7f..c91136c3415 100644 --- a/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { description: None, tier: Some(3), host_tools: Some(false), - std: None, // ? + std: Some(true), }, pointer_width: 32, data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs index 1029a135e4a..6544d32a552 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { description: None, tier: Some(3), host_tools: Some(false), - std: None, // ? + std: Some(true), }, pointer_width: 64, data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), diff --git a/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks.rs index b19513bf1d7..4900d5fef7b 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks.rs @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { description: None, tier: Some(3), host_tools: Some(false), - std: None, // ? + std: Some(true), }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs index 4a6f7950b87..5d4b7a3e946 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs @@ -7,7 +7,7 @@ pub(crate) fn target() -> Target { description: None, tier: Some(3), host_tools: Some(false), - std: None, // STD is a work in progress for this target arch + std: Some(true), }, pointer_width: 32, data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs index b0914871a64..5cddce29aa0 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs @@ -7,7 +7,7 @@ pub(crate) fn target() -> Target { description: None, tier: Some(3), host_tools: Some(false), - std: None, // STD is a work in progress for this target arch + std: Some(true), }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), diff --git a/compiler/rustc_target/src/spec/targets/x86_64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/x86_64_wrs_vxworks.rs index 604f71ffaa6..45571540268 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_wrs_vxworks.rs @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { description: None, tier: Some(3), host_tools: Some(false), - std: None, // ? + std: Some(true), }, pointer_width: 64, data_layout: diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 76b7dad8f18..1bed02ad48b 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -358,14 +358,14 @@ target | std | host | notes [`riscv32imc-esp-espidf`](platform-support/esp-idf.md) | ✓ | | RISC-V ESP-IDF [`riscv32imac-esp-espidf`](platform-support/esp-idf.md) | ✓ | | RISC-V ESP-IDF [`riscv32imafc-esp-espidf`](platform-support/esp-idf.md) | ✓ | | RISC-V ESP-IDF -[`riscv32-wrs-vxworks`](platform-support/vxworks.md) | ? | | +[`riscv32-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | [`riscv64gc-unknown-hermit`](platform-support/hermit.md) | ✓ | | RISC-V Hermit `riscv64gc-unknown-freebsd` | | | RISC-V FreeBSD `riscv64gc-unknown-fuchsia` | | | RISC-V Fuchsia [`riscv64gc-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | RISC-V NetBSD [`riscv64gc-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/riscv64 [`riscv64-linux-android`](platform-support/android.md) | | | RISC-V 64-bit Android -[`riscv64-wrs-vxworks`](platform-support/vxworks.md) | ? | | +[`riscv64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | `s390x-unknown-linux-musl` | | | S390x Linux (kernel 3.2, musl 1.2.3) `sparc-unknown-linux-gnu` | ✓ | | 32-bit SPARC Linux [`sparc-unknown-none-elf`](./platform-support/sparc-unknown-none-elf.md) | * | | Bare 32-bit SPARC V7+ From 4957eda2c17ff43d52ece67b118ec304e5c41f11 Mon Sep 17 00:00:00 2001 From: B I Mohammed Abbas Date: Fri, 20 Sep 2024 17:26:42 +0530 Subject: [PATCH 3/4] Allow unused unsafe for vxworks in alligned_malloc to resolve build errors --- library/std/src/sys/alloc/unix.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/std/src/sys/alloc/unix.rs b/library/std/src/sys/alloc/unix.rs index 46ed7de7162..dfce50aec13 100644 --- a/library/std/src/sys/alloc/unix.rs +++ b/library/std/src/sys/alloc/unix.rs @@ -71,6 +71,7 @@ cfg_if::cfg_if! { } } else { #[inline] + #[cfg_attr(target_os = "vxworks", allow(unused_unsafe))] unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 { let mut out = ptr::null_mut(); // We prefer posix_memalign over aligned_alloc since it is more widely available, and From 6d229f89ba9b828a0482b892eb87989a41c24af5 Mon Sep 17 00:00:00 2001 From: B I Mohammed Abbas Date: Wed, 25 Sep 2024 09:46:15 +0530 Subject: [PATCH 4/4] Vxworks riscv target specs: remove redundant zicsr feature --- compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs | 4 ++-- compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs index 5d4b7a3e946..4d3df78a563 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs @@ -1,4 +1,4 @@ -use crate::spec::{base, StackProbeType, Target, TargetOptions}; +use crate::spec::{StackProbeType, Target, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { cpu: "generic-rv32".into(), llvm_abiname: "ilp32d".into(), max_atomic_width: Some(32), - features: "+m,+a,+f,+d,+c,+zicsr".into(), + features: "+m,+a,+f,+d,+c".into(), stack_probes: StackProbeType::Inline, ..base::vxworks::opts() }, diff --git a/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs index 5cddce29aa0..720549e6a01 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs @@ -1,4 +1,4 @@ -use crate::spec::{base, StackProbeType, Target, TargetOptions}; +use crate::spec::{StackProbeType, Target, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { cpu: "generic-rv64".into(), llvm_abiname: "lp64d".into(), max_atomic_width: Some(64), - features: "+m,+a,+f,+d,+c,+zicsr".into(), + features: "+m,+a,+f,+d,+c".into(), stack_probes: StackProbeType::Inline, ..base::vxworks::opts() },