emscripten

Emscripten

emcc -v
#emscripten git checkout refs/tags/2.0.12 && npm install # llvm-12, node v10, binaryen98
#binaryen git checkout refs/tags/version_98 && rm CMakeCache.txt && cmake . && make

#llvm
https://emscripten.org/docs/building_from_source/index.html

  Backends

  Emscripten emits WebAssembly using the upstream LLVM wasm backend, since version 1.39.0
   (October 2019). Previously emscripten also supported the old fastcomp backend which was 
  removed in 2.0.0 (August 2020).

2.0.10: 12/04/2020 # llvm-12, node v10, binaryen98
------------------

1.40.0
-------------------
1.39.20: 07/20/2020 # llvm-12, node v8, binaryen94
-------------------
1.39.19: 07/07/2020
-------------------
- In standalone mode make `main` mandatory by default (#11536). To build a
  library ("reactor"), use `--no-entry`. The compiler will suggest that if
  `main` is not present.
- Automatically resume AudioContexts on user input in SDL and OpenAL (#10843).
- Asyncify now does liveness analysis to find which locals to save
  (Binaryen#2890).
1.39.17: 06/05/2020
-------------------
- Remove emterpreter and `EMTERPRETIFY` settings.  Emterpreter has largely
  been replaced by asyncify and is fastcomp only so due for removing in
  the near future anyway.


v1.39.14: binaryen-version_93...emscripten_sleep() ok!


v1.39.11: 03/20/2020 (require option: --version, <=binaryen -version_91)
--------------------
- Enable DWARF support: When compiling with `-g`, normal DWARF emitting happens,
  and when linking with `-g` we preserve that and update it. This is a change
  from before, where we assumed DWARF was unneeded and did not emit it, so this
  can increase the size of debug builds (i.e. builds compiling and/or linking
  with -g). This change is necessary for full debugging support, that is, to
  be able to build with `-g` and use a debugger. Before this change only the
  `-gforce_dwarf` flag enabled DWARF; that flag is now removed. If you want
  the old behavior, build your object files with `-gline-tables-only` (that will
  only add line table info, which is just enough for things like source maps and
  does not include full debug info). For more info and background see #10325.

1.39.4-fastcomp (not require option: --version) openFramework-0.11.0 binaryen-version_8x
-------------------
v1.39.0: 10/18/2019
-------------------
 - The emsdk defaults to the upstream backend (instead of fastcomp) from this
   release onward (but both backends are still fully supported). See
v1.38.41: 08/07/2019
--------------------
 - Remove fastcomp's implementation of Asyncify. This has been deprecated for
   a long time, since we added Emterpreter-Async, and now we have a new Asyncify
   implementation in the upstream wasm backend. It is recommended to upgrade to
   the upstream backend and use Asyncify there if you need it. (If you do still
   need the older version, you can use 1.38.40.)

sdk-fastcomp-1.38.31 openCV4 compiled with binaryen-version_82,clang-11
--------------------
v1.36.14: 11/3/2016
-------------------
 - Added support to emscripten_async_wget() for relative paths.
v1.30.5: 4/7/2015
-----------------
 - Fixed WebIDL operation when closure is enabled after the previous EM_ASM()
   optimizations.
 - Optimized jsCall() to handle variadic cases of number of arguments faster
   (#3290, #3305).
 - Removed support for the getwd() function (#1115, #3309).
 - Fixed a problem with -s IGNORED_FUNCTIONS and -s DEAD_FUNCTIONS not working
   as expected (#3239).
 - Fixed an issue with -s EMTERPRETIFY_ASYNC=1 and emscripten_sleep() not
   working (#3307).


-fignore-exceptions: update to LLVM-11 HEAD
Fatal: initialStackPointer must be set: update binaryen
unreachable executed: update to emcc v1.39.14


# ~/.emscripten
#LLVM_ROOT = os.path.expanduser(os.getenv('LLVM', '/usr/bin')) # directory
LLVM_ROOT = os.path.expanduser(os.getenv('LLVM', '~/download/llvm-project/build/bin')) # directory
#BINARYEN_ROOT = os.path.expanduser(os.getenv('BINARYEN', '')) # if not set, we will use it from ports
BINARYEN_ROOT = os.path.expanduser(os.getenv('BINARYEN', '~/.emscripten_ports/binaryen/binaryen-version_82/')) # if not set, we will use it from ports


export EMCC_CORES=4
emcc --clear-cache # libcも削除される
EMCC_DEBUG=1 emmake make clean
EMCC_DEBUG=1 emmake make

#-s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 # slower, deprecated, supported by the LLVM wasm backend
-O3 -s ASYNCIFY=1
-s ALLOW_MEMORY_GROWTH=1 -s WASM_MEM_MAX=2097152000 #v1.39.8まで
# Rename `TOTAL_MEMORY` to `INITIAL_MEMORY` and `WASM_MEM_MAX` to `MAXIMUM_MEMORY`, #v1.39.9から
-s ERROR_ON_UNDEFINED_SYMBOLS=0
-s EXPORT_ALL=1 -s EXPORT_ALL=1 -s "EXPORTED_FUNCTIONS=['_file_uploaded']" -s  -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall']"


emrun --no_browser --hostname=jetson.local . 
python3 -m http.server 6931 --bind jetson.local


em++ -s ASYNCIFY=1 -o timer.js timer.c

Assertion failed: compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]


emconfigure ./configure --host=asmjs-unknown-emscripten
emconfigure ./configure --disable-assembly
emconfigure ./configure --disable-threads

-s BINARYEN_ASYNC_COMPILATION=0 | 1 # https://github.com/emscripten-core/emscripten/issues/5034
-s WASM=0 | 1

-pthreads | -s USE_PTHREADS=1 # pthreadsを入れると--shared-memoryも入る仕様
-s PTHREAD_POOL_SIZE=4
-matomics # (-mthread-model posix) ほぼ-pthreadsと同じオプション

-Wl,--shared-memory

--check-features/--no-check-features
-Wl,--no-check-features

-mbulk-memory


-s WASM=0 -s ASSERTIONS=2 -g3 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s EXPORT_ALL=1 -s ASYNCIFY=1 -s ALLOW_MEMORY_GROWTH=1

-g4 -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=1 --source-map-base http://jetson.local:6931/

python ~/document/source/emscripten/tools/file_packager.py emnp21kai.data --preload np2.cfg

-s INITIAL_MEMORY=32MB # must be 24MB higher
-s MAXIMUM_MEMORY=
-s ALLOW_MEMORY_GROWTH=1 # it disables asm.js optimizations
  -s ALLOW_MEMORY_GROWTH=0
  -s ALLOW_MEMORY_GROWTH=1
-O3
  -O0
  -O1
  -O2
  -O3
-flto
-fno-rtti -fno-exceptions
--llvm-lto 1 # https://github.com/emscripten-core/emscripten/issues/10603
-g
  -g0
  -g1
  -g2
  -g3
  -g4 # (generate source-map)
-s WASM=1
  -s WASM=0
  -s WASM=1
-s WASM_ASYNC_COMPILATION=1
-s EXPORT_ALL=1
-s "EXPORTED_FUNCTIONS=['_main', '_my_func']"
-s LINKABLE=1
-s RESERVED_FUNCTION_POINTERS=20
-s ASSERTIONS=2
  -s ASSERTIONS=0
  -s ASSERTIONS=1
  -s ASSERTIONS=2
-s SAFE_HEAP=1
-s STACK_OVERFLOW_CHECK=1
-s ERROR_ON_UNDEFINED_SYMBOLS=0
-s ASYNCIFY=1
-s FORCE_FILESYSTEM=1
--preload-file