Bug 279889 - devel/emscripten: Error: Cannot find module 'acorn'
Summary: devel/emscripten: Error: Cannot find module 'acorn'
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Yuri Victorovich
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-21 09:39 UTC by Marcin Cieślak
Modified: 2024-06-21 09:39 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (yuri)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcin Cieślak 2024-06-21 09:39:18 UTC
emscripten-3.1.43_1 running on FreeBSD 15-CURRENT main-n270224-fb623aab3927

Name           : emscripten
Version        : 3.1.43_1
Installed on   : Fri Jun 21 02:32:23 2024 CEST
Origin         : devel/emscripten
Architecture   : FreeBSD:15:*
Prefix         : /usr/local
Categories     : www devel
Licenses       : NCSA or MIT
Maintainer     : yuri@FreeBSD.org
WWW            : https://emscripten.org/
Comment        : LLVM-to-Web Compiler
Annotations    :
	build_timestamp: 2024-06-12T20:40:32+0000
	built_by       : poudriere-git-3.4.1-30-g79e3edcd
	port_checkout_unclean: no
	port_git_hash  : 1ce58015ec0
	ports_top_checkout_unclean: no
	ports_top_git_hash: be0f24e23b1
	repo_type      : binary
	repository     : FreeBSD
Flat size      : 31.2MiB
Description    :
Emscripten is a toolchain for compiling to asm.js and WebAssembly, built using
LLVM, that lets you run C and C++ on the web at near-native speed without
plugins.

I try to make new nodejs facility to compile all JS stuff into one ELF binary that contains node + the app.

I have checked out the following:

radziecki> git log -1 --oneline
3c4f208 (HEAD -> main, tag: v1.0.0-alpha.6, origin/main, origin/HEAD) release: 1.0.0-alpha.6
radziecki> git remote -v
origin	https://github.com/nodejs/postject (fetch)
origin	https://github.com/nodejs/postject (push)

and using www/node20 and yarn to build it with "yarn build" I end up with the following during the final linking stage:

[427/432] Building C object vendor/lief/CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/x509_csr.c.o
emcc: warning: LLVM version for clang executable "/usr/local/bin/clang-devel" appears incorrect (seeing "19.0", expected "17") [-Wversion-check]
[428/432] 
[429/432] Building C object vendor/lief/CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/x509write_csr.c.o
emcc: warning: LLVM version for clang executable "/usr/local/bin/clang-devel" appears incorrect (seeing "19.0", expected "17") [-Wversion-check]
[430/432] Building C object vendor/lief/CMakeFiles/LIB_LIEF.dir/mbed_tls/src/lief_mbed_tls/library/x509write_crt.c.o
emcc: warning: LLVM version for clang executable "/usr/local/bin/clang-devel" appears incorrect (seeing "19.0", expected "17") [-Wversion-check]
[431/432] Linking CXX static library vendor/lief/libLIEF.a
[432/432] Linking CXX executable postject.js
FAILED: postject.js 
: && ccache /usr/local/lib/emscripten/em++ -O3 -DNDEBUG -sSINGLE_FILE -sMODULARIZE=1 -sALLOW_MEMORY_GROWTH -sINITIAL_MEMORY=268435456 -sMAXIMUM_MEMORY=4294967296 --bind CMakeFiles/postject.dir/src/postject.cpp.o -o postject.js  vendor/lief/libLIEF.a && :
em++: warning: LLVM version for clang executable "/usr/local/bin/clang-devel" appears incorrect (seeing "19.0", expected "17") [-Wversion-check]
cache:INFO: generating system asset: symbol_lists/af2dd0985b0d617a65fe09ff6f26ca078c0b4ff6.json... (this will be cached in "/usr/home/saper/.emscripten_cache/symbol_lists/af2dd0985b0d617a65fe09ff6f26ca078c0b4ff6.json" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot/lib/wasm32-emscripten/libembind-rtti.a... (this will be cached in "/usr/home/saper/.emscripten_cache/sysroot/lib/wasm32-emscripten/libembind-rtti.a" for subsequent builds)
system_libs:INFO: compiled 1 inputs
cache:INFO:  - ok
cache:INFO: generating system library: sysroot/lib/wasm32-emscripten/libstubs.a... (this will be cached in "/usr/home/saper/.emscripten_cache/sysroot/lib/wasm32-emscripten/libstubs.a" for subsequent builds)
system_libs:INFO: compiled 2 inputs
cache:INFO:  - ok
cache:INFO: generating system library: sysroot/lib/wasm32-emscripten/libc.a... (this will be cached in "/usr/home/saper/.emscripten_cache/sysroot/lib/wasm32-emscripten/libc.a" for subsequent builds)
system_libs:INFO: compiled 1023 inputs
cache:INFO:  - ok
cache:INFO: generating system library: sysroot/lib/wasm32-emscripten/libc++abi-noexcept.a... (this will be cached in "/usr/home/saper/.emscripten_cache/sysroot/lib/wasm32-emscripten/libc++abi-noexcept.a" for subsequent builds)
system_libs:INFO: compiled 16 inputs
cache:INFO:  - ok
em++: warning: unexpected binaryen version: 117 (expected 114) [-Wversion-check]
node:internal/modules/cjs/loader:1148
  throw err;
  ^

Error: Cannot find module 'acorn'
Require stack:
- /usr/local/lib/emscripten/tools/acorn-optimizer.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Module._load (node:internal/modules/cjs/loader:986:27)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/usr/local/lib/emscripten/tools/acorn-optimizer.js:5:15)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/local/lib/emscripten/tools/acorn-optimizer.js' ]
}

Node.js v20.14.0
em++: error: '/tmp/yarn--1718931070591-0.4618112675740218/node /usr/local/lib/emscripten/tools/acorn-optimizer.js /tmp/emscripten_temp_e5ienxp6/postject.js unsignPointers -o /tmp/emscripten_temp_e5ienxp6/postject.jso1.js' failed (returned 1)
ninja: build stopped: subcommand failed.
Error: 
    at file:///big/sw/postject/scripts/build.mjs:33:8
    exit code: 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Shall the additional component be installed with the port?

I can see there are

tools/acorn-optimizer.[m]js
third_party/terser/

in https://github.com/emscripten-core/emscripten among other things...