Currently in order to use secp256k1 in WASM builds one must patch into the build system empty header files for stdlib.h and stdio.h [0].
- Patch 1: Removes the unconditional include of
stdio.hbased on the presence ofUSE_EXTERNAL_DEFAULT_CALLBACKSandVERIFY. - Patch 2: Introduces
PREALLOC_INTERFACE_ONLYand ifndef guards any calls to malloc and friends as well as the include ofstdio.h.
Works towards fixing: #1095
1095 does not mention string.h but it is a problem as well. I cannot work out how to resolve it so attempting to push this in without it. Happy to extend this further if anyone has any ideas.
Notes on testing
I could not work out how to test this in rust-secp256k1 so the I have not proved that this PR removes the requirement to include empty headers described above.
[0] - https://github.com/rust-bitcoin/rust-secp256k1/blob/master/secp256k1-sys/depend/secp256k1.c.patch