Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when building O3 or O2 optimization is enabled #6526

Closed
altanozlu opened this issue May 11, 2018 · 4 comments
Closed

Error when building O3 or O2 optimization is enabled #6526

altanozlu opened this issue May 11, 2018 · 4 comments

Comments

@altanozlu
Copy link
Contributor

/Users/altanozlu/emsdk/emscripten/1.38.0/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:272 throw new JS_Parse_Error(message, line, col, pos); ^ TypeError: {} is not a function at new JS_Parse_Error (/Users/altanozlu/emsdk/emscripten/1.38.0/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:261:21) at js_error (/Users/altanozlu/emsdk/emscripten/1.38.0/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:272:15) at croak (/Users/altanozlu/emsdk/emscripten/1.38.0/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:742:17) at token_error (/Users/altanozlu/emsdk/emscripten/1.38.0/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:749:17) at unexpected (/Users/altanozlu/emsdk/emscripten/1.38.0/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:755:17) at Arguments.semicolon (/Users/altanozlu/emsdk/emscripten/1.38.0/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:775:51) at prog1 (/Users/altanozlu/emsdk/emscripten/1.38.0/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:1314:29) at simple_statement (/Users/altanozlu/emsdk/emscripten/1.38.0/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:906:35) at /Users/altanozlu/emsdk/emscripten/1.38.0/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:816:35 at block_ (/Users/altanozlu/emsdk/emscripten/1.38.0/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:999:32) Traceback (most recent call last): File "/Users/altanozlu/emsdk/emscripten/1.38.0/emcc", line 11, in <module> python_selector.run(__file__) File "/Users/altanozlu/emsdk/emscripten/1.38.0/tools/python_selector.py", line 38, in run sys.exit(run_by_import(filename, main) if on_allowed_version() else run_by_subprocess(filename)) File "/Users/altanozlu/emsdk/emscripten/1.38.0/tools/python_selector.py", line 13, in run_by_import return getattr(importlib.import_module(os.path.basename(filename)), main)() File "/Users/altanozlu/emsdk/emscripten/1.38.0/emcc.py", line 1902, in run wasm_text_target, misc_temp_files, optimizer) File "/Users/altanozlu/emsdk/emscripten/1.38.0/emcc.py", line 2442, in do_binaryen emit_symbol_map=emit_symbol_map) File "/Users/altanozlu/emsdk/emscripten/1.38.0/tools/shared.py", line 2236, in minify_wasm_js js_file = Building.js_optimizer_no_asmjs(js_file, ['noPrintMetadata'] + passes) File "/Users/altanozlu/emsdk/emscripten/1.38.0/tools/shared.py", line 2105, in js_optimizer_no_asmjs subprocess.check_call(NODE_JS + [js_optimizer.JS_OPTIMIZER, filename] + passes, stdout=open(next, 'w')) File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 190, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['/Users/altanozlu/emsdk/node/8.9.1_64bit/bin/node', '/Users/altanozlu/emsdk/emscripten/1.38.0/tools/js-optimizer.js', '/tmp/tmpg07KHy/a.bc.o.js.mem.js', 'noPrintMetadata', 'JSDCE', 'minifyWhitespace']' returned non-zero exit status 1

I get this error when i try to enable O2 or O3
this works : emcc deneme.cpp -s WASM=1 -o a.js -std=c++11 -s --llvm-opts "['-O3']" -O1
this doesn't work : emcc deneme.cpp -s WASM=1 -o a.js -std=c++11 -s --llvm-opts "['-O3']" -O2

@kripken
Copy link
Member

kripken commented May 11, 2018

This error could result from --pre-js or EM_ASM code that Uglify can't handle, see #5700, #6000.

We should really add a FAQ entry on this, I'll do that.

@altanozlu
Copy link
Contributor Author

Is the difference between o1 and o2 just uglify ?

@kripken
Copy link
Member

kripken commented May 11, 2018

There are a few more differences too, like passing the higher optimization level to the LLVM optimizer.

You may be able to disable just the js opts part with -O2 --js-opts 0, but without those opts your JS will be much much bigger. Refactoring the tricky ES6 code to not be seen by the optimizer is usually better.

@altanozlu
Copy link
Contributor Author

thanks i'm closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants