mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
tools/build: Make Rust target triples for x86 use JSON files
X86 support for Rust needs more test and verification, and not upstreamed to Rust side yet. It's better to use custom target triples for x86 by json files for now, and it can be upstreamed to Rust side if stable enough. Changed the Rust target triples in the CMake configuration to reference JSON files for x86_64 and i486 architectures. This improves the build process by providing more detailed target specifications. * Added JSON files for i486 and x86_64 targets * Updated CMake functions to use the new target triples * Enhanced build directory structure for Rust crates Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
parent
68f9e5424b
commit
f90e1e184f
4 changed files with 86 additions and 9 deletions
|
|
@ -48,9 +48,9 @@ include(nuttx_parse_function_args)
|
|||
|
||||
function(nuttx_rust_target_triple ARCHTYPE ABITYPE CPUTYPE OUTPUT)
|
||||
if(ARCHTYPE STREQUAL "x86_64")
|
||||
set(TARGET_TRIPLE "x86_64-unknown-nuttx")
|
||||
set(TARGET_TRIPLE "${APPDIR}/tools/x86_64-unknown-nuttx.json")
|
||||
elseif(ARCHTYPE STREQUAL "x86")
|
||||
set(TARGET_TRIPLE "i686-unknown-nuttx")
|
||||
set(TARGET_TRIPLE "${APPDIR}/tools/i486-unknown-nuttx.json")
|
||||
elseif(ARCHTYPE MATCHES "thumb")
|
||||
if(ARCHTYPE MATCHES "thumbv8m")
|
||||
# Extract just the base architecture type (thumbv8m.main or thumbv8m.base)
|
||||
|
|
@ -138,10 +138,16 @@ function(nuttx_add_rust)
|
|||
nuttx_rust_target_triple(${LLVM_ARCHTYPE} ${LLVM_ABITYPE} ${LLVM_CPUTYPE}
|
||||
RUST_TARGET)
|
||||
|
||||
# Set up build directory in current binary dir
|
||||
set(RUST_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CRATE_NAME})
|
||||
set(RUST_LIB_PATH
|
||||
${RUST_BUILD_DIR}/${RUST_TARGET}/${RUST_PROFILE}/lib${CRATE_NAME}.a)
|
||||
# Get binary directory path using target triple base name if it's a JSON file
|
||||
if(RUST_TARGET MATCHES ".json$")
|
||||
get_filename_component(TARGET_BASE ${RUST_TARGET} NAME_WE)
|
||||
else()
|
||||
set(TARGET_BASE ${RUST_TARGET})
|
||||
endif()
|
||||
|
||||
set(RUST_BUILD_DIR
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${CRATE_NAME}/target/${TARGET_BASE})
|
||||
set(RUST_LIB_PATH ${RUST_BUILD_DIR}/${RUST_PROFILE}/lib${CRATE_NAME}.a)
|
||||
|
||||
# Create build directory
|
||||
file(MAKE_DIRECTORY ${RUST_BUILD_DIR})
|
||||
|
|
|
|||
|
|
@ -47,10 +47,10 @@
|
|||
define RUST_TARGET_TRIPLE
|
||||
$(or \
|
||||
$(and $(filter x86_64,$(LLVM_ARCHTYPE)), \
|
||||
x86_64-unknown-nuttx \
|
||||
$(APPDIR)/tools/x86_64-unknown-nuttx.json \
|
||||
), \
|
||||
$(and $(filter x86,$(LLVM_ARCHTYPE)), \
|
||||
i686-unknown-nuttx \
|
||||
$(APPDIR)/tools/i486-unknown-nuttx.json \
|
||||
), \
|
||||
$(and $(filter thumb%,$(LLVM_ARCHTYPE)), \
|
||||
$(if $(filter thumbv8m%,$(LLVM_ARCHTYPE)), \
|
||||
|
|
@ -132,5 +132,7 @@ endef
|
|||
# Path to the Rust binary (e.g. path/to/project/target/riscv32imac-unknown-nuttx-elf/release/libhello.a)
|
||||
|
||||
define RUST_GET_BINDIR
|
||||
$(2)/$(1)/target/$(strip $(call RUST_TARGET_TRIPLE))/$(if $(CONFIG_DEBUG_FULLOPT),release,debug)/lib$(1).a
|
||||
$(2)/$(1)/target/$(strip $(if $(findstring .json,$(call RUST_TARGET_TRIPLE)), \
|
||||
$(basename $(notdir $(call RUST_TARGET_TRIPLE))), \
|
||||
$(call RUST_TARGET_TRIPLE)))/$(if $(CONFIG_DEBUG_FULLOPT),release,debug)/lib$(1).a
|
||||
endef
|
||||
|
|
|
|||
33
tools/i486-unknown-nuttx.json
Normal file
33
tools/i486-unknown-nuttx.json
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"arch": "x86",
|
||||
"cpu": "i486",
|
||||
"crt-objects-fallback": "false",
|
||||
"data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128",
|
||||
"features": "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2,+soft-float",
|
||||
"default-dwarf-version": 2,
|
||||
"dynamic-linking": true,
|
||||
"has-rpath": true,
|
||||
"has-thread-local": true,
|
||||
"linker-flavor": "gnu-lld",
|
||||
"llvm-target": "i486-unknown-nuttx",
|
||||
"max-atomic-width": 64,
|
||||
"metadata": {
|
||||
"description": "32-bit x86, resricted to i486",
|
||||
"host_tools": false,
|
||||
"std": true,
|
||||
"tier": 3
|
||||
},
|
||||
"no-default-libraries": true,
|
||||
"os": "nuttx",
|
||||
"position-independent-executables": false,
|
||||
"relro-level": "full",
|
||||
"rustc-abi": "x86-softfloat",
|
||||
"stack-probes": {
|
||||
"kind": "inline"
|
||||
},
|
||||
"target-family": [
|
||||
"unix"
|
||||
],
|
||||
"target-mcount": "__mcount",
|
||||
"target-pointer-width": "32"
|
||||
}
|
||||
36
tools/x86_64-unknown-nuttx.json
Normal file
36
tools/x86_64-unknown-nuttx.json
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"arch": "x86_64",
|
||||
"cpu": "x86-64",
|
||||
"crt-objects-fallback": "false",
|
||||
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
|
||||
"disable-redzone": true,
|
||||
"features": "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2,+soft-float",
|
||||
"linker": "rust-lld",
|
||||
"linker-flavor": "gnu-lld",
|
||||
"llvm-target": "x86_64-unknown-nuttx",
|
||||
"max-atomic-width": 64,
|
||||
"metadata": {
|
||||
"description": "x86_64 target for NuttX RTOS with softfloat",
|
||||
"host_tools": false,
|
||||
"std": true,
|
||||
"tier": 3
|
||||
},
|
||||
"panic-strategy": "abort",
|
||||
"plt-by-default": false,
|
||||
"position-independent-executables": true,
|
||||
"relro-level": "full",
|
||||
"rustc-abi": "x86-softfloat",
|
||||
"stack-probes": {
|
||||
"kind": "inline"
|
||||
},
|
||||
"static-position-independent-executables": true,
|
||||
"supported-sanitizers": [
|
||||
"kcfi",
|
||||
"kernel-address"
|
||||
],
|
||||
"os": "nuttx",
|
||||
"target-family": [
|
||||
"unix"
|
||||
],
|
||||
"target-pointer-width": "64"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue