Skip to content

Commit 2856076

Browse files
no1wudixiaoxiang781216
authored andcommitted
tools/Rust: Add support for x86 platform
Summary: - Added support for x86 and x86_64 architectures in the Rust build system - Updated `nuttx_rust_target_triple` function in `cmake/nuttx_add_rust.cmake` to handle x86 and x86_64 target triples - Updated `RUST_TARGET_TRIPLE` macro in `tools/Rust.mk` to include x86 and x86_64 target triples Impact: - Enables Rust crate compilation for x86 and x86_64 platforms - No functional changes for existing architectures (ARM, RISC-V, etc.) - Improves platform compatibility and expands Rust support in NuttX Signed-off-by: Huang Qi <[email protected]>
1 parent cf46792 commit 2856076

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cmake/nuttx_add_rust.cmake

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ include(nuttx_parse_function_args)
3333
# - thumbv8m.base: thumbv8m.base-nuttx-eabi, thumbv8m.base-nuttx-eabihf
3434
# - riscv32: riscv32imc/imac/imafc-unknown-nuttx-elf
3535
# - riscv64: riscv64imac/imafdc-unknown-nuttx-elf
36+
# - x86: i686-unknown-nuttx
37+
# - x86_64: x86_64-unknown-nuttx
3638
#
3739
# Inputs:
3840
# ARCHTYPE - Architecture type (e.g. thumbv7m, riscv32)
@@ -45,7 +47,11 @@ include(nuttx_parse_function_args)
4547
# ~~~
4648

4749
function(nuttx_rust_target_triple ARCHTYPE ABITYPE CPUTYPE OUTPUT)
48-
if(ARCHTYPE MATCHES "thumb")
50+
if(ARCHTYPE STREQUAL "x86_64")
51+
set(TARGET_TRIPLE "x86_64-unknown-nuttx")
52+
elseif(ARCHTYPE STREQUAL "x86")
53+
set(TARGET_TRIPLE "i686-unknown-nuttx")
54+
elseif(ARCHTYPE MATCHES "thumb")
4955
if(ARCHTYPE MATCHES "thumbv8m")
5056
# Extract just the base architecture type (thumbv8m.main or thumbv8m.base)
5157
if(ARCHTYPE MATCHES "thumbv8m.main")

tools/Rust.mk

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
# - LLVM_CPUTYPE: CPU type (e.g. cortex-m23, sifive-e20)
2727
#
2828
# Supported architectures and their target triples:
29+
# - x86: i686-unknown-nuttx
30+
# - x86_64: x86_64-unknown-nuttx
2931
# - armv7a: armv7a-nuttx-eabi, armv7a-nuttx-eabihf
3032
# - thumbv6m: thumbv6m-nuttx-eabi
3133
# - thumbv7a: thumbv7a-nuttx-eabi, thumbv7a-nuttx-eabihf
@@ -44,6 +46,12 @@
4446

4547
define RUST_TARGET_TRIPLE
4648
$(or \
49+
$(and $(filter x86_64,$(LLVM_ARCHTYPE)), \
50+
x86_64-unknown-nuttx \
51+
), \
52+
$(and $(filter x86,$(LLVM_ARCHTYPE)), \
53+
i686-unknown-nuttx \
54+
), \
4755
$(and $(filter thumb%,$(LLVM_ARCHTYPE)), \
4856
$(if $(filter thumbv8m%,$(LLVM_ARCHTYPE)), \
4957
$(if $(filter cortex-m23,$(LLVM_CPUTYPE)),thumbv8m.base,thumbv8m.main)-nuttx-$(LLVM_ABITYPE), \

0 commit comments

Comments
 (0)