-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix wasm build #421
Fix wasm build #421
Conversation
What happens if we just drop all the WASM32_* consts in stdio.h? Otherwise we'll need to not define them, just declare the extern and add another .c file which actually defines them and only build it in when building for wasm. |
I'll digest that more thoroughly tomorrow and have a go. Cheers. |
Just wanted to leave a word of encouragement, @tcharding, the work you're doing here is very valuable. |
Thanks man! For the record, I absolutely love working on this project :) |
53455b8
to
c845680
Compare
Hi! Passing by because I'm having compilation issues with |
Noted! Thanks for the info @reuvenpo. |
c845680
to
86d95bb
Compare
@@ -1,17 +0,0 @@ | |||
#include <stddef.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can delete the entire file I guess?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left it because I don't know why these files are there, stdlib.h
is empty as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK @TheBlueMatt added them when he worked on wasm compatibility. They are included in the build-script but serve otherwise no purpose.
This may be an instance of Chesterton’s fence but I would honestly just try and delete them and if nothing breaks, you are good to go :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried removing it and build fails, FTR here is a portion of the error:
cargo:warning=In file included from depend/secp256k1/src/field.h:25:
cargo:warning=depend/secp256k1/src/util.h:16:10: fatal error: 'stdio.h' file not found
cargo:warning=#include <stdio.h>
cargo:warning= ^~~~~~~~~
cargo:warning=1 error generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah interesting. Yeah that makes sense!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, if nothing breaks these files (or any parts of them you can) should definitely be removed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol, I am pretty sure that #include
should not be present upstream. cc @real-or-random
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created bitcoin-core/secp256k1#1095 to track this.
We added these align/size checks because wasm32 doesn't have a well-defined ABI. |
Agreed, let's not remove them. But they should be in their own include, not |
86d95bb
to
bbf1bf4
Compare
Total re-write, please see re-written PR description. |
@@ -8,6 +8,7 @@ | |||
|
|||
#include "../include/secp256k1.h" | |||
#include "../include/secp256k1_preallocated.h" | |||
#include "../../../wasm-sysroot/wasm.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should likely patch this by means of a .patch
file that is automatically applied by vendor.sh
otherwise this change will be gone with the next update of libsecp256k1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh coool, that will fix my unease mentioned in the commit message about patching vendored code :) Thanks man.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case you can also append -include ../../../wasm-sysroot/wasm.h
to the command line of the C compiler (https://docs.rs/cc/latest/cc/struct.Build.html#method.flag), this works on gcc and clang at least.
Should this maybe just be a |
Currently we are defining the WASM integer size and alignments in the `stdio.h` header file, this is wrong because this file is included in the build by way of `build.rs` as well as by upstream `libsecp256k1`. Move WASM integer definitions to a `C` source file and build the file into the binary if target is WASM.
bbf1bf4
to
bfd88db
Compare
Force push is total re-write, please see updated PR description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clean, thanks!
Can't see any blockers in this.
ACK bfd88db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK bfd88db
Huzzah! My local CI script passes once again.
Thank you @elichai for explaining wtf was going on here. |
post merge ACK bfd88db |
Total re-write ... again :)
Currently we are defining the WASM integer size and alignments in the
stdio.h
header file, this is wrong because this file is included in the build by way ofbuild.rs
as well as by upstreamlibsecp256k1
.Move WASM integer definitions to a
C
source file and build the file into the binary if target is WASM.Fixes the first part of #419 (#422 does the second part).
Note to reviewers
I'm not exactly sure why the directory
was-sysroot
is named as it is or if the name is significant tocargo
, please review carefully the directory tree changes.