From 684593adc72aa4c563aba1a6aff7ef9332cd660c Mon Sep 17 00:00:00 2001 From: Niklas Dusenlund Date: Mon, 12 Aug 2024 16:04:45 +0200 Subject: [PATCH] Build stdlib ourselves --- src/CMakeLists.txt | 10 ++++++---- src/rust/Cargo.lock | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1a93525470..99ea3cc72e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -205,7 +205,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "DEBUG") set(RUST_PROFILE "debug") else() set(RUST_PROFILE "release") - set(RUST_CARGO_FLAG "--release") + set(RUST_CARGO_FLAGS "--release") # For binary reproducibility, strip path prefixes that can be different depending on environment (e.g. /home/, etc.). set(RUSTFLAGS "--remap-path-prefix=${CMAKE_CURRENT_SOURCE_DIR}/rust=src --remap-path-prefix=$ENV{HOME}=") endif() @@ -231,6 +231,7 @@ if(CMAKE_CROSSCOMPILING) set(RUST_TARGET_ARCH thumbv7em-none-eabi) set(RUST_TARGET_ARCH_DIR ${RUST_TARGET_ARCH}) set(RUST_TARGET_ARCH_ARG --target ${RUST_TARGET_ARCH}) + set(RUST_CARGO_FLAGS ${RUST_CARGO_FLAGS} -Zbuild-std=core,alloc -Zbuild-std-features=panic_immediate_abort,optimize_for_size) else() set(RUST_TARGET_ARCH_DIR .) endif() @@ -436,7 +437,7 @@ if(NOT CMAKE_CROSSCOMPILING) CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} FIRMWARE_VERSION_SHORT=${FIRMWARE_VERSION} # 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. - ${CARGO} test $<$:-v> --all-features --target-dir ${RUST_BINARY_DIR}/all-features ${RUST_CARGO_FLAG} -- --nocapture --test-threads 1 + ${CARGO} test $<$:-v> --all-features --target-dir ${RUST_BINARY_DIR}/all-features ${RUST_CARGO_FLAGS} -- --nocapture --test-threads 1 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/rust/ ) add_dependencies(rust-test bitbox_merged generate-protobufs) @@ -518,7 +519,8 @@ foreach(type ${RUST_LIBS}) RUSTFLAGS=${RUSTFLAGS} FIRMWARE_VERSION_SHORT=${FIRMWARE_VERSION} $<$:RUSTC_WRAPPER=${SCCACHE_PROGRAM}> - ${CARGO} build $<$:-vv> --offline --features target-${type} --target-dir ${RUST_BINARY_DIR}/feature-${type} ${RUST_CARGO_FLAG} ${RUST_TARGET_ARCH_ARG} + RUSTC_BOOTSTRAP=1 + ${CARGO} build $<$:-vv> --offline --features target-${type} --target-dir ${RUST_BINARY_DIR}/feature-${type} ${RUST_CARGO_FLAGS} ${RUST_TARGET_ARCH_ARG} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${lib} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/lib${type}_rust_c.a # DEPFILES are only supported with the Ninja build tool @@ -544,7 +546,7 @@ if(CMAKE_CROSSCOMPILING) CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} SYSROOT=${CMAKE_SYSROOT} INCLUDES="${RUST_INCLUDES}" - ${CARGO} doc --document-private-items --target-dir ${CMAKE_BINARY_DIR}/docs-rust ${RUST_CARGO_FLAG} --target thumbv7em-none-eabi + ${CARGO} doc --document-private-items --target-dir ${CMAKE_BINARY_DIR}/docs-rust --target thumbv7em-none-eabi COMMAND ${CMAKE_COMMAND} -E echo "See docs at file://${CMAKE_BINARY_DIR}/docs-rust/thumbv7em-none-eabi/doc/bitbox02_rust/index.html" WORKING_DIRECTORY ${LIBBITBOX02_RUST_SOURCE_DIR} diff --git a/src/rust/Cargo.lock b/src/rust/Cargo.lock index af1ef09a5e..ad7cfd1595 100644 --- a/src/rust/Cargo.lock +++ b/src/rust/Cargo.lock @@ -431,9 +431,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.146" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "minicbor" @@ -692,9 +692,9 @@ dependencies = [ [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "x25519-dalek"