From d332c3e29bad86d1a44ead8b293049b196ec4400 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 11:18:45 +0800 Subject: [PATCH 01/19] gh actions: Build debug and release Signed-off-by: Daniel Schaefer --- .github/workflows/firmware.yml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/firmware.yml b/.github/workflows/firmware.yml index 730eaf13..43b8e3fb 100644 --- a/.github/workflows/firmware.yml +++ b/.github/workflows/firmware.yml @@ -9,7 +9,7 @@ env: jobs: building: - name: Building + name: Building ${{ matrix.platform }} continue-on-error: ${{ matrix.experimental || false }} strategy: matrix: @@ -17,6 +17,8 @@ jobs: # TODO: Also test nightly #rust: [nightly, stable] rust: [stable] + target: [debug, release] + platform: [b1display, c1minimal, ledmatrix] #include: # # Nightly is only for reference and allowed to fail # - rust: nightly @@ -35,28 +37,28 @@ jobs: toolchain: ${{ matrix.rust }} target: thumbv6m-none-eabi - run: cargo install flip-link - - run: cargo build -p ledmatrix - - run: cargo build -p b1display - - run: cargo build -p c1minimal - # TODO: Also build release versions - #- run: cargo build --all --release - run: | + cargo build --${{ matrix.target }} -p ${{ matrix.platform }} + + - name: Convert to UF2 file + run: | sudo apt-get update sudo apt-get install -y libudev-dev cargo install elf2uf2-rs - elf2uf2-rs target/thumbv6m-none-eabi/debug/b1display b1display.uf2 - elf2uf2-rs target/thumbv6m-none-eabi/debug/c1minimal c1minimal.uf2 - elf2uf2-rs target/thumbv6m-none-eabi/debug/ledmatrix ledmatrix.uf2 + elf2uf2-rs target/thumbv6m-none-eabi/${{ matrix.target }}/${{ matrix.platform }} ${{ matrix.platform }}.uf2 + + - name; Show hash of firmare + - run: | + sha256sum target/thumbv6m-none-eabi/${{ matrix.target }}/${{ matrix.platform }} + sha256sum target/thumbv6m-none-eabi/${{ matrix.target }}/${{ matrix.platform }}.uf2 - name: Upload Linux tool uses: actions/upload-artifact@v3 with: - name: inputmodule_fw + name: ${{matrix.platform}.uf2 path: | - b1display.uf2 - c1minimal.uf2 - ledmatrix.uf2 + ${{matrix.platform}.uf2 linting: name: Linting From 80f43d6fde1862bb151e80e92beb1fd4860ed7b8 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 11:24:05 +0800 Subject: [PATCH 02/19] fixup! gh actions: Build debug and release --- .github/workflows/firmware.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/firmware.yml b/.github/workflows/firmware.yml index 43b8e3fb..a499d8f0 100644 --- a/.github/workflows/firmware.yml +++ b/.github/workflows/firmware.yml @@ -1,5 +1,4 @@ name: Firmware CI Checks - on: push @@ -39,7 +38,7 @@ jobs: - run: cargo install flip-link - run: | - cargo build --${{ matrix.target }} -p ${{ matrix.platform }} + cargo build --${{ matrix.target }} -p ${{ matrix.platform }} - name: Convert to UF2 file run: | From 0fd2eafee5e15cca0c07fc9a7f2e3a2a73a13043 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 11:24:39 +0800 Subject: [PATCH 03/19] fixup! fixup! gh actions: Build debug and release --- .github/workflows/firmware.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/firmware.yml b/.github/workflows/firmware.yml index a499d8f0..a3f32153 100644 --- a/.github/workflows/firmware.yml +++ b/.github/workflows/firmware.yml @@ -47,8 +47,8 @@ jobs: cargo install elf2uf2-rs elf2uf2-rs target/thumbv6m-none-eabi/${{ matrix.target }}/${{ matrix.platform }} ${{ matrix.platform }}.uf2 - - name; Show hash of firmare - - run: | + - name: Show hash of firmare + run: | sha256sum target/thumbv6m-none-eabi/${{ matrix.target }}/${{ matrix.platform }} sha256sum target/thumbv6m-none-eabi/${{ matrix.target }}/${{ matrix.platform }}.uf2 From f697eefd230d2aa42e72c7450494d31876cd0b47 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 11:25:29 +0800 Subject: [PATCH 04/19] fixup! fixup! fixup! gh actions: Build debug and release --- .github/workflows/firmware.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/firmware.yml b/.github/workflows/firmware.yml index a3f32153..96dd1d9d 100644 --- a/.github/workflows/firmware.yml +++ b/.github/workflows/firmware.yml @@ -55,9 +55,9 @@ jobs: - name: Upload Linux tool uses: actions/upload-artifact@v3 with: - name: ${{matrix.platform}.uf2 + name: ${{ matrix.platform }}.uf2 path: | - ${{matrix.platform}.uf2 + ${{ matrix.platform }}.uf2 linting: name: Linting From 3b7dcb5e355ff960b2b7daccd8b77b7603ad6e5b Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 11:29:49 +0800 Subject: [PATCH 05/19] fixup! fixup! fixup! fixup! gh actions: Build debug and release --- .github/workflows/firmware.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/firmware.yml b/.github/workflows/firmware.yml index 96dd1d9d..fe75a273 100644 --- a/.github/workflows/firmware.yml +++ b/.github/workflows/firmware.yml @@ -37,8 +37,15 @@ jobs: target: thumbv6m-none-eabi - run: cargo install flip-link - - run: | - cargo build --${{ matrix.target }} -p ${{ matrix.platform }} + - name: Build release firmware + if: ${{ matrix.target }} == 'release' + run: | + cargo build --release -p ${{ matrix.platform }} + + - name: Build debug firmware + if: ${{ matrix.target }} == 'debug' + run: | + cargo build -p ${{ matrix.platform }} - name: Convert to UF2 file run: | From c7796946b75542af4a77818f2f5dcf3e3c99f5da Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 11:35:01 +0800 Subject: [PATCH 06/19] fixup! fixup! fixup! fixup! fixup! gh actions: Build debug and release --- .github/workflows/firmware.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/firmware.yml b/.github/workflows/firmware.yml index fe75a273..a6aa3794 100644 --- a/.github/workflows/firmware.yml +++ b/.github/workflows/firmware.yml @@ -8,8 +8,8 @@ env: jobs: building: - name: Building ${{ matrix.platform }} - continue-on-error: ${{ matrix.experimental || false }} + name: Build ${{ matrix.platform }} (${{ matrix.target }}) + continue-on-error: true strategy: matrix: # All generated code should be running on stable now @@ -57,7 +57,7 @@ jobs: - name: Show hash of firmare run: | sha256sum target/thumbv6m-none-eabi/${{ matrix.target }}/${{ matrix.platform }} - sha256sum target/thumbv6m-none-eabi/${{ matrix.target }}/${{ matrix.platform }}.uf2 + sha256sum ${{ matrix.platform }}.uf2 - name: Upload Linux tool uses: actions/upload-artifact@v3 From 5e81bfc61afadb183cabcfc24660220a07ccd1f8 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 12:02:38 +0800 Subject: [PATCH 07/19] fixup! fixup! fixup! fixup! fixup! fixup! gh actions: Build debug and release --- .github/workflows/firmware.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/firmware.yml b/.github/workflows/firmware.yml index a6aa3794..52c57de2 100644 --- a/.github/workflows/firmware.yml +++ b/.github/workflows/firmware.yml @@ -16,7 +16,7 @@ jobs: # TODO: Also test nightly #rust: [nightly, stable] rust: [stable] - target: [debug, release] + target: ['debug', 'release'] platform: [b1display, c1minimal, ledmatrix] #include: # # Nightly is only for reference and allowed to fail From e70db9cc0ec0cdc54900b27063a7ba4a14736f93 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 12:02:43 +0800 Subject: [PATCH 08/19] gh actions: Build reproducible binary Signed-off-by: Daniel Schaefer --- .github/workflows/firmware.yml | 2 +- Makefile | 48 ++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/.github/workflows/firmware.yml b/.github/workflows/firmware.yml index 52c57de2..67ab2cc5 100644 --- a/.github/workflows/firmware.yml +++ b/.github/workflows/firmware.yml @@ -40,7 +40,7 @@ jobs: - name: Build release firmware if: ${{ matrix.target }} == 'release' run: | - cargo build --release -p ${{ matrix.platform }} + make PLATFORM=${{ matrix.platform }} release - name: Build debug firmware if: ${{ matrix.target }} == 'debug' diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..f87a839e --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +# Makefile to build releases and check build reproducibility + +.PHONY: repro +PLATFORM:=ledmatrix +RELEASE_BIN:=target/thumbv6m-none-eabi/release/$(PLATFORM) +TARGET_FOLDER:=target/thumbv6m-none-eabi/release +FIRST_BIN:=$(PLATFORM)_first + +clean: + rm -f $(RELEASE_BIN) + +# Simple reproducibility check +# Run clean build twice +repro: + # First build + cargo clean + $(MAKE) release + + # Back up, so that `cargo clean` won't remove it + cp $(RELEASE_BIN) $(FIRST_BIN) + # Sleep a bit to make sure timestamps are different + sleep 2 + + # Second build + cargo clean + $(MAKE) release + + # Move back into target, so that `cargo clean` can remove it next time + mv $(FIRST_BIN) $(TARGET_FOLDER) + + $(MAKE) repro_check + +repro_check: + # Make sure the username wasn't embedded + ! strings $(RELEASE_BIN) | grep $(shell whoami) + + # Check that both binaries are equivalent + sha256sum $(RELEASE_BIN) $(TARGET_FOLDER)/$(FIRST_BIN) + cmp $(RELEASE_BIN) $(TARGET_FOLDER)/$(FIRST_BIN) + +release: $(RELEASE_BIN) + +# Build release binary +# Need to remap paths to avoid local absolute paths being embedded in the binary +$(RELEASE_BIN): + env \ + RUSTFLAGS="--remap-path-prefix=$$PWD=. --remap-path-prefix=$$CARGO_HOME=home --remap-path-prefix=$$HOME=home" \ + cargo build --release -p $(PLATFORM) From a6da245c0d68371f5a7db8b03dced8faf0f41785 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 12:50:33 +0800 Subject: [PATCH 09/19] repro: remap-path-prefix Signed-off-by: Daniel Schaefer --- Cargo.toml | 1 + Makefile | 14 +++++++++++--- remap-path-prefix.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100755 remap-path-prefix.py diff --git a/Cargo.toml b/Cargo.toml index ec5e8cb3..0f00d202 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ incremental = false lto = 'fat' opt-level = 3 overflow-checks = false +strip = true # do not optimize proc-macro crates = faster builds from scratch [profile.dev.build-override] diff --git a/Makefile b/Makefile index f87a839e..036eef30 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,14 @@ release: $(RELEASE_BIN) # Build release binary # Need to remap paths to avoid local absolute paths being embedded in the binary $(RELEASE_BIN): - env \ - RUSTFLAGS="--remap-path-prefix=$$PWD=. --remap-path-prefix=$$CARGO_HOME=home --remap-path-prefix=$$HOME=home" \ - cargo build --release -p $(PLATFORM) + cargo build --release -p $(PLATFORM) + + # TODO: Doesn't work, produces a 416B binary, instead of the 46KB binary without this + #env \ + # RUSTFLAGS="--remap-path-prefix=$$PWD=. --remap-path-prefix=$$CARGO_HOME=home --remap-path-prefix=$$HOME=home" \ + # cargo build --release -p $(PLATFORM) + # Manually remap + ./remap-path-prefix.py $(RELEASE_BIN) + + ls -lh $(RELEASE_BIN) + sha256sum $(RELEASE_BIN) diff --git a/remap-path-prefix.py b/remap-path-prefix.py new file mode 100755 index 00000000..d28e188a --- /dev/null +++ b/remap-path-prefix.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# Strip path names from rust binaries +# Ideally would build with RUSTFLAGS set to: +# RUSTFLAGS="--remap-path-prefix=$$PWD=. --remap-path-prefix=$$CARGO_HOME=home --remap-path-prefix=$$HOME=home" \ +# But there's a bug that makes it nuke almost the entire binary, so we can't use it. +# This is a home-grown replacement. + +import sys +import os + +# Get content of these environment variables, search the binaries for them and +# replace it with a string of Xs with the same length +remap_vars = ['PWD', 'HOME', 'CARGO_HOME'] + +# Read all of binary in memory +# Should be much less less than 500K +with open(sys.argv[1], "rb") as f: + binary = f.read() + +for var in remap_vars: + if var in os.environ: + val = os.environ[var] + binval = val.encode('ascii') + replacement = b'X' * len(binval) + print(var, val, binval, replacement) + binary = binary.replace(binval, replacement) + +with open(sys.argv[1], "wb") as f: + f.write(binary) From f8ebf797408639bd98262eba3a66ed4225c89bc8 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 12:50:51 +0800 Subject: [PATCH 10/19] repro: Allow generating uf2 file Signed-off-by: Daniel Schaefer --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 036eef30..e624e0c7 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Makefile to build releases and check build reproducibility -.PHONY: repro +.PHONY: repro release uf2 repro_check PLATFORM:=ledmatrix RELEASE_BIN:=target/thumbv6m-none-eabi/release/$(PLATFORM) TARGET_FOLDER:=target/thumbv6m-none-eabi/release @@ -40,6 +40,10 @@ repro_check: release: $(RELEASE_BIN) +uf2: $(RELEASE_BIN) + elf2uf2-rs target/thumbv6m-none-eabi/release/$(PLATFORM) $(PLATFORM).uf2 + + # Build release binary # Need to remap paths to avoid local absolute paths being embedded in the binary $(RELEASE_BIN): From 22f02dd106ecd569898616cfee769b1c3aa89bab Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 13:22:41 +0800 Subject: [PATCH 11/19] Update cargo.lock Signed-off-by: Daniel Schaefer --- Cargo.lock | 173 ----------------------------------------------------- 1 file changed, 173 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7923f8b4..d19a1b11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -583,55 +583,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52" -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" -dependencies = [ - "autocfg 1.1.0", - "cfg-if", - "crossbeam-utils", - "memoffset", - "scopeguard 1.1.0", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - [[package]] name = "cxx" version = "1.0.94" @@ -827,22 +778,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "exr" -version = "1.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdd2162b720141a91a054640662d3edce3d50a944a50ffca5313cd951abb35b4" -dependencies = [ - "bit_field", - "flume", - "half", - "lebe", - "miniz_oxide 0.6.2", - "rayon-core", - "smallvec 1.10.0", - "zune-inflate", -] - [[package]] name = "ezconf" version = "0.3.0" @@ -911,19 +846,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "flume" -version = "0.10.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" -dependencies = [ - "futures-core", - "futures-sink", - "nanorand", - "pin-project", - "spin", -] - [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -978,15 +900,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "half" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0" -dependencies = [ - "crunchy", -] - [[package]] name = "hash32" version = "0.2.1" @@ -1030,15 +943,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.1" @@ -1202,15 +1106,6 @@ dependencies = [ "libc", ] -[[package]] -name = "jpeg-decoder" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" -dependencies = [ - "rayon", -] - [[package]] name = "js-sys" version = "0.3.61" @@ -1232,12 +1127,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" -[[package]] -name = "lebe" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" - [[package]] name = "ledmatrix" version = "0.1.4" @@ -1377,15 +1266,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memoffset" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" -dependencies = [ - "autocfg 1.1.0", -] - [[package]] name = "micromath" version = "1.1.1" @@ -1682,26 +1562,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "pin-project" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "pio" version = "0.2.1" @@ -1941,28 +1801,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" -[[package]] -name = "rayon" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - [[package]] name = "rdrand" version = "0.4.0" @@ -2377,17 +2215,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "tiff" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7449334f9ff2baf290d55d73983a7d6fa15e01198faef72af07e2a8db851e471" -dependencies = [ - "flate2", - "jpeg-decoder", - "weezl", -] - [[package]] name = "time" version = "0.1.45" From 5ecf3a615eedf99be0efbec5f73423b6bfe10891 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 13:55:12 +0800 Subject: [PATCH 12/19] rust-toolchain: Pin to 1.69.0 Signed-off-by: Daniel Schaefer --- rust-toolchain.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 rust-toolchain.toml diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..1841587b --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.69.0" +targets = ["thumbv6m-none-eabi"] From 7027f8abe89f327937e35b9cd67975b4770dec32 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 14:11:23 +0800 Subject: [PATCH 13/19] fixup! rust-toolchain: Pin to 1.69.0 --- rust-toolchain.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 1841587b..5ce400b6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,4 @@ [toolchain] channel = "1.69.0" targets = ["thumbv6m-none-eabi"] +components = ["clippy", "rustfmt"] From be8f6a314adf90602cfb1cf35b3e93d33e418ca5 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 14:15:11 +0800 Subject: [PATCH 14/19] fixup! repro: Allow generating uf2 file --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index e624e0c7..7be8e55d 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,8 @@ release: $(RELEASE_BIN) uf2: $(RELEASE_BIN) elf2uf2-rs target/thumbv6m-none-eabi/release/$(PLATFORM) $(PLATFORM).uf2 + ls -lh $(PLATFORM).uf2 + sha256sum $(PLATFORM).uf2 # Build release binary From dd15d68b6b4af119af3e3b4025bf7402bb54a0f8 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 14:59:32 +0800 Subject: [PATCH 15/19] gh actions: use rust-toolchain.toml Signed-off-by: Daniel Schaefer --- .github/workflows/firmware.yml | 45 ++++++++++------------------------ 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/.github/workflows/firmware.yml b/.github/workflows/firmware.yml index 67ab2cc5..3c16428a 100644 --- a/.github/workflows/firmware.yml +++ b/.github/workflows/firmware.yml @@ -9,32 +9,13 @@ env: jobs: building: name: Build ${{ matrix.platform }} (${{ matrix.target }}) - continue-on-error: true - strategy: - matrix: - # All generated code should be running on stable now - # TODO: Also test nightly - #rust: [nightly, stable] - rust: [stable] - target: ['debug', 'release'] - platform: [b1display, c1minimal, ledmatrix] - #include: - # # Nightly is only for reference and allowed to fail - # - rust: nightly - # experimental: true - #os: - # # Check compilation works on common OSes - # # (i.e. no path issues) - # # - macOS-latest - # - ubuntu-latest - # - windows-latest - runs-on: [ubuntu-latest] #${{ matrix.os }} + runs-on: [ubuntu-latest] steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.rust }} - target: thumbv6m-none-eabi + + - name: Setup Rust toolchain + run: rustup show + - run: cargo install flip-link - name: Build release firmware @@ -73,10 +54,10 @@ jobs: - uses: actions/checkout@v3 with: submodules: true - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - target: thumbv6m-none-eabi + + - name: Setup Rust toolchain + run: rustup show + - run: | cargo clippy -p b1display -- --deny=warnings cargo clippy -p c1minimal -- --deny=warnings @@ -89,8 +70,8 @@ jobs: - uses: actions/checkout@v3 with: submodules: true - - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt - target: thumbv6m-none-eabi + + - name: Setup Rust toolchain + run: rustup show + - run: cargo fmt --all -- --check From d47596a58f489bf333454ffa3263a72b20f7fe4a Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 15:10:09 +0800 Subject: [PATCH 16/19] fixup! gh actions: use rust-toolchain.toml --- .github/workflows/firmware.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/firmware.yml b/.github/workflows/firmware.yml index 3c16428a..5186d265 100644 --- a/.github/workflows/firmware.yml +++ b/.github/workflows/firmware.yml @@ -9,6 +9,10 @@ env: jobs: building: name: Build ${{ matrix.platform }} (${{ matrix.target }}) + strategy: + matrix: + target: ['debug', 'release'] + platform: [b1display, c1minimal, ledmatrix] runs-on: [ubuntu-latest] steps: - uses: actions/checkout@v3 From 07cb099e617d673eb93ff8dbbfe6e6fe817c3208 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 20:45:42 +0800 Subject: [PATCH 17/19] fixup! repro: remap-path-prefix --- Makefile | 11 +++++------ remap-path-prefix.py | 29 ----------------------------- 2 files changed, 5 insertions(+), 35 deletions(-) delete mode 100755 remap-path-prefix.py diff --git a/Makefile b/Makefile index 7be8e55d..45d45677 100644 --- a/Makefile +++ b/Makefile @@ -51,12 +51,11 @@ uf2: $(RELEASE_BIN) $(RELEASE_BIN): cargo build --release -p $(PLATFORM) - # TODO: Doesn't work, produces a 416B binary, instead of the 46KB binary without this - #env \ - # RUSTFLAGS="--remap-path-prefix=$$PWD=. --remap-path-prefix=$$CARGO_HOME=home --remap-path-prefix=$$HOME=home" \ - # cargo build --release -p $(PLATFORM) - # Manually remap - ./remap-path-prefix.py $(RELEASE_BIN) + # Need to provide the rustflags defined in .cargo/config.toml again because + # setting the environment variable overrides them + env \ + RUSTFLAGS="--remap-path-prefix=$$PWD=. --remap-path-prefix=$$CARGO_HOME=home --remap-path-prefix=$$HOME=home -C link-arg=--nmagic -C link-arg=-Tlink.x -C link-arg=-Tdefmt.x -C linker=flip-link -C inline-threshold=5 -C no-vectorize-loops" \ + cargo build --release -p $(PLATFORM) ls -lh $(RELEASE_BIN) sha256sum $(RELEASE_BIN) diff --git a/remap-path-prefix.py b/remap-path-prefix.py deleted file mode 100755 index d28e188a..00000000 --- a/remap-path-prefix.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python -# Strip path names from rust binaries -# Ideally would build with RUSTFLAGS set to: -# RUSTFLAGS="--remap-path-prefix=$$PWD=. --remap-path-prefix=$$CARGO_HOME=home --remap-path-prefix=$$HOME=home" \ -# But there's a bug that makes it nuke almost the entire binary, so we can't use it. -# This is a home-grown replacement. - -import sys -import os - -# Get content of these environment variables, search the binaries for them and -# replace it with a string of Xs with the same length -remap_vars = ['PWD', 'HOME', 'CARGO_HOME'] - -# Read all of binary in memory -# Should be much less less than 500K -with open(sys.argv[1], "rb") as f: - binary = f.read() - -for var in remap_vars: - if var in os.environ: - val = os.environ[var] - binval = val.encode('ascii') - replacement = b'X' * len(binval) - print(var, val, binval, replacement) - binary = binary.replace(binval, replacement) - -with open(sys.argv[1], "wb") as f: - f.write(binary) From 03cc51efd9ce1ddb72a6f92ab1b6b632517ecebd Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 20:59:52 +0800 Subject: [PATCH 18/19] fixup! repro: remap-path-prefix --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index 45d45677..09ed1c32 100644 --- a/Makefile +++ b/Makefile @@ -49,8 +49,6 @@ uf2: $(RELEASE_BIN) # Build release binary # Need to remap paths to avoid local absolute paths being embedded in the binary $(RELEASE_BIN): - cargo build --release -p $(PLATFORM) - # Need to provide the rustflags defined in .cargo/config.toml again because # setting the environment variable overrides them env \ From d172dd79695f013fbc296d580d25cedb99db4b90 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 11 May 2023 21:31:26 +0800 Subject: [PATCH 19/19] fixup! repro: remap-path-prefix --- Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 0f00d202..176834ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,8 @@ incremental = false lto = 'fat' opt-level = 3 overflow-checks = false -strip = true +# Don't need to strip +strip = false # do not optimize proc-macro crates = faster builds from scratch [profile.dev.build-override]