Skip to content

Commit b38865a

Browse files
committed
rust: remove RUST_BOOTSTRAP and unstable features
Since Rust 1.68.0, there is a default alloc error handler in no_std that simply panics. Before Rust 1.68.0, we had to define our own alloc error handler using the unstable/nightly feature `#[alloc_error_handler]`. We can simply remove this now. As a result, we can remove the RUST_BOOTSTRAP=1 hack that enables nightly features even on stable releases.
1 parent 2a5ebed commit b38865a

File tree

3 files changed

+0
-26
lines changed

3 files changed

+0
-26
lines changed

src/CMakeLists.txt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,6 @@ if(NOT CMAKE_CROSSCOMPILING)
408408
COMMAND
409409
${CMAKE_COMMAND} -E env
410410
CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}
411-
# enable nightly features in the stable release - needed to activate alloc_error_handler.
412-
# see src/rust/bitbox02-rust-c/src/lib.rs.
413-
# https://github.com/rust-lang/rust/issues/66740
414-
RUSTC_BOOTSTRAP=1
415411
FIRMWARE_VERSION_SHORT=${FIRMWARE_VERSION}
416412
# only one test thread because of unsafe concurrent access to `SafeData`, `mock_sd()` and `mock_memory()`. Using mutexes instead leads to mutex poisoning and very messy output in case of a unit test failure.
417413
${CARGO} test $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:-v> --all-features --target-dir ${RUST_BINARY_DIR}/all-features ${RUST_CARGO_FLAG} -- --nocapture --test-threads 1
@@ -426,10 +422,6 @@ if(NOT CMAKE_CROSSCOMPILING)
426422
COMMAND
427423
${CMAKE_COMMAND} -E env
428424
CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}
429-
# enable nightly features in the stable release - needed to activate alloc_error_handler.
430-
# see src/rust/bitbox02-rust-c/src/lib.rs.
431-
# https://github.com/rust-lang/rust/issues/66740
432-
RUSTC_BOOTSTRAP=1
433425
FIRMWARE_VERSION_SHORT=${FIRMWARE_VERSION}
434426
${CARGO} clippy
435427
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:-v>
@@ -505,10 +497,6 @@ foreach(type ${RUST_LIBS})
505497
${CMAKE_COMMAND} -E env
506498
CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}
507499
RUSTFLAGS=${RUSTFLAGS}
508-
# enable nightly features in the stable release - needed to activate alloc_error_handler.
509-
# see src/rust/bitbox02-rust-c/src/lib.rs.
510-
# https://github.com/rust-lang/rust/issues/66740
511-
RUSTC_BOOTSTRAP=1
512500
FIRMWARE_VERSION_SHORT=${FIRMWARE_VERSION}
513501
${CARGO} build $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:-v> --features target-${type} --target-dir ${RUST_BINARY_DIR}/feature-${type} ${RUST_CARGO_FLAG} ${RUST_TARGET_ARCH_ARG}
514502
COMMAND
@@ -532,10 +520,6 @@ if(CMAKE_CROSSCOMPILING)
532520
add_custom_target(rust-docs
533521
COMMAND
534522
${CMAKE_COMMAND} -E env
535-
# enable nightly features in the stable release - needed to activate alloc_error_handler.
536-
# see src/rust/bitbox02-rust-c/src/lib.rs.
537-
# https://github.com/rust-lang/rust/issues/66740
538-
RUSTC_BOOTSTRAP=1
539523
FIRMWARE_VERSION_SHORT=${FIRMWARE_VERSION}
540524
CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}
541525
SYSROOT=${CMAKE_SYSROOT}

src/rust/bitbox02-rust-c/src/alloc.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[alloc_error_handler]
16-
#[cfg(not(test))]
17-
#[cfg(not(feature = "testing"))]
18-
// Function name is arbitrary.
19-
fn bitbox02_alloc_error_handler(layout: core::alloc::Layout) -> ! {
20-
panic!("memory allocation of {} bytes failed", layout.size())
21-
}
22-
2315
struct BB02Allocator;
2416

2517
extern "C" {

src/rust/bitbox02-rust-c/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
// limitations under the License.
1414

1515
#![no_std]
16-
#![feature(alloc_error_handler)] // used in alloc.rs
17-
#![feature(lang_items)]
1816

1917
#[cfg(test)]
2018
#[macro_use]

0 commit comments

Comments
 (0)