From 3047f5f2f56fa8c0b4d786a1ac6f067d171d0864 Mon Sep 17 00:00:00 2001 From: Evan Perry Grove Date: Wed, 29 Jan 2025 12:58:06 -0600 Subject: [PATCH 1/2] cmake: rust: Set target for 64-bit posix targets Add new conditionals that will set RUST_TARGET to the appropriate triplet when a 64-bit posix target is selected. Signed-off-by: Evan Perry Grove --- cmake/modules/rust.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/modules/rust.cmake b/cmake/modules/rust.cmake index 560763b21cb4d..1f22d62e97744 100644 --- a/cmake/modules/rust.cmake +++ b/cmake/modules/rust.cmake @@ -44,6 +44,10 @@ function(_rust_map_target) else() message(FATAL_ERROR "Rust: Unsupported riscv ISA") endif() + elseif(CONFIG_ARCH_POSIX AND CONFIG_64BIT AND (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "x86_64")) + set(RUST_TARGET "x86_64-unknown-none" PARENT_SCOPE) + elseif(CONFIG_ARCH_POSIX AND CONFIG_64BIT AND (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "aarch64")) + set(RUST_TARGET "aarch64-unknown-none" PARENT_SCOPE) else() message(FATAL_ERROR "Rust: Add support for other target") endif() From 6f1f4406972fcc20c27285197be9aaac1f4c5275 Mon Sep 17 00:00:00 2001 From: Evan Perry Grove Date: Wed, 29 Jan 2025 13:00:29 -0600 Subject: [PATCH 2/2] rust: Support 64-bit posix targets Change the RUST_SUPPORTED flag so it defaults to 'y' when ARCH_POSIX and 64BIT are selected. This allows Rust projects to use the native_sim/native/64 board. Note that 32-bit native_sim isn't being implemented because Cargo doesn't ship with support for i686-unknown-none. Signed-off-by: Evan Perry Grove --- lib/rust/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rust/Kconfig b/lib/rust/Kconfig index 0d99cb4034381..5f38d68fced68 100644 --- a/lib/rust/Kconfig +++ b/lib/rust/Kconfig @@ -8,7 +8,8 @@ menu "Rust Language Support" config RUST_SUPPORTED bool default y if (CPU_CORTEX_M || \ - (RISCV && !RISCV_ISA_RV32E && !RISCV_ISA_RV128I)) + (RISCV && !RISCV_ISA_RV32E && !RISCV_ISA_RV128I) || \ + (ARCH_POSIX && 64BIT)) help Selected for platforms that have support for Rust.