From: Jeffrey Czyz Date: Fri, 4 Mar 2022 07:59:44 +0000 (-0800) Subject: Check for no-std compatibility across dependencies X-Git-Tag: v0.0.106~31^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=f041a64fca8ff76123adf5c49d34f7e32f9bcd26;p=rust-lightning Check for no-std compatibility across dependencies To ensure no-std is honored across dependencies, add a crate depending on lightning crates supporting no-std. This should ensure any regressions are caught. Otherwise, cargo doesn't seem to catch some incompatibilities (e.g., f64::log10 unavailable in core) and seemingly across other dependencies as describe here: https://blog.dbrgn.ch/2019/12/24/testing-for-no-std-compatibility/ --- diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a4eec2bbc..e894b4947 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -122,6 +122,10 @@ jobs: cargo test --verbose --color always --no-default-features --features no-std # check if there is a conflict between no-std and the default std feature cargo test --verbose --color always --features no-std + # check no-std compatibility across dependencies + cd .. + cd no-std-check + cargo check --verbose --color always cd .. - name: Test on no-std builds Rust ${{ matrix.toolchain }} and full code-linking for coverage generation if: "matrix.build-no-std && matrix.coverage" diff --git a/.gitignore b/.gitignore index a108267c2..10e905af5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ lightning-c-bindings/a.out Cargo.lock .idea lightning/target +no-std-check/target diff --git a/Cargo.toml b/Cargo.toml index df32ac5d9..6e03fc1ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,10 @@ members = [ "lightning-background-processor", ] +exclude = [ + "no-std-check", +] + # Our tests do actual crypo and lots of work, the tradeoff for -O1 is well worth it. # Ideally we would only do this in profile.test, but profile.test only applies to # the test binary, not dependencies, which means most of the critical code still diff --git a/no-std-check/Cargo.toml b/no-std-check/Cargo.toml new file mode 100644 index 000000000..15d2c196c --- /dev/null +++ b/no-std-check/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "no-std-check" +version = "0.1.0" +edition = "2018" + +[features] +default = ["lightning/no-std", "lightning-invoice/no-std"] + +[dependencies] +lightning = { path = "../lightning", default-features = false } +lightning-invoice = { path = "../lightning-invoice", default-features = false } diff --git a/no-std-check/src/lib.rs b/no-std-check/src/lib.rs new file mode 100644 index 000000000..e69de29bb