diff --git a/cmake/nuttx_add_rust.cmake b/cmake/nuttx_add_rust.cmake index c8546f0fad4..2c28983f0ff 100644 --- a/cmake/nuttx_add_rust.cmake +++ b/cmake/nuttx_add_rust.cmake @@ -35,7 +35,8 @@ include(nuttx_parse_function_args) # - riscv64: riscv64imac/imafdc-unknown-nuttx-elf # - x86: i686-unknown-nuttx # - x86_64: x86_64-unknown-nuttx -# - aarch64: aarch64-apple-darwin +# - aarch64: aarch64-unknown-nuttx-macho for sim on macOS, +# aarch64-unknown-nuttx otherwise # # Inputs: # ARCHTYPE - Architecture type (e.g. thumbv7m, riscv32) @@ -55,8 +56,11 @@ function(nuttx_rust_target_triple ARCHTYPE ABITYPE CPUTYPE OUTPUT) elseif(ARCHTYPE STREQUAL "x86") set(TARGET_TRIPLE "${APPDIR}/tools/i486-unknown-nuttx.json") elseif(ARCHTYPE STREQUAL "aarch64") - if(APPLE) - set(TARGET_TRIPLE "aarch64-apple-darwin") + if(CONFIG_ARCH_SIM AND CONFIG_HOST_MACOS) + set(TARGET_TRIPLE + "${PROJECT_SOURCE_DIR}/tools/aarch64-unknown-nuttx-macho.json") + else() + set(TARGET_TRIPLE "${APPDIR}/tools/aarch64-unknown-nuttx.json") endif() elseif(ARCHTYPE MATCHES "thumb") if(ARCHTYPE MATCHES "thumbv8m") diff --git a/tools/Rust.mk b/tools/Rust.mk index 3a5f728064b..4fc74af4e12 100644 --- a/tools/Rust.mk +++ b/tools/Rust.mk @@ -37,6 +37,8 @@ # - thumbv8m.base: thumbv8m.base-nuttx-eabi, thumbv8m.base-nuttx-eabihf # - riscv32: riscv32imc/imac/imafc-unknown-nuttx-elf # - riscv64: riscv64imac/imafdc-unknown-nuttx-elf +# - aarch64: aarch64-unknown-nuttx-macho for sim on macOS, +# aarch64-unknown-nuttx otherwise # # Usage: $(call RUST_TARGET_TRIPLE) # @@ -53,7 +55,10 @@ $(or \ $(APPDIR)/tools/i486-unknown-nuttx.json \ ), \ $(and $(filter aarch64,$(LLVM_ARCHTYPE)), \ - $(if $(filter y,$(CONFIG_HOST_MACOS)),aarch64-apple-darwin) \ + $(if $(and $(filter sim,$(CONFIG_ARCH)),$(filter y,$(CONFIG_HOST_MACOS))), \ + $(TOPDIR)/tools/aarch64-unknown-nuttx-macho.json, \ + $(APPDIR)/tools/aarch64-unknown-nuttx.json \ + ) \ ), \ $(and $(filter thumb%,$(LLVM_ARCHTYPE)), \ $(if $(filter thumbv8m%,$(LLVM_ARCHTYPE)), \ diff --git a/tools/aarch64-unknown-nuttx.json b/tools/aarch64-unknown-nuttx.json new file mode 100644 index 00000000000..04a333616fb --- /dev/null +++ b/tools/aarch64-unknown-nuttx.json @@ -0,0 +1,42 @@ +{ + "arch": "aarch64", + "crt-objects-fallback": "false", + "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32", + "default-uwtable": true, + "disable-redzone": true, + "features": "+v8a,+strict-align,+neon", + "linker": "rust-lld", + "linker-flavor": "gnu-lld", + "llvm-target": "aarch64-unknown-nuttx", + "max-atomic-width": 128, + "metadata": { + "description": "aarch64 target for NuttX RTOS", + "host_tools": false, + "std": true, + "tier": 3 + }, + "os": "nuttx", + "panic-strategy": "abort", + "pre-link-args": { + "gnu": [ + "--fix-cortex-a53-843419" + ], + "gnu-lld": [ + "--fix-cortex-a53-843419" + ] + }, + "relocation-model": "static", + "stack-probes": { + "kind": "inline" + }, + "supported-sanitizers": [ + "kcfi", + "kernel-address", + "kernel-hwaddress" + ], + "supports-xray": true, + "target-family": [ + "unix" + ], + "target-pointer-width": 64 +}