diff --git a/cmake/nuttx_add_rust.cmake b/cmake/nuttx_add_rust.cmake index e590a3fdc..776f21616 100644 --- a/cmake/nuttx_add_rust.cmake +++ b/cmake/nuttx_add_rust.cmake @@ -122,8 +122,10 @@ function(nuttx_add_rust) # Determine build profile based on CONFIG_DEBUG_FULLOPT if(CONFIG_DEBUG_FULLOPT) set(RUST_PROFILE "release") + set(RUST_DEBUG_FLAGS "-Zbuild-std-features=panic_immediate_abort") else() set(RUST_PROFILE "debug") + set(RUST_DEBUG_FLAGS "") endif() # Get the Rust target triple @@ -142,9 +144,9 @@ function(nuttx_add_rust) add_custom_command( OUTPUT ${RUST_LIB_PATH} COMMAND - cargo build --${RUST_PROFILE} -Zbuild-std=std,panic_abort --manifest-path - ${CRATE_PATH}/Cargo.toml --target ${RUST_TARGET} --target-dir - ${RUST_BUILD_DIR} + cargo build --${RUST_PROFILE} -Zbuild-std=std,panic_abort + ${RUST_DEBUG_FLAGS} --manifest-path ${CRATE_PATH}/Cargo.toml --target + ${RUST_TARGET} --target-dir ${RUST_BUILD_DIR} COMMENT "Building Rust crate ${CRATE_NAME}" VERBATIM) diff --git a/tools/Rust.mk b/tools/Rust.mk index f62d51e7b..935508fa1 100644 --- a/tools/Rust.mk +++ b/tools/Rust.mk @@ -82,6 +82,7 @@ endef ifeq ($(CONFIG_DEBUG_FULLOPT),y) define RUST_CARGO_BUILD cargo build --release -Zbuild-std=std,panic_abort \ + -Zbuild-std-features=panic_immediate_abort \ --manifest-path $(2)/$(1)/Cargo.toml \ --target $(call RUST_TARGET_TRIPLE) endef