WebAssembly / binaryen

Optimizer and compiler/toolchain library for WebAssembly
Apache License 2.0
7.52k stars 745 forks source link

Can't compile BinaryenJs myself from version 101 #3816

Open hummeleBop opened 3 years ago

hummeleBop commented 3 years ago

Using emscripten 2.0.16, I need to compile the js target of binaryen 101 myself:

C:\dev\emscripten\emscripten\emcmake.bat cmake -G"MinGW Makefiles" -DENABLE_WERROR=OFF -DBUILD_STATIC_LIB:BOOLEAN=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM:PATH="C:\programs\mingw\mingw64\bin\mingw32-make.exe" -L ..\binaryen
C:\dev\emscripten\emscripten\emmake.bat cmake --build . -- binaryen_js -j 1

I get the following error:

[ 98%] Linking CXX executable bin\binaryen_js.js
building:ERROR: Closure compiler run failed:

building:ERROR: tmpeg_o_k8g.js:854:1: ERROR - [JSC_UNDEFINED_VARIABLE] variable _setThrew is undeclared
  854|  _setThrew(0);
        ^^^^^^^^^

1 error(s), 0 warning(s)

em++: error: closure compiler failed (rc: 1): C:\dev\emscripten\emscripten\node_modules\.bin\google-closure-compiler.cmd --compilation_level ADVANCED_OPTIMIZATIONS --language_in ECMASCRIPT_2020 --language_out NO_TRANSPILE --emit_use_strict=false --externs tmp9cwtp9hv.js --externs tmp9sawob0z.js --externs tmpz5z6asgh.js --externs tmplfy9v405.js --externs tmp1_zbywga.js --externs tmpkxptji3s.js --externs tmpm6g0737b.js --externs tmp9muasr2i.js --externs tmp7lr4sgvt.js --externs tmp41o46oap.js --externs tmp9y4vbqk1.js --externs tmpc3lxofrs.js --externs tmpos6nx376.js --externs tmpwl3w7lnk.js --externs tmp48rm2ad1.js --externs tmpbkhstt1i.js --externs tmp05o76wl_.js --externs tmp0ddjd9pb.js --externs tmpjooc23as.js --externs tmpnpjhoa1x.js --externs tmpq0x3frbt.js --externs tmp210jiciw.js --externs tmp3g8va4rp.js --externs tmpipaa9ds1.js --externs tmpvxjwy1_5.js --externs tmpob_k5_m8.js --externs tmpoeltqx4d.js --externs tmpum70xnnz.js --externs tmpy65eov39.js --externs tmpu4cwlxk7.js --externs tmpi0yexjh9.js --externs tmp9rwrc4vf.js --js_output_file tmp_nax1ij7.cc.js --js tmpeg_o_k8g.js --language_in=ECMASCRIPT6 --language_out=ECMASCRIPT6 the error message may be clearer with -g1 and EMCC_DEBUG=2 set
mingw32-make[3]: *** [CMakeFiles\binaryen_js.dir\build.make:308: bin/binaryen_js.js] Error 1
mingw32-make[3]: Leaving directory 'C:/dev/tmp/binaryen_build'
mingw32-make[2]: *** [CMakeFiles\Makefile2:498: CMakeFiles/binaryen_js.dir/all] Error 2
mingw32-make[2]: Leaving directory 'C:/dev/tmp/binaryen_build'
mingw32-make[1]: *** [CMakeFiles\Makefile2:510: CMakeFiles/binaryen_js.dir/rule] Error 2
mingw32-make[1]: Leaving directory 'C:/dev/tmp/binaryen_build'
mingw32-make: *** [Makefile:307: binaryen_js] Error 2
emmake: error: 'cmake --build . -- binaryen_js -j 1' failed (2)

It work as expected on the previous version, could you tell me what I am doing wrong ?

Thanks a lot

kripken commented 3 years ago

I tested on version_101 using emsdk install tot and it works ok. Does that work for you?

(if it does then maybe this was a closure compiler integration error that has been fixed meanwhile)

hummeleBop commented 3 years ago

Thanks for your answer, it doesn't work as expected though:

