]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Check for no-std compatibility across dependencies
authorJeffrey Czyz <jkczyz@gmail.com>
Fri, 4 Mar 2022 07:59:44 +0000 (23:59 -0800)
committerJeffrey Czyz <jkczyz@gmail.com>
Wed, 9 Mar 2022 05:23:26 +0000 (23:23 -0600)
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/

.github/workflows/build.yml
.gitignore
Cargo.toml
no-std-check/Cargo.toml [new file with mode: 0644]
no-std-check/src/lib.rs [new file with mode: 0644]

index a4eec2bbc42e7f97edf89ef7f1228b82b5f2e56d..e894b4947f5b4a35cddbf0307534ae945b4ec031 100644 (file)
@@ -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"
index a108267c2fd1d725aa0e6d8bb1b8f0371b7eea51..10e905af5145fbae9e0c61afa82f3beeeeb9d0c9 100644 (file)
@@ -8,3 +8,4 @@ lightning-c-bindings/a.out
 Cargo.lock
 .idea
 lightning/target
+no-std-check/target
index df32ac5d9cf047ea597a75a0736de6f0a3537ce5..6e03fc1ac4cfc4bab1feed65368651bc5135cb9e 100644 (file)
@@ -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 (file)
index 0000000..15d2c19
--- /dev/null
@@ -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 (file)
index 0000000..e69de29