emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.71k stars 3.3k forks source link

ASYNCIFY, shipping build (O3), code bloat and increased memory usage between emscripten versions #14143

Closed warvstar closed 3 years ago

warvstar commented 3 years ago

Looks like debug info is included in O3 with asyncify enabled, is it a bug, can it be removed? I know if I run wasm-opt again manually without the -g it does further optimize but still about 5mb larger. Also, and this might need to be posted in the binaryen repo but anyway, I have a 12 thread, 32gb, machine here and have noticed that upgrading from 2.0.12 to 2.0.18 the memory usage has increased quite a bit with wasm-opt, so much that my program only successfully compiles if I shutdown everything else.

emcc main.cpp -o main.html -pthread -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=navigator.hardwareConcurrency -s EXPORTED_FUNCTIONS="['_main', '_emscripten_is_main_browser_thread']" -s ALLOW_MEMORY_GROWTH=0  -s PROXY_TO_PTHREAD  -s 'ASYNCIFY_ONLY=["main","__original_main","dynCall_ii",  "write_thread_cacheapi(void*)", "read_thread_cacheapi(void*)", "write_thread_idb(void*)", "read_thread_idb(void*)"]' -s 'ASYNCIFY_IMPORTS=["emscripten_idb_load", "emscripten_set_main_loop", "openCache", "loadFromCache", "storeIntoCache"]' -s INITIAL_MEMORY=1024000000 -s ASYNCIFY_IGNORE_INDIRECT -Oz -s ASYNCIFY --shell-file "shell.html"  -mbulk-memory
jeffRTC commented 3 years ago

@kripken @sbc100

WTF!! Is this for real? Did I ship everything with -g flag if this is real??

jeffRTC commented 3 years ago

@warvstar

How'd you figure out that it's force compiled with -g flag?

warvstar commented 3 years ago

@warvstar

How'd you figure out that it's force compiled with -g flag?

I used the -v verbose flag when building and it shows the build steps, -g is listed there.

kripken commented 3 years ago

Asyncify requires some internal use of debug info - the names section. But it only uses it internally, and during the various compiler phases. If you actually see debug info in the output, that would be a serious bug, but I am not aware of such a bug. So, Asyncify should not add debug info.

If you paste the full output of -v we can verify that. Specifically, you should see -g passed to wasm-opt (and maybe finalize), but not to LLVM or clang. And there should be a later wasm-opt command that does not have -g, and removes the debug info.

OTOH, Asyncify does increase code size for other reasons than debug info (details in this post). Asyncify restructures the code to allow pausing and resuming. Often that can add up to 50% bloat, but you can optimize it out in many cases.

kripken commented 3 years ago

About the memory usage issue mentioned here, I don't have a guess as to what could have changed. The quickest thing would probably be for you to bisect to find what caused that regression so we can fix it: https://emscripten.org/docs/contributing/developers_guide.html#bisecting

warvstar commented 3 years ago

Update:

Most of the added size is from the preserved function names, this is happening because I'm using ASYNCIFY_OPEN and because of this line in emcc.py intermediate_debug_info = bool(debug_info or options.emit_symbol_map or settings.ASYNCIFY_OPEN or settings.ASYNCIFY_REMOVE or settings.ASYNCIFY_ADD)

Removing settings.ASYNCIFY_OPEN or settings.ASYNCIFY_REMOVE or settings.ASYNCIFY_ADD solves the issue for me (-g is still used in the wasm-emscripten-finalize stage but not in the final wasm-opt stage) and it avoids leaving the function names in the final build.

warvstar commented 3 years ago

@kripken before my change mentioned earlier