> emsdk install tot
Cloning into 'C:/dev/em-sdk/releases'...
remote: Finding sources: 100% (3/3)
remote: Total 21821 (delta 13958), reused 21821 (delta 13958)
Receiving objects: 100% (21821/21821), 9.24 MiB | 2.45 MiB/s, done.
Resolving deltas: 100% (13958/13958), done.
Fetching latest changes to the branch 'master' for 'C:/dev/em-sdk/releases'...
Already up to date.
Successfully updated and checked out branch 'master' on repository 'C:/dev/em-sdk/releases'
Current repository version: "Tue, 20 Apr 2021 06:47:16 +0000 a78c88a559310caf7ae247a9c68d3d11414b6378"
Installing SDK 'sdk-releases-upstream-a78c88a559310caf7ae247a9c68d3d11414b6378-64bit'..
Skipped installing node-14.15.5-64bit, already installed.
Skipped installing python-3.9.2-1-64bit, already installed.
Skipped installing java-8.152-64bit, already installed.
Installing tool 'releases-upstream-a78c88a559310caf7ae247a9c68d3d11414b6378-64bit'..
Downloading: C:/dev/em-sdk/zips/a78c88a559310caf7ae247a9c68d3d11414b6378-wasm-binaries.zip from https://storage.googleapis.com/webassembly/emscripten-releases-builds/win/a78c88a559310caf7ae247a9c68d3d11414b6378/wasm-binaries.zip, 432451995 Bytes
Unpacking 'C:/dev/em-sdk/zips/a78c88a559310caf7ae247a9c68d3d11414b6378-wasm-binaries.zip' to 'C:/dev/em-sdk/upstream'
Done installing tool 'releases-upstream-a78c88a559310caf7ae247a9c68d3d11414b6378-64bit'.
Done installing SDK 'sdk-releases-upstream-a78c88a559310caf7ae247a9c68d3d11414b6378-64bit'.

