FS#67443 - [emscripten] Missing JavaScript libraries error on optimization level -O2 and above
Attached to Project:
Community Packages
Opened by Ho Tuan Kiet (tuankiet65) - Thursday, 30 July 2020, 11:34 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Friday, 07 August 2020, 21:43 GMT
Opened by Ho Tuan Kiet (tuankiet65) - Thursday, 30 July 2020, 11:34 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Friday, 07 August 2020, 21:43 GMT
|
Details
Invoking em++ to compile a simple C++ program with the -Os
flag complains that a JavaScript library is missing:
tuankiet65:~/emscripten/ $ em++ -Os hello.cpp shared:INFO: EM_IGNORE_SANITY set, ignoring sanity checks em++: warning: unexpected binaryen version: 95 (expected 93) [-Wversion-check] internal/modules/cjs/loader.js:1068 throw err; ^ Error: Cannot find module 'acorn' Require stack: - /usr/lib/emscripten/tools/acorn-optimizer.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1065:15) at Function.Module._load (internal/modules/cjs/loader.js:911:27) at Module.require (internal/modules/cjs/loader.js:1125:19) at require (internal/modules/cjs/helpers.js:75:18) at Object.<anonymous> (/usr/lib/emscripten/tools/acorn-optimizer.js:1:13) at Module._compile (internal/modules/cjs/loader.js:1236:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10) at Module.load (internal/modules/cjs/loader.js:1085:32) at Function.Module._load (internal/modules/cjs/loader.js:950:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) { code: 'MODULE_NOT_FOUND', requireStack: [ '/usr/lib/emscripten/tools/acorn-optimizer.js' ] } em++: error: '/usr/bin/node /usr/lib/emscripten/tools/acorn-optimizer.js /tmp/emscripten_temp_8pgwloxq/a.out.wasm.o.js AJSDCE minifyWhitespace' failed (1) At optimization level -O2 and higher, tools/acorn-optimizer.js is used to optimize the output JavaScript file, however this tool depends on the acorn library which is not installed. I temporarily fixed it by manually installing the library using npm, however I think a permanent fix is to install the libraries by running "npm install" or "npm ci" in the tools/ directory. emscripten's formulae for Homebrew does something like that (https://github.com/Homebrew/homebrew-core/blob/master/Formula/emscripten.rb#L80). Emsdk also does invoke npm ci (https://github.com/emscripten-core/emsdk/blob/master/emsdk.py#L1226) |
This task depends upon
Closed by Sven-Hendrik Haase (Svenstaro)
Friday, 07 August 2020, 21:43 GMT
Reason for closing: Fixed
Friday, 07 August 2020, 21:43 GMT
Reason for closing: Fixed
Also using em++ to build a HTML file also fails on optimization level -O2 and above because the html-minifier-terser library was not found:
tuankiet65:~/emscripten/ $ em++ hello.cpp -o hello.html -Os
shared:INFO: EM_IGNORE_SANITY set, ignoring sanity checks
em++: warning: unexpected binaryen version: 95 (expected 93) [-Wversion-check]
em++: error: html-minifier-terser was not found! Please run "npm install" in Emscripten root directory to set up npm dependencies!