0m.sh 1.0 KB

1234567891011121314151617181920212223242526
  1. #/bin/sh -x
  2. echo "tested with clang-7"
  3. clang --version
  4. clang --target=wasm32 --no-standard-libraries -Wl,--export-all -Wl,--no-entry -o add.wasm add.c
  5. echo "adding memory support with -Wl,--import-memory for lenstr.c"
  6. clang --target=wasm32 --no-standard-libraries -Wl,--export-all -Wl,--import-memory -Wl,--no-entry -o lenstr.wasm lenstr.c
  7. exit 0
  8. on debian with clang version 7, lld-7 as separate package installed
  9. missing link to /usr/bin/ldd added to /usr/bin/ldd-7
  10. The options passed to clang are:
  11. --target=wasm32 Set the build target to wasm.
  12. --no-standard-libraries Do not use libc (more on this later).
  13. -Wl,--export-all Export all symbols (i.e., add) from the compiled wasm file so that they can be used from JavaScript.
  14. -Wl,--no-entry Don't check for a main function.
  15. -o Set the output destination.
  16. Options preceded by -Wl, are passed from the LLVM compiler to the linker.
  17. The webserver to use is:
  18. pythom -m SimpleHTTPServer
  19. Then the page is on localhost at port 8000 and in console log file is "the answer is 3"