-
Notifications
You must be signed in to change notification settings - Fork 23
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
How to use? #1
Comments
Sorry, no documentation yet. :-) But if you want to just try converting a module, the console app in c-testsuite/build is currently configured to do that. It wants two command line args. The first is the path to your wasm file. The second is the destination to write the assembly.
But I just tried the module you linked, and it doesn't work. :-( Looks like this issue is another instance of RyanLamansky/dotnet-webassembly#11 I don't have table imports working yet either. And if I did, there would also be the minor problem of needing a reference assembly for the other imports. That's not a big issue, but the console app mentioned above is currently configured only to provide WASI. |
@ericsink what is a "table import"? I thought it was something needed for pulling external dependencies. However, this lib, |
In Wasm, a "table" is a used for indirect function calls. Like a "vtable". Conceptually, it's a list of function pointers, and the call indirect instruction is saying "call the nth function in this list". What produced this Wasm file? Where did it come from? |
@ericsink this file has been generated by this dockerfile https://github.com/bitauth/bitcoin-ts/blob/master/wasm/docker/secp256k1.Dockerfile The project itself is https://github.com/bitcoin-core/secp256k1 which is a pure minimalist cryptographic library made in C without dependency. |
Ah, I see. I'm guessing the table import isn't necessary. So my code currently can't cope with the kinds of Wasm produced by emsdk. But the original C code here looks very straightforward, so it should be possible to get it compiling with clang-8 and wasi-sysroot, which should result in something I can convert to an assembly. |
That code appears to also have a dependency on gmp. |
Interesting. I will try to make it works with clang-8. |
If I include gmp statically should be OK. Though I am surprised about this dependency. |
@ericsink I am trying to build the library with the wasi-sdk You can see my progress on https://github.com/NicolasDorier/NBitcoin.Secp256k1 It build but I am surprised because there is no wasm file created anywhere... I think this library is a good test for your project, because it has no dependency (if I turn bignum feature off) |
So I am getting a |
sadly, it is not a wasm file :( |
Yeah, I'm not sure how all that autoconf/configure stuff interacts with the need to use --sysroot and --target flags. |
I managed to build the wasm file! https://aois.blob.core.windows.net/public/libsecp256k1.wasm It seems to be working with RyanLamansky/dotnet-webassembly as well!! :) |
So
|
Still a bunch of import:
|
Nowhere in my lib source code I see any reference to all of this. |
Ok I managed to remove some by making sure the linker does not create an entry point: Still have
|
I checked the wat file those imports are not referenced by any code my library is exporting :( |
Most of those imports are basic calls from the WASI API. |
The "env" __ imports are a surprise. I'm not sure why they're showing up. Usually that stuff shows up with Clang when I'm not building with the wasi target, but with the wasi target, only the wasi functions get declared as imports. It is interesting to note that __indirect_function_table is a table import, which is the problem we started with. |
It seems that it depends on your version. See https://reviews.llvm.org/D40875 The |
I don't understand, as far as I understood your blog post, by using |
Actually I just tracked |
The only imports remaining are
If you can fix this, then things would work like expected :) |
As far as |
I'm trying to build with .NET 5.0 preview, and if I change the version in the project to get it to build, I get this:
|
Is there any instruction somewhere on how to use your project?
I would like to try on this module: https://aois.blob.core.windows.net/public/secp256k1.wasm
The text was updated successfully, but these errors were encountered: