antelle / argon2-browser

Argon2 library compiled for browser runtime
https://antelle.net/argon2-browser
MIT License
367 stars 79 forks source link

Can't reproduce build #11

Closed Fang- closed 5 years ago

Fang- commented 6 years ago

I'm having trouble reproducing the build results as found in /dist.

The files I end up with are significantly shorter than the versions that ship with the repo, and moving them into /docs/dist gives me the following output in the browser console when clicking run on test.html:

wasm streaming compile failed: TypeError: NetworkError when attempting to fetch resource. argon2-asm.min.js:1:11123
falling back to ArrayBuffer instantiation argon2-asm.min.js:1:11169
on the web, we need the wasm binary to be preloaded and set on Module['wasmBinary']. emcc.py will do that for you when generating HTML (but not JS) argon2-asm.min.js:1:15088
on the web, we need the wasm binary to be preloaded and set on Module['wasmBinary']. emcc.py will do that for you when generating HTML (but not JS) argon2-asm.min.js:1:15098
failed to asynchronously prepare wasm: abort("on the web, we need the wasm binary to be preloaded and set on Module['wasmBinary']. emcc.py will do that for you when generating HTML (but not JS)"). Build with -s ASSERTIONS=1 for more info. argon2-asm.min.js:1:10772
abort("on the web, we need the wasm binary to be preloaded and set on Module['wasmBinary']. emcc.py will do that for you when generating HTML (but not JS)"). Build with -s ASSERTIONS=1 for more info. argon2-asm.min.js:1:15088
abort("on the web, we need the wasm binary to be preloaded and set on Module['wasmBinary']. emcc.py will do that for you when generating HTML (but not JS)"). Build with -s ASSERTIONS=1 for more info. argon2-asm.min.js:1:15098
Module.intArrayFromString is not a function undefined test.html:22:19
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///Users/fang/softsrc/argon2-browser/docs/argon2-asm.min.wasm. (Reason: CORS request not http). 

I don't get any errors when running build.sh, as far as I can tell everything's completing fine. Could there be an emscripten configuration step that I missed? Or perhaps this has to do with me using the latest version of all the required tooling?

In case it's useful, I uploaded pastebins of my outputs for /dist/argon2.js and /dist/argon2-asm.min.js. You can see that especially the latter seems to be missing a lot of information compared to the version in the repo.

If you have any ideas here, they'd be much appreciated. Thank you for your time!

antelle commented 6 years ago

What’s your emsctipten and binaryen versions? Could you please upload the build log somewhere?

Fang- commented 6 years ago

Emscripten 1.38.8. I think binaryen has the same version nr? Not sure how to find out. It's whatever came with the emscripten 1.38.8 install, which was latest as of yesterday.

Build log is just this.

Fang- commented 6 years ago

Building with -s ASSERTIONS=1 as suggested by the console output actually gave useful information!

uncaught exception: abort("'intArrayFromString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")

That was clearly actionable. Fixing that brought up a few similar errors. I ended up adding the following to the following into to the build scripts' linker flags:

-s 'EXTRA_EXPORTED_RUNTIME_METHODS=[\"intArrayFromString\",\"ALLOC_NORMAL\",\"allocate\"]'

At this point, testing using /docs/index.html, the WebAssembly version asked for Pointer_stringify to also be exported. Adding that into the above in build-wasm.sh resolved this, and makes it run fine! So that's one down at least.

The asm.js version, on the other hand, started complaining that Assertion failed: you need to wait for the runtime to be ready (e.g. wait for main() to be called). This is probably caused by the .wasm file request failing, as shown in the browser console:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///Users/fang/softsrc/argon2-browser/docs/argon2-asm.min.wasm. (Reason: CORS request not http). 

But then I'm unsure what this is still doing different from the version supplied with the repo, which doesn't have any issue requesting the .wasm file. (Yes, I'm just loading the .html file into my browser directly rather than going through a localhost server, in all cases described here.)

I'm assuming this project still builds/runs fine as-is for you, with latest emscripten and emscripten cmake toolchain file?
Maybe there's a system discrepancy at play here. I'm on MacOS 10.12.6.

Would you consider accepting the above -s addition into the build scripts, assuming that doesn't magically break the build on your end?

Thanks again for your time, hopefully we can work together to make builds for this project more consistent across whatever variable it is we're hitting here. (:

antelle commented 5 years ago

I'll close this, not sure what I can I do with it. Probably playing with different versions of compliers will eventually give a working result.