emcc main.cpp -o main.html -pthread -s USE_PTHREADS=1 --extern-post-js ./shell2.js -s PTHREAD_POOL_SIZE=navigator.hardwareConcurrency -s EXPORTED_FUNCTIONS="['_main', '_emscripten_is_main_browser_thread']" -s ALLOW_MEMORY_GROWTH=0  -s PROXY_TO_PTHREAD  -s 'ASYNCIFY_ONLY=["main","__original_main","dynCall_ii",  "write_thread_cacheapi(void*)", "read_thread_cacheapi(void*)", "startTest", "write_thread_idb(void*)", "read_thread_idb(void*)"]' -s 'ASYNCIFY_IMPORTS=["emscripten_idb_load", "emscripten_set_main_loop", "openCache", "loadFromCache", "storeIntoCache"]' -s INITIAL_MEMORY=1024000000 -s ASYNCIFY_IGNORE_INDIRECT -s PTHREAD_POOL_SIZE=navigator.hardwareConcurrency -Oz -s ASYNCIFY --shell-file "shell.html"  -mbulk-memory -v
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream/bin\clang++.exe" -target wasm32-unknown-emscripten -D__EMSCRIPTEN_PTHREADS__=1 -DEMSCRIPTEN -fignore-exceptions -fno-inline-functions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -D__EMSCRIPTEN_major__=2 -D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=18 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL --sysroot=A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot -Xclang -iwithsysroot/include\compat -pthread -Oz -mbulk-memory -v -pthread main.cpp -c -o C:\Users\warvs\AppData\Local\Temp\emscripten_temp_44m0xnvt\main_0.o
clang version 13.0.0 (Cswircachegitchromium.googlesource.com-external-github.com-llvm-llvm--project 94340dd5bb23fb7c4bc7d91d5ac0608eb25660a8)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream/bin
 (in-process)
 "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\bin\\clang++.exe" -cc1 -triple wasm32-unknown-emscripten -emit-obj --mrelax-relocations -disable-free -main-file-name main.cpp -mrelocation-model static -mframe-pointer=none -fno-rounding-math -mconstructor-aliases -target-feature +atomics -target-feature +bulk-memory -target-feature +mutable-globals -target-feature +sign-ext -target-cpu generic -target-feature +bulk-memory -fvisibility hidden -debugger-tuning=gdb -v "-fcoverage-compilation-dir=A:\\Test" -resource-dir "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\lib\\clang\\13.0.0" -D __EMSCRIPTEN_PTHREADS__=1 -D EMSCRIPTEN -D __EMSCRIPTEN_major__=2 -D __EMSCRIPTEN_minor__=0 -D __EMSCRIPTEN_tiny__=18 -D _LIBCPP_ABI_VERSION=2 -D unix -D __unix -D __unix__ -isysroot "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\emscripten\\cache\\sysroot" -internal-isystem "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\emscripten\\cache\\sysroot/include/wasm32-emscripten/c++/v1" -internal-isystem "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\emscripten\\cache\\sysroot/include/c++/v1" -internal-isystem "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\lib\\clang\\13.0.0\\include" -internal-isystem "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\emscripten\\cache\\sysroot/include/wasm32-emscripten" -internal-isystem "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\emscripten\\cache\\sysroot/include" -Oz -Werror=implicit-function-declaration -fdeprecated-macro "-fdebug-compilation-dir=A:\\Test" -ferror-limit 19 -fmessage-length=358 -pthread -fgnuc-version=4.2.1 -fno-inline-functions -fcxx-exceptions -fignore-exceptions -fexceptions -fcolor-diagnostics -vectorize-slp -iwithsysroot/include/SDL "-iwithsysroot/include\\compat" -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o "C:\\Users\\warvs\\AppData\\Local\\Temp\\emscripten_temp_44m0xnvt\\main_0.o" -x c++ main.cpp
clang -cc1 version 13.0.0 based upon LLVM 13.0.0git default target x86_64-pc-windows-msvc
ignoring nonexistent directory "A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot/include/wasm32-emscripten/c++/v1"
ignoring nonexistent directory "A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
 A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot/include/SDL
 A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot/include\compat
 A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot/include/c++/v1
 A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\lib\clang\13.0.0\include
 A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot/include
