From 6f04ac3b7466535755e3752e7fe79eab35bcf0b8 Mon Sep 17 00:00:00 2001 From: Shoji Tokunaga Date: Mon, 1 Jun 2026 15:30:14 +0900 Subject: [PATCH] apps/tools: Enable Rust sim builds on Intel Macs Select the Mach-O Rust target (x86_64-unknown-nuttx-macho.json) when building Rust apps for the simulator on x86_64 macOS. Signed-off-by: Shoji Tokunaga --- cmake/nuttx_add_rust.cmake | 10 ++++++++-- tools/Rust.mk | 10 +++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cmake/nuttx_add_rust.cmake b/cmake/nuttx_add_rust.cmake index 8978c84f325..54b17255bb0 100644 --- a/cmake/nuttx_add_rust.cmake +++ b/cmake/nuttx_add_rust.cmake @@ -34,7 +34,8 @@ include(nuttx_parse_function_args) # - riscv32: riscv32imc/imac/imafc-unknown-nuttx-elf # - riscv64: riscv64imac/imafdc-unknown-nuttx-elf # - x86: i686-unknown-nuttx -# - x86_64: x86_64-unknown-nuttx +# - x86_64: x86_64-unknown-nuttx-macho for sim on macOS, +# x86_64-unknown-nuttx otherwise # - aarch64: aarch64-unknown-nuttx-macho for sim on macOS, # aarch64-unknown-nuttx otherwise # @@ -50,7 +51,12 @@ include(nuttx_parse_function_args) function(nuttx_rust_target_triple ARCHTYPE ABITYPE CPUTYPE OUTPUT) if(ARCHTYPE STREQUAL "x86_64") - set(TARGET_TRIPLE "${PROJECT_SOURCE_DIR}/tools/x86_64-unknown-nuttx.json") + if(CONFIG_ARCH_SIM AND CONFIG_HOST_MACOS) + set(TARGET_TRIPLE + "${PROJECT_SOURCE_DIR}/tools/x86_64-unknown-nuttx-macho.json") + else() + set(TARGET_TRIPLE "${PROJECT_SOURCE_DIR}/tools/x86_64-unknown-nuttx.json") + endif() elseif(ARCHTYPE STREQUAL "x86") set(TARGET_TRIPLE "${PROJECT_SOURCE_DIR}/tools/i486-unknown-nuttx.json") elseif(ARCHTYPE STREQUAL "aarch64") diff --git a/tools/Rust.mk b/tools/Rust.mk index 80abe29704c..06b65f7c5ba 100644 --- a/tools/Rust.mk +++ b/tools/Rust.mk @@ -27,7 +27,8 @@ # # Supported architectures and their target triples: # - x86: i686-unknown-nuttx -# - x86_64: x86_64-unknown-nuttx +# - x86_64: x86_64-unknown-nuttx-macho for sim on macOS, +# x86_64-unknown-nuttx otherwise # - armv7a: armv7a-nuttx-eabi, armv7a-nuttx-eabihf # - thumbv6m: thumbv6m-nuttx-eabi # - thumbv7a: thumbv7a-nuttx-eabi, thumbv7a-nuttx-eabihf @@ -49,13 +50,16 @@ define RUST_TARGET_TRIPLE $(or \ $(and $(filter x86_64,$(LLVM_ARCHTYPE)), \ - $(TOPDIR)/tools/x86_64-unknown-nuttx.json \ + $(if $(and $(filter y,$(CONFIG_ARCH_SIM)),$(filter y,$(CONFIG_HOST_MACOS))), \ + $(TOPDIR)/tools/x86_64-unknown-nuttx-macho.json, \ + $(TOPDIR)/tools/x86_64-unknown-nuttx.json \ + ) \ ), \ $(and $(filter x86,$(LLVM_ARCHTYPE)), \ $(TOPDIR)/tools/i486-unknown-nuttx.json \ ), \ $(and $(filter aarch64,$(LLVM_ARCHTYPE)), \ - $(if $(and $(filter sim,$(CONFIG_ARCH)),$(filter y,$(CONFIG_HOST_MACOS))), \ + $(if $(and $(filter y,$(CONFIG_ARCH_SIM)),$(filter y,$(CONFIG_HOST_MACOS))), \ $(TOPDIR)/tools/aarch64-unknown-nuttx-macho.json, \ $(TOPDIR)/tools/aarch64-unknown-nuttx.json \ ) \