> & emmake.bat cmake --build . -- binaryen_js -j 1
make: cmake --build . -- binaryen_js -j 1
[0/1] Re-running CMake...
-- Building with -std=c++14
-- Building with -Wall
-- Building with -Werror
-- Building with -Wextra
-- Building with -Wno-unused-parameter
-- Building with -fno-omit-frame-pointer
-- Building with -fno-rtti
-- Building with -Wno-implicit-int-float-conversion
-- Building with -Wno-unknown-warning-option
-- Building with -Wswitch
-- Building with -Wimplicit-fallthrough
-- Building with -Wnon-virtual-dtor
-- Building with -Oz
-- Building with -UNDEBUG
-- Linking with -s SINGLE_FILE
-- Linking with -s ALLOW_MEMORY_GROWTH=1
-- Building with -s DISABLE_EXCEPTION_CATCHING=0
-- Linking with -s DISABLE_EXCEPTION_CATCHING=0
-- Linking with -s NODERAWFS
-- Building with -flto
-- Building with -fcolor-diagnostics
-- Building libbinaryen as statically linked library.
-- Configuring done
-- Generating done
-- Build files have been written to: C:/dev/tmp/binaryen_build
[1/112] Building CXX object src/passes/CMakeFiles/passes.dir/StackIR.cpp.o
shared:INFO: (Emscripten: Running sanity checks)
[112/112] Linking CXX executable bin\binaryen_js.js
FAILED: bin/binaryen_js.js
cmd.exe /C "cd . && C:\dev\em-sdk\upstream\emscripten\em++.bat  -std=c++14 -Wall -Werror -Wextra -Wno-unused-parameter -fno-omit-frame-pointer -fno-rtti -Wno-implicit-int-float-conversion -Wno-unknown-warning-option -Wswitch -Wimplicit-fallthrough -Wnon-virtual-dtor -s DISABLE_EXCEPTION_CATCHING=0 -fcolor-diagnostics -O3 -DNDEBUG -Oz -UNDEBUG -flto  -s SINGLE_FILE -s ALLOW_MEMORY_GROWTH=1 -s DISABLE_EXCEPTION_CATCHING=0 -s NODERAWFS    -O3 src/wasm/CMakeFiles/wasm.dir/literal.cpp.o src/wasm/CMakeFiles/wasm.dir/parsing.cpp.o src/wasm/CMakeFiles/wasm.dir/wasm.cpp.o src/wasm/CMakeFiles/wasm.dir/wasm-binary.cpp.o src/wasm/CMakeFiles/wasm.dir/wasm-debug.cpp.o src/wasm/CMakeFiles/wasm.dir/wasm-emscripten.cpp.o src/wasm/CMakeFiles/wasm.dir/wasm-interpreter.cpp.o src/wasm/CMakeFiles/wasm.dir/wasm-io.cpp.o src/wasm/CMakeFiles/wasm.dir/wasm-s-parser.cpp.o src/wasm/CMakeFiles/wasm.dir/wasm-stack.cpp.o src/wasm/CMakeFiles/wasm.dir/wasm-type.cpp.o src/wasm/CMakeFiles/wasm.dir/wasm-validator.cpp.o src/asmjs/CMakeFiles/asmjs.dir/asm_v_wasm.cpp.o src/asmjs/CMakeFiles/asmjs.dir/asmangle.cpp.o src/asmjs/CMakeFiles/asmjs.dir/shared-constants.cpp.o src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/optimizer-shared.cpp.o src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/parser.cpp.o src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/simple_ast.cpp.o src/passes/CMakeFiles/passes.dir/pass.cpp.o src/passes/CMakeFiles/passes.dir/AlignmentLowering.cpp.o src/passes/CMakeFiles/passes.dir/Asyncify.cpp.o src/passes/CMakeFiles/passes.dir/AvoidReinterprets.cpp.o src/passes/CMakeFiles/passes.dir/CoalesceLocals.cpp.o src/passes/CMakeFiles/passes.dir/CodePushing.cpp.o src/passes/CMakeFiles/passes.dir/CodeFolding.cpp.o src/passes/CMakeFiles/passes.dir/ConstHoisting.cpp.o src/passes/CMakeFiles/passes.dir/DataFlowOpts.cpp.o src/passes/CMakeFiles/passes.dir/DeadArgumentElimination.cpp.o src/passes/CMakeFiles/passes.dir/DeadCodeElimination.cpp.o src/passes/CMakeFiles/passes.dir/DeAlign.cpp.o src/passes/CMakeFiles/passes.dir/DeNaN.cpp.o src/passes/CMakeFiles/passes.dir/Directize.cpp.o src/passes/CMakeFiles/passes.dir/DuplicateImportElimination.cpp.o src/passes/CMakeFiles/passes.dir/DuplicateFunctionElimination.cpp.o src/passes/CMakeFiles/passes.dir/DWARF.cpp.o src/passes/CMakeFiles/passes.dir/ExtractFunction.cpp.o src/passes/CMakeFiles/passes.dir/Flatten.cpp.o src/passes/CMakeFiles/passes.dir/FuncCastEmulation.cpp.o src/passes/CMakeFiles/passes.dir/GenerateDynCalls.cpp.o src/passes/CMakeFiles/passes.dir/I64ToI32Lowering.cpp.o src/passes/CMakeFiles/passes.dir/Inlining.cpp.o src/passes/CMakeFiles/passes.dir/InstrumentLocals.cpp.o src/passes/CMakeFiles/passes.dir/InstrumentMemory.cpp.o src/passes/CMakeFiles/passes.dir/LegalizeJSInterface.cpp.o src/passes/CMakeFiles/passes.dir/LimitSegments.cpp.o src/passes/CMakeFiles/passes.dir/LocalCSE.cpp.o src/passes/CMakeFiles/passes.dir/LogExecution.cpp.o src/passes/CMakeFiles/passes.dir/LoopInvariantCodeMotion.cpp.o src/passes/CMakeFiles/passes.dir/Memory64Lowering.cpp.o src/passes/CMakeFiles/passes.dir/MemoryPacking.cpp.o src/passes/CMakeFiles/passes.dir/MergeBlocks.cpp.o src/passes/CMakeFiles/passes.dir/MergeLocals.cpp.o src/passes/CMakeFiles/passes.dir/Metrics.cpp.o src/passes/CMakeFiles/passes.dir/MinifyImportsAndExports.cpp.o src/passes/CMakeFiles/passes.dir/NameList.cpp.o src/passes/CMakeFiles/passes.dir/NameTypes.cpp.o src/passes/CMakeFiles/passes.dir/NoExitRuntime.cpp.o src/passes/CMakeFiles/passes.dir/OptimizeAddedConstants.cpp.o src/passes/CMakeFiles/passes.dir/OptimizeInstructions.cpp.o src/passes/CMakeFiles/passes.dir/PickLoadSigns.cpp.o src/passes/CMakeFiles/passes.dir/Poppify.cpp.o src/passes/CMakeFiles/passes.dir/PostEmscripten.cpp.o src/passes/CMakeFiles/passes.dir/Precompute.cpp.o src/passes/CMakeFiles/passes.dir/Print.cpp.o src/passes/CMakeFiles/passes.dir/PrintCallGraph.cpp.o src/passes/CMakeFiles/passes.dir/PrintFeatures.cpp.o src/passes/CMakeFiles/passes.dir/PrintFunctionMap.cpp.o src/passes/CMakeFiles/passes.dir/RoundTrip.cpp.o src/passes/CMakeFiles/passes.dir/SetGlobals.cpp.o src/passes/CMakeFiles/passes.dir/StackIR.cpp.o src/passes/CMakeFiles/passes.dir/Strip.cpp.o src/passes/CMakeFiles/passes.dir/StripTargetFeatures.cpp.o src/passes/CMakeFiles/passes.dir/RedundantSetElimination.cpp.o src/passes/CMakeFiles/passes.dir/RemoveImports.cpp.o src/passes/CMakeFiles/passes.dir/RemoveMemory.cpp.o src/passes/CMakeFiles/passes.dir/RemoveNonJSOps.cpp.o src/passes/CMakeFiles/passes.dir/RemoveUnusedBrs.cpp.o src/passes/CMakeFiles/passes.dir/RemoveUnusedNames.cpp.o src/passes/CMakeFiles/passes.dir/RemoveUnusedModuleElements.cpp.o src/passes/CMakeFiles/passes.dir/ReorderLocals.cpp.o src/passes/CMakeFiles/passes.dir/ReorderFunctions.cpp.o src/passes/CMakeFiles/passes.dir/ReReloop.cpp.o src/passes/CMakeFiles/passes.dir/TrapMode.cpp.o src/passes/CMakeFiles/passes.dir/SafeHeap.cpp.o src/passes/CMakeFiles/passes.dir/SimplifyGlobals.cpp.o src/passes/CMakeFiles/passes.dir/SimplifyLocals.cpp.o src/passes/CMakeFiles/passes.dir/Souperify.cpp.o src/passes/CMakeFiles/passes.dir/StackCheck.cpp.o src/passes/CMakeFiles/passes.dir/SSAify.cpp.o src/passes/CMakeFiles/passes.dir/Untee.cpp.o src/passes/CMakeFiles/passes.dir/Vacuum.cpp.o src/passes/CMakeFiles/passes.dir/WasmIntrinsics.cpp.o src/ir/CMakeFiles/ir.dir/ExpressionAnalyzer.cpp.o src/ir/CMakeFiles/ir.dir/ExpressionManipulator.cpp.o src/ir/CMakeFiles/ir.dir/LocalGraph.cpp.o src/ir/CMakeFiles/ir.dir/ReFinalize.cpp.o src/ir/CMakeFiles/ir.dir/stack-utils.cpp.o src/ir/CMakeFiles/ir.dir/table-utils.cpp.o src/ir/CMakeFiles/ir.dir/type-updating.cpp.o src/ir/CMakeFiles/ir.dir/module-splitting.cpp.o src/cfg/CMakeFiles/cfg.dir/Relooper.cpp.o src/support/CMakeFiles/support.dir/archive.cpp.o src/support/CMakeFiles/support.dir/bits.cpp.o src/support/CMakeFiles/support.dir/colors.cpp.o src/support/CMakeFiles/support.dir/command-line.cpp.o src/support/CMakeFiles/support.dir/debug.cpp.o src/support/CMakeFiles/support.dir/file.cpp.o src/support/CMakeFiles/support.dir/path.cpp.o src/support/CMakeFiles/support.dir/safe_integer.cpp.o src/support/CMakeFiles/support.dir/threads.cpp.o src/support/CMakeFiles/support.dir/utilities.cpp.o CMakeFiles/binaryen_js.dir/src/binaryen-c.cpp.o  -o bin\binaryen_js.js  -s WASM=0 -s WASM_ASYNC_COMPILATION=0 -s NO_FILESYSTEM=0 -s NODERAWFS=0 -s EXPORT_NAME=binaryen --post-js C:/dev/tmp/binaryen/src/js/binaryen.js-post.js --extern-pre-js C:/dev/tmp/binaryen/src/js/binaryen.js-extern-pre.js --extern-post-js C:/dev/tmp/binaryen/src/js/binaryen.js-extern-post.js --closure 1 --closure-args "--language_in=ECMASCRIPT6 --language_out=ECMASCRIPT6" -flto && cd ."
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libgl.a... (this will be cached in "C:\dev\em-sdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libgl.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libal.a... (this will be cached in "C:\dev\em-sdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libal.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libhtml5.a... (this will be cached in "C:\dev\em-sdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libhtml5.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libc.a... (this will be cached in "C:\dev\em-sdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libc.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libcompiler_rt.a... (this will be cached in "C:\dev\em-sdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libcompiler_rt.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libc++.a... (this will be cached in "C:\dev\em-sdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libc++.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libc++abi.a... (this will be cached in "C:\dev\em-sdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libc++abi.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libdlmalloc.a... (this will be cached in "C:\dev\em-sdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libdlmalloc.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libc_rt_wasm-optz.a... (this will be cached in "C:\dev\em-sdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libc_rt_wasm-optz.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libsockets.a... (this will be cached in "C:\dev\em-sdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libsockets.a" for subsequent builds)
cache:INFO:  - ok
building:ERROR: Closure compiler run failed:

building:ERROR: tmpk4bpqmfj.js:839:1: ERROR - [JSC_UNDEFINED_VARIABLE] variable _setThrew is undeclared
  839|  _setThrew(0);
        ^^^^^^^^^

1 error(s), 0 warning(s)

em++: error: closure compiler failed (rc: 1): C:\dev\em-sdk\upstream\emscripten\node_modules\.bin\google-closure-compiler.cmd --compilation_level ADVANCED_OPTIMIZATIONS --language_in ECMASCRIPT_2020 --language_out NO_TRANSPILE --emit_use_strict=false --externs tmpa5ntuvs9.js --externs tmpjym330ao.js --externs tmpidgf93wy.js --externs tmp5jysisiu.js --externs tmpn9h1_t27.js --externs tmpjfxy2d_r.js --externs tmpqdic_oj3.js --externs tmp3mbf3v1r.js --externs tmpskqmwaqo.js --externs tmp778apn78.js --externs tmprpvls9lb.js --externs tmpenxlamic.js --externs tmpd14wvt2k.js --externs tmpqgtitvg5.js --externs tmp7wdatglq.js --externs tmp_qimq_n2.js --externs tmpyw19_jl8.js --externs tmpkrhcmnxj.js --externs tmpn1krr_vy.js --externs tmpkkc9uwe0.js --externs tmpxeaseolu.js --externs tmp80m2snac.js --externs tmp8uass2ju.js --externs tmp02s6y01x.js --externs tmp8mu5wmic.js --externs tmpb0dws74s.js --externs tmp6w3dzj_t.js --externs tmptyi6xixl.js --externs tmpuigbd3dk.js --externs tmp1fpom51p.js --externs tmp842tmaj1.js --externs tmpa80sw47n.js --js_output_file tmp6kzwqxd_.cc.js --js tmpk4bpqmfj.js --language_in=ECMASCRIPT6 --language_out=ECMASCRIPT6 the error message may be clearer with -g1 and EMCC_DEBUG=2 set
ninja: build stopped: subcommand failed.
emmake: error: 'cmake --build . -- binaryen_js -j 1' failed (1)
kripken commented 3 years ago

Very strange...

Try linking with EMCC_DEBUG=1 in the env and attaching the emcc-* temp files that it emits in the temp dir (/tmp/emscripten_temp on linux, not sure where that is on windows). We can search those for that setThrew to understand the issue better.