End of search list.
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream/bin\wasm-ld.exe" -o main.wasm C:\Users\warvs\AppData\Local\Temp\emscripten_temp_44m0xnvt\main_0.o -LA:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\crtbegin.o A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libgl-mt.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libal.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libhtml5.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libc-mt.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libcompiler_rt-mt.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libc++-mt-noexcept.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libc++abi-mt-noexcept.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libdlmalloc-mt.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libc_rt_wasm-optz.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libsockets-mt.a -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined --import-memory --shared-memory --export main --export emscripten_is_main_browser_thread --export emscripten_stack_get_base --export emscripten_stack_get_end --export emscripten_stack_set_limits --export stackSave --export stackRestore --export stackAlloc --export __wasm_call_ctors --export __errno_location --export __emscripten_pthread_data_constructor --export __pthread_tsd_run_dtors --export _emscripten_call_on_thread --export _emscripten_do_dispatch_to_thread --export _emscripten_main_thread_futex --export _emscripten_thread_init --export emscripten_current_thread_process_queued_calls --export _emscripten_allow_main_runtime_queued_calls --export emscripten_futex_wake --export emscripten_get_global_libc --export emscripten_main_browser_thread_id --export emscripten_main_thread_process_queued_calls --export emscripten_register_main_browser_thread_id --export emscripten_run_in_main_runtime_thread_js --export emscripten_sync_run_in_main_thread_2 --export emscripten_sync_run_in_main_thread_4 --export emscripten_tls_init --export pthread_self --export memalign --export emscripten_proxy_main --export malloc --export free --export-table --export __start_em_asm --export __stop_em_asm -z stack-size=5242880 --initial-memory=1024000000 --no-entry --max-memory=1024000000 --global-base=1024
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream\bin\wasm-emscripten-finalize" --minimize-wasm-changes -g main.wasm -o main.wasm --detect-features
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\src\compiler.js C:\Users\warvs\AppData\Local\Temp\tmp8fbk8wgt.txt
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream\bin\wasm-opt" --strip-dwarf --post-emscripten --no-exit-runtime -Oz --low-memory-unused --asyncify --pass-arg=asyncify-ignore-indirect --pass-arg=asyncify-imports@env.emscripten_idb_load,env.emscripten_set_main_loop,env.openCache,env.loadFromCache,env.storeIntoCache,env.__call_main --pass-arg=asyncify-onlylist@main,__original_main,dynCall_ii,write_thread_cacheapi(void*),read_thread_cacheapi(void*),startTest,write_thread_idb(void*),read_thread_idb(void*) --zero-filled-memory --strip-debug --strip-producers main.wasm -o main.wasm -g --mvp-features --enable-threads --enable-mutable-globals --enable-bulk-memory --enable-sign-ext   
warning: Asyncify onlylist contained a non-existing function name: __original_main (__original_main)
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools\acorn-optimizer.js C:\Users\warvs\AppData\Local\Temp\emscripten_temp_44m0xnvt\main.js AJSDCE minifyWhitespace
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools\acorn-optimizer.js C:\Users\warvs\AppData\Local\Temp\tmpn2u34rdn.js emitDCEGraph noPrint
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream\bin\wasm-metadce" --graph-file=C:\Users\warvs\AppData\Local\Temp\tmpmr0jpjqk.txt main.wasm -o main.wasm -g --mvp-features --enable-threads --enable-mutable-globals --enable-bulk-memory --enable-sign-ext
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools\acorn-optimizer.js C:\Users\warvs\AppData\Local\Temp\tmp_4uecvmu.js applyDCEGraphRemovals minifyWhitespace
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools\acorn-optimizer.js C:\Users\warvs\AppData\Local\Temp\emscripten_temp_44m0xnvt\main.js.jso.js.jso.js AJSDCE minifyWhitespace
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream\bin\wasm-opt" --strip-dwarf --minify-imports-and-exports-and-modules main.wasm -o main.wasm -g --mvp-features --enable-threads --enable-mutable-globals --enable-bulk-memory --enable-sign-ext
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools\acorn-optimizer.js C:\Users\warvs\AppData\Local\Temp\tmpfjq36f4t.js applyImportAndExportNameChanges minifyWhitespace
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools/preprocessor.js C:\Users\warvs\AppData\Local\Temp\emscripten_temp_44m0xnvt\settings.js worker.js --expandMacros
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools\acorn-optimizer.js A:\Test\main.worker.js minifyWhitespace
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools/preprocessor.js C:\Users\warvs\AppData\Local\Temp\emscripten_temp_44m0xnvt\settings.js shell.html
 "A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\node_modules\.bin\html-minifier-terser.cmd" main.html -o main.html --collapse-whitespace --collapse-inline-tag-whitespace --remove-comments --remove-tag-whitespace --sort-attributes --sort-class-name --decode-entities --collapse-boolean-attributes --remove-attribute-quotes --remove-redundant-attributes --remove-script-type-attributes --remove-style-link-type-attributes --use-short-doctype --minify-css true --minify-js true

and after

