0m.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/sh -x
  2. echo "tested with clang-8"
  3. alias clang=clang-8
  4. alias wasm-ld=/usr/lib/llvm-8/bin/wasm-ld
  5. export PATH=/usr/lib/llvm-8/bin/:$PATH
  6. clang --version
  7. rm -v -f ./graph2svg.wasm
  8. echo "adding memory support with -Wl,--import-memory for graph2svg.c"
  9. clang -I. --target=wasm32 --no-standard-libraries -Wl,--export-all -Wl,--import-memory -Wl,--no-entry -o graph2svg.wasm graph2svg.c clib.c sfg.c dlmalloc.c
  10. # -v
  11. exit 0
  12. clang -c -v -I. -D__wasi__ --target=wasm32-unknown-wasi --sysroot /home/gold/notabug/sfgraph/wasm/test02/wasi-sysroot -nostartfiles -Wl,--export-all -Wl,--import-memory -Wl,--no-entry graph2svg.c clib.c sfg.c
  13. "/usr/bin/lld" -flavor wasm -L/home/gold/notabug/sfgraph/wasm/test02/wasi-sysroot/lib/wasm32-wasi/ --export-all --import-memory --no-entry *.o libc.a /usr/lib/llvm-7/lib/clang/7.0.1/lib/libclang_rt.builtins-wasm32.a -o graph2svg.wasm
  14. on debian with clang version 7, lld-7 as separate package installed
  15. missing link to /usr/bin/ldd added to /usr/bin/ldd-7
  16. The options passed to clang are:
  17. --target=wasm32 Set the build target to wasm.
  18. --no-standard-libraries Do not use libc (more on this later).
  19. -Wl,--export-all Export all symbols (i.e., add) from the compiled wasm file so that they can be used from JavaScript.
  20. -Wl,--no-entry Don't check for a main function.
  21. -o Set the output destination.
  22. -Wl,--import-memory for memory usage
  23. Options preceded by -Wl, are passed from the LLVM compiler to the linker.
  24. The webserver to use is:
  25. pythom -m SimpleHTTPServer
  26. Then the page is on localhost at port 8000
  27. todo: compiling with this sdk appears to be troublesome:
  28. https://github.com/WebAssembly/wasi-sdk/releases