Test a full `no-std` build in the `no-std-check` crate in CI 2022-10-rgs-no-std
authorMatt Corallo <git@bluematt.me>
Thu, 6 Oct 2022 15:44:03 +0000 (15:44 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 7 Oct 2022 17:19:12 +0000 (17:19 +0000)
Rust is incredibly forgiving in attempts to access `std`, making it
rather difficult to test `no-std` properly. In practice, the only
decent way to do so is to actually build for a platform that does
not have `std`, which we do here by building the `no-std-check`
crate for `arm-thumbv7m-none-eabi`.

.github/workflows/build.yml
no-std-check/src/lib.rs

index a48ecc743b3e2f192fb0dbad54a85a399cc85e1f..799d22a64667ed3fd8de55e4fe4a5097da7e2dba 100644 (file)
@@ -128,7 +128,13 @@ jobs:
           # check no-std compatibility across dependencies
           cd no-std-check
           cargo check --verbose --color always
-          cd ..
+      - name: Build no-std-check on Rust ${{ matrix.toolchain }} for ARM Embedded
+        if: "matrix.build-no-std && matrix.platform == 'ubuntu-latest'"
+        run: |
+          cd no-std-check
+          rustup target add thumbv7m-none-eabi
+          sudo apt-get -y install gcc-arm-none-eabi
+          cargo build --target=thumbv7m-none-eabi
       - name: Test on no-std builds Rust ${{ matrix.toolchain }} and full code-linking for coverage generation
         if: "matrix.build-no-std && matrix.coverage"
         run: |
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0c9ac1ac8e4bd702086402213af792ae0636d192 100644 (file)
@@ -0,0 +1 @@
+#![no_std]