Daninet / hash-wasm

Lightning fast hash functions using hand-tuned WebAssembly binaries
https://npmjs.com/package/hash-wasm
Other
881 stars 49 forks source link

Why is node/optimize commented out in build.sh? #48

Closed gamedevsam closed 1 year ago

gamedevsam commented 1 year ago

I'm a newb when it comes to WASM, mind enlightening me about what the optimize script does (and maybe why it's a bad idea / commented out, or why it's only applied to bcrypt)?

Also using a docker container to get around all the native tooling requirements is so good.

If you don't mind another question, what do these options do on the docker run command?

  -v $(pwd):/app \ <-- does this allow docker to write to the current directory? It that how the output of the build process ends up on the host machine?
  -u $(id -u):$(id -g) \ <-- this one I'm totally confused about
Daninet commented 1 year ago

In the optimize script I tried to use the binaryen's wasm toolchain optimizations. Those are different from LLVM / Clang optimizer which comes with C compilation. But it turned out that LLVM is already doing a great job and binaryen is not able to make further improvements. I kept the script there for future evaluations.

-v command just mounts a volume into the docker container. Basically it creates a shared folder between the container and the host so the container can read the source files and output the binary.

-u command sets the user used in the docker container to run the compiler. Sometimes it helps with fixing file permissions at the output files. But I'm not sure if it's useful in this case. I just copied this from a different project of mine.

gamedevsam commented 1 year ago

Thanks for the clarifications, and exceptional work. I'm gonna be referencing this project anytime I need to compile some WASM!