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

Build fails when testing cross-compile #233

Closed
averissimo opened this issue Jun 23, 2023 · 5 comments
Closed

Build fails when testing cross-compile #233

averissimo opened this issue Jun 23, 2023 · 5 comments

Comments

@averissimo
Copy link

I'm having problems building with the custom LLVM,

System: Ubuntu (Linux 6.2.0-23-generic)

sudo apt install emscripten cmake gperf liblzma-dev libpcre2-dev quilt  wget
git clone https://github.com/r-wasm/webr
cd webr
./configure
make

Error

config.log

/home/averissimo/work/opensource/r-wasm/webr/libs/build/pcre2-10.39/build/conftest:147
      throw ex;
      ^

TypeError: Failed to parse URL from /home/averissimo/work/opensource/r-wasm/webr/libs/build/pcre2-10.39/build/conftest.wasm
    at Object.fetch (node:internal/deps/undici/undici:11753:11) {
  [cause]: TypeError [ERR_INVALID_URL]: Invalid URL
      at new NodeError (node:internal/errors:400:5)
      at URL.onParseError (node:internal/url:565:9)
      at new URL (node:internal/url:645:5)
      at new Request (node:internal/deps/undici/undici:7175:25)
      at fetch2 (node:internal/deps/undici/undici:10839:25)
      at Object.fetch (node:internal/deps/undici/undici:11751:18)
      at fetch (node:internal/process/pre_execution:237:25)
      at instantiateAsync (/home/averissimo/work/opensource/r-wasm/webr/libs/build/pcre2-10.39/build/conftest:1670:14)
      at createWasm (/home/averissimo/work/opensource/r-wasm/webr/libs/build/pcre2-10.39/build/conftest:1706:3)
      at Object.<anonymous> (/home/averissimo/work/opensource/r-wasm/webr/libs/build/pcre2-10.39/build/conftest:4987:11) {
    input: '/home/averissimo/work/opensource/r-wasm/webr/libs/build/pcre2-10.39/build/conftest.wasm',
    code: 'ERR_INVALID_URL'
  }
}

Node.js v18.13.0
@averissimo
Copy link
Author

This was a problem by using Node.js v18 in emscripten (see emscripten-core/emscripten#16915)

It's probably related to the version Ubuntu ships.

@georgestagg
Copy link
Member

It looks like a newer version of Emscripten might also help -- I'm not sure which version Ubuntu ships in their repos.

In my setup, I use nvm and emsdk to easily switch between versions of Node and Emscripten. Currently, I'm building with Node v20.1.0 and Emscripten v3.1.37, and I think our GHA scripts do the same.

Probably we should spend some time to investigate the exact minimum required version for both and update our README.md to reflect that.

@averissimo
Copy link
Author

Yup! Node v16 with v3.1.37 (or v3.1.42) also fails in building webR. It's the default version that comes with emscripten.

Node v20 solves all issues I was still facing! 🎉

Thank you @georgestagg 🥇 for detailing the versions you're using and pointing to the GHA


Additional help for others that may encounter problems building:

The error below (found in config.log) was solved by using node v20 with emsdk v3.1.37

TypeError: WebAssembly.Tag is not a constructor
    at Object.<anonymous> (/home/averissimo/work/opensource/r-wasm/webr/R/build/R-4.3.0/build/conftest:2:28937)
    at Module._compile (node:internal/modules/cjs/loader:1196:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
    at Module.load (node:internal/modules/cjs/loader:1074:32)
    at Function.Module._load (node:internal/modules/cjs/loader:909:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47
configure:27852: WARNING: cannot run mixed C/Fortran code
configure:27854: error: Maybe check LDFLAGS for paths to Fortran libraries?

@DivadNojnarg
Copy link

Hi,

Facing issues with node > v20 (tried multiple versions) and emcc 3.1.42 with similar error messages.

Are there other versions prerequisites for all the necessary deps (below is what I have):

  • cmake (3.26.4)
  • gperf (GNU gperf 3.0.3)
  • liblzma-dev (For Mac: xz (XZ Utils) 5.4.3; liblzma 5.4.3)
  • quilt (0.67)
  • wget (GNU Wget 1.21.1 built on darwin20.2.0.)
  • libpcre2 (pcre2 from homebrew v10.42)

@DivadNojnarg
Copy link

Solved thanks to @georgestagg:

Hi @DivadNojnarg,

I took a look at your log, and I can see that the Emscripten compiler is using the following v16 node executable bundled with emsdk: /Users/davidgranjon/emsdk/node/16.20.0_64bit/bin/node

The error WebAssembly.Tag is not a constructor is caused by the fact that v16 of node does not support Wasm exceptions, which we have turned on in the Emscripten compiler to be used by webR[1]. It looks like support was introduced in v17.

Please can you try setting the EM_NODE_JS environment variable to point to the newer node binary, before making webR. This should tell Emscripten to use a that newer version of node.

export EM_NODE_JS=/the/path/to/your/v20/node

If you are unsure where node lives, the command which node should print you the full path. You might also have to change the same configuration setting in the file /Users/davidgranjon/emsdk/.emscripten.

If you are still having problems after trying the above, please could you open a new issue and attach your latest config.log there, thanks.

[1] The current README.md is out of date and does not include this information, sorry about that. I plan to update the instructions before the next release.

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

3 participants