Skip to content

Commit 92b7333

Browse files
committed
Support non-WASM platforms that are missing string.h
Dunno why we haven't seen this elsewhere, but when trying to build locally for an ARM embedded target `secp256k1-sys` failed to compile as it was missing `string.h`, just like WASM. This patch adds a trivial fallback - if we fail to compile initially we unconditionally retry with the wasm-sysroot, giving us a valid `string.h`.
1 parent 576e10b commit 92b7333

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

secp256k1-sys/build.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@ fn main() {
6262
base_config.file("depend/secp256k1/contrib/lax_der_parsing.c")
6363
.file("depend/secp256k1/src/precomputed_ecmult_gen.c")
6464
.file("depend/secp256k1/src/precomputed_ecmult.c")
65-
.file("depend/secp256k1/src/secp256k1.c")
66-
.compile("libsecp256k1.a");
65+
.file("depend/secp256k1/src/secp256k1.c");
66+
67+
if base_config.try_compile("libsecp256k1.a").is_err() {
68+
// Some embedded platforms may not have, eg, string.h available, so if the build fails
69+
// simply try again with the wasm sysroot (but without the wasm type sizes) in the hopes
70+
// that it works.
71+
base_config.include("wasm/wasm-sysroot");
72+
base_config.compile("libsecp256k1.a");
73+
}
6774
}
6875

0 commit comments

Comments
 (0)