build.rs: patch out any calls to `printf`

This commit is contained in:
Andrew Poelstra 2023-11-01 17:06:16 +00:00
parent 51dab7ac04
commit 942a0e5e2c
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 6 additions and 1 deletions

View File

@ -20,11 +20,16 @@ fn main() {
.include("depend/secp256k1/include") .include("depend/secp256k1/include")
.include("depend/secp256k1/src") .include("depend/secp256k1/src")
.flag_if_supported("-Wno-unused-function") // some ecmult stuff is defined but not used upstream .flag_if_supported("-Wno-unused-function") // some ecmult stuff is defined but not used upstream
.flag_if_supported("-Wno-unused-parameter") // patching out printf causes this warning
.define("SECP256K1_API", Some("")) .define("SECP256K1_API", Some(""))
.define("ENABLE_MODULE_ECDH", Some("1")) .define("ENABLE_MODULE_ECDH", Some("1"))
.define("ENABLE_MODULE_SCHNORRSIG", Some("1")) .define("ENABLE_MODULE_SCHNORRSIG", Some("1"))
.define("ENABLE_MODULE_EXTRAKEYS", Some("1")) .define("ENABLE_MODULE_EXTRAKEYS", Some("1"))
.define("ENABLE_MODULE_ELLSWIFT", Some("1")); .define("ENABLE_MODULE_ELLSWIFT", Some("1"))
// upstream sometimes introduces calls to printf, which we cannot compile
// with WASM due to its lack of libc. printf is never necessary and we can
// just #define it away.
.define("printf(...)", Some(""));
if cfg!(feature = "lowmemory") { if cfg!(feature = "lowmemory") {
base_config.define("ECMULT_WINDOW_SIZE", Some("4")); // A low-enough value to consume negligible memory base_config.define("ECMULT_WINDOW_SIZE", Some("4")); // A low-enough value to consume negligible memory