emcc main.cpp -o main.html -pthread -s USE_PTHREADS=1 --extern-post-js ./shell2.js -s PTHREAD_POOL_SIZE=navigator.hardwareConcurrency -s EXPORTED_FUNCTIONS="['_main', '_emscripten_is_main_browser_thread']" -s ALLOW_MEMORY_GROWTH=0  -s PROXY_TO_PTHREAD  -s 'ASYNCIFY_ONLY=["main","__original_main","dynCall_ii",  "write_thread_cacheapi(void*)", "read_thread_cacheapi(void*)", "startTest", "write_thread_idb(void*)", "read_thread_idb(void*)"]' -s 'ASYNCIFY_IMPORTS=["emscripten_idb_load", "emscripten_set_main_loop", "openCache", "loadFromCache", "storeIntoCache"]' -s INITIAL_MEMORY=1024000000 -s ASYNCIFY_IGNORE_INDIRECT -s PTHREAD_POOL_SIZE=navigator.hardwareConcurrency -Oz -s ASYNCIFY --shell-file "shell.html"  -mbulk-memory -v
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream/bin\clang++.exe" -target wasm32-unknown-emscripten -D__EMSCRIPTEN_PTHREADS__=1 -DEMSCRIPTEN -fignore-exceptions -fno-inline-functions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -D__EMSCRIPTEN_major__=2 -D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=18 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL --sysroot=A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot -Xclang -iwithsysroot/include\compat -pthread -Oz -mbulk-memory -v -pthread main.cpp -c -o C:\Users\warvs\AppData\Local\Temp\emscripten_temp_1ogql2of\main_0.o
clang version 13.0.0 (Cswircachegitchromium.googlesource.com-external-github.com-llvm-llvm--project 94340dd5bb23fb7c4bc7d91d5ac0608eb25660a8)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream/bin
 (in-process)
 "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\bin\\clang++.exe" -cc1 -triple wasm32-unknown-emscripten -emit-obj --mrelax-relocations -disable-free -main-file-name main.cpp -mrelocation-model static -mframe-pointer=none -fno-rounding-math -mconstructor-aliases -target-feature +atomics -target-feature +bulk-memory -target-feature +mutable-globals -target-feature +sign-ext -target-cpu generic -target-feature +bulk-memory -fvisibility hidden -debugger-tuning=gdb -v "-fcoverage-compilation-dir=A:\\Test" -resource-dir "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\lib\\clang\\13.0.0" -D __EMSCRIPTEN_PTHREADS__=1 -D EMSCRIPTEN -D __EMSCRIPTEN_major__=2 -D __EMSCRIPTEN_minor__=0 -D __EMSCRIPTEN_tiny__=18 -D _LIBCPP_ABI_VERSION=2 -D unix -D __unix -D __unix__ -isysroot "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\emscripten\\cache\\sysroot" -internal-isystem "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\emscripten\\cache\\sysroot/include/wasm32-emscripten/c++/v1" -internal-isystem "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\emscripten\\cache\\sysroot/include/c++/v1" -internal-isystem "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\lib\\clang\\13.0.0\\include" -internal-isystem "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\emscripten\\cache\\sysroot/include/wasm32-emscripten" -internal-isystem "A:\\dev\\ue4-r424-html5\\Engine\\Platforms\\HTML5\\Build\\emsdk\\emsdk-2.0.18\\upstream\\emscripten\\cache\\sysroot/include" -Oz -Werror=implicit-function-declaration -fdeprecated-macro "-fdebug-compilation-dir=A:\\Test" -ferror-limit 19 -fmessage-length=358 -pthread -fgnuc-version=4.2.1 -fno-inline-functions -fcxx-exceptions -fignore-exceptions -fexceptions -fcolor-diagnostics -vectorize-slp -iwithsysroot/include/SDL "-iwithsysroot/include\\compat" -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o "C:\\Users\\warvs\\AppData\\Local\\Temp\\emscripten_temp_1ogql2of\\main_0.o" -x c++ main.cpp
clang -cc1 version 13.0.0 based upon LLVM 13.0.0git default target x86_64-pc-windows-msvc
ignoring nonexistent directory "A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot/include/wasm32-emscripten/c++/v1"
ignoring nonexistent directory "A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
 A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot/include/SDL
 A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot/include\compat
 A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot/include/c++/v1
 A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\lib\clang\13.0.0\include
 A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot/include
