Skip to content

Commit 2c5947d

Browse files
committed
cmake/tools: Fix panic_immediate_abort deprecation in Rust build
Replace deprecated -Zbuild-std-features=panic_immediate_abort with -Cpanic=immediate-abort compiler flag via RUSTFLAGS. The panic_immediate_abort feature has been stabilized as a real panic strategy in recent Rust nightly versions. The old method of enabling it via -Zbuild-std-features is no longer supported and triggers a compile error in core/src/panicking.rs. Changes: * cmake/nuttx_add_rust.cmake: Use RUSTFLAGS with -Cpanic=immediate-abort * tools/Rust.mk: Use RUSTFLAGS with -Cpanic=immediate-abort Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
1 parent 45d4c70 commit 2c5947d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

cmake/nuttx_add_rust.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ function(nuttx_add_rust)
128128
# Determine build profile based on CONFIG_DEBUG_FULLOPT
129129
if(CONFIG_DEBUG_FULLOPT)
130130
set(RUST_PROFILE "release")
131-
set(RUST_DEBUG_FLAGS "-Zbuild-std-features=panic_immediate_abort")
131+
set(RUST_PANIC_FLAGS "-Zunstable-options -Cpanic=immediate-abort")
132132
else()
133133
set(RUST_PROFILE "debug")
134-
set(RUST_DEBUG_FLAGS "")
134+
set(RUST_PANIC_FLAGS "")
135135
endif()
136136

137137
# Get the Rust target triple
@@ -152,8 +152,9 @@ function(nuttx_add_rust)
152152
COMMAND
153153
${CMAKE_COMMAND} -E env
154154
NUTTX_INCLUDE_DIR=${PROJECT_SOURCE_DIR}/include:${CMAKE_BINARY_DIR}/include:${CMAKE_BINARY_DIR}/include/arch
155+
RUSTFLAGS=${RUST_PANIC_FLAGS}
155156
cargo build --${RUST_PROFILE} -Zbuild-std=std,panic_abort
156-
${RUST_DEBUG_FLAGS} --manifest-path ${CRATE_PATH}/Cargo.toml --target
157+
--manifest-path ${CRATE_PATH}/Cargo.toml --target
157158
${RUST_TARGET} --target-dir ${RUST_BUILD_DIR}
158159
COMMENT "Building Rust crate ${CRATE_NAME}"
159160
VERBATIM)

tools/Rust.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ endef
9090
ifeq ($(CONFIG_DEBUG_FULLOPT),y)
9191
define RUST_CARGO_BUILD
9292
NUTTX_INCLUDE_DIR=$(TOPDIR)/include:$(TOPDIR)/include/arch \
93+
RUSTFLAGS="-Zunstable-options -Cpanic=immediate-abort" \
9394
cargo build --release -Zbuild-std=std,panic_abort \
94-
-Zbuild-std-features=panic_immediate_abort \
9595
--manifest-path $(2)/$(1)/Cargo.toml \
9696
--target $(call RUST_TARGET_TRIPLE)
9797
endef

0 commit comments

Comments
 (0)