End of search list.
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream/bin\wasm-ld.exe" -o main.wasm C:\Users\warvs\AppData\Local\Temp\emscripten_temp_1ogql2of\main_0.o -LA:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\crtbegin.o A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libgl-mt.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libal.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libhtml5.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libc-mt.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libcompiler_rt-mt.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libc++-mt-noexcept.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libc++abi-mt-noexcept.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libdlmalloc-mt.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libc_rt_wasm-optz.a A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libsockets-mt.a -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined --import-memory --shared-memory --export main --export emscripten_is_main_browser_thread --export emscripten_stack_get_base --export emscripten_stack_get_end --export emscripten_stack_set_limits --export stackSave --export stackRestore --export stackAlloc --export __wasm_call_ctors --export __errno_location --export __emscripten_pthread_data_constructor --export __pthread_tsd_run_dtors --export _emscripten_call_on_thread --export _emscripten_do_dispatch_to_thread --export _emscripten_main_thread_futex --export _emscripten_thread_init --export emscripten_current_thread_process_queued_calls --export _emscripten_allow_main_runtime_queued_calls --export emscripten_futex_wake --export emscripten_get_global_libc --export emscripten_main_browser_thread_id --export emscripten_main_thread_process_queued_calls --export emscripten_register_main_browser_thread_id --export emscripten_run_in_main_runtime_thread_js --export emscripten_sync_run_in_main_thread_2 --export emscripten_sync_run_in_main_thread_4 --export emscripten_tls_init --export pthread_self --export memalign --export emscripten_proxy_main --export malloc --export free --export-table --export __start_em_asm --export __stop_em_asm -z stack-size=5242880 --initial-memory=1024000000 --no-entry --max-memory=1024000000 --global-base=1024
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream\bin\wasm-emscripten-finalize" --minimize-wasm-changes -g main.wasm -o main.wasm --detect-features
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\src\compiler.js C:\Users\warvs\AppData\Local\Temp\tmp3_bmbazq.txt
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream\bin\wasm-opt" --strip-dwarf --post-emscripten --no-exit-runtime -Oz --low-memory-unused --asyncify --pass-arg=asyncify-ignore-indirect --pass-arg=asyncify-imports@env.emscripten_idb_load,env.emscripten_set_main_loop,env.openCache,env.loadFromCache,env.storeIntoCache,env.__call_main --pass-arg=asyncify-onlylist@main,__original_main,dynCall_ii,write_thread_cacheapi(void*),read_thread_cacheapi(void*),startTest,write_thread_idb(void*),read_thread_idb(void*) --zero-filled-memory --strip-debug --strip-producers main.wasm -o main.wasm --mvp-features --enable-threads --enable-mutable-globals --enable-bulk-memory --enable-sign-ext      
warning: Asyncify onlylist contained a non-existing function name: __original_main (__original_main)
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools\acorn-optimizer.js C:\Users\warvs\AppData\Local\Temp\emscripten_temp_1ogql2of\main.js AJSDCE minifyWhitespace
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools\acorn-optimizer.js C:\Users\warvs\AppData\Local\Temp\tmp73dcvqac.js emitDCEGraph noPrint
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream\bin\wasm-metadce" --graph-file=C:\Users\warvs\AppData\Local\Temp\tmpheq90pj4.txt main.wasm -o main.wasm --mvp-features --enable-threads --enable-mutable-globals --enable-bulk-memory --enable-sign-ext
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools\acorn-optimizer.js C:\Users\warvs\AppData\Local\Temp\tmpzcl_h5_s.js applyDCEGraphRemovals minifyWhitespace
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools\acorn-optimizer.js C:\Users\warvs\AppData\Local\Temp\emscripten_temp_1ogql2of\main.js.jso.js.jso.js AJSDCE minifyWhitespace
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/upstream\bin\wasm-opt" --strip-dwarf --minify-imports-and-exports-and-modules main.wasm -o main.wasm --mvp-features --enable-threads --enable-mutable-globals --enable-bulk-memory --enable-sign-ext
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools\acorn-optimizer.js C:\Users\warvs\AppData\Local\Temp\tmpyoa6jgiu.js applyImportAndExportNameChanges minifyWhitespace
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools/preprocessor.js C:\Users\warvs\AppData\Local\Temp\emscripten_temp_1ogql2of\settings.js worker.js --expandMacros
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools\acorn-optimizer.js A:\Test\main.worker.js minifyWhitespace
 "A:/dev/ue4-r424-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-2.0.18/node/14.15.5_64bit/bin/node.exe" A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\tools/preprocessor.js C:\Users\warvs\AppData\Local\Temp\emscripten_temp_1ogql2of\settings.js shell.html
 "A:\dev\ue4-r424-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-2.0.18\upstream\emscripten\node_modules\.bin\html-minifier-terser.cmd" main.html -o main.html --collapse-whitespace --collapse-inline-tag-whitespace --remove-comments --remove-tag-whitespace --sort-attributes --sort-class-name --decode-entities --collapse-boolean-attributes --remove-attribute-quotes --remove-redundant-attributes --remove-script-type-attributes --remove-style-link-type-attributes --use-short-doctype --minify-css true --minify-js true
kripken commented 3 years ago

Thanks @warvstar ! Now I see it. Yes, we emitted the names section (function names - not full debug info, that is, not DWARF) unnecessarily for some of the asyncify flags.

I think what happened is we added more usages of interim debug info, and this regressed. #14154 adds a proper fix as well as some detailed testing so this never regresses again.

jeffRTC commented 3 years ago

@kripken If I understand you correctly, so this happen only for certain asyncify flags?

I only use this flag -s ASYNCIFY and nothing else but OP used several.

kripken commented 3 years ago

@jeffRTC Correct. This only happened with specific flags like ASYNCIFY_ONLY. Default ASYNCIFY did not have the bug (which is probably part of why it wasn't noticed before).