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

Rescript fails to build with glibc-2.34 #5494

Closed
jyssh opened this issue Jul 1, 2022 · 4 comments · Fixed by #5499
Closed

Rescript fails to build with glibc-2.34 #5494

jyssh opened this issue Jul 1, 2022 · 4 comments · Fixed by #5499

Comments

@jyssh
Copy link

jyssh commented Jul 1, 2022

The prebuilt binary in my system (NixOS) is (probably) incompatible, forcing a build. However, the process fails with the error:

$ npm install rescript --save-dev

...
No prebuilt Ninja, building Ninja now
bootstrapping ninja...
...
bootstrap complete.  rebuilding...
ninja binary is ready:  <dir>/node_modules/rescript/linux/ninja.exe
No working prebuilt buckleScript compiler
...
Configuring OCaml version 4.06.1+BS
...
signals_asm.c:185:13: error: variably modified ‘sig_alt_stack’ at file scope
  185 | static char sig_alt_stack[SIGSTKSZ];
      |             ^~~~~~~~~~~~~
make[3]: *** [Makefile:150: signals_asm.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory '/home/jayesh/projects/hillridge/simulated-yield/node_modules/rescript/ocaml/asmrun'
make[2]: *** [Makefile:1007: makeruntimeopt] Error 2
make[2]: Leaving directory '/home/jayesh/projects/hillridge/simulated-yield/node_modules/rescript/ocaml'
make[1]: *** [Makefile:484: opt.opt] Error 2
make[1]: Leaving directory '/home/jayesh/projects/hillridge/simulated-yield/node_modules/rescript/ocaml'
make: *** [Makefile:556: world.opt] Error 2
child_process.js:866
    throw err;
    ^

Error: Command failed: make -j9 world.opt && make install 
    at checkExecSyncError (child_process.js:790:11)
    at Object.execSync (child_process.js:863:15)
    at Object.build (/home/jayesh/projects/hillridge/simulated-yield/node_modules/rescript/scripts/buildocaml.js:70:6)
    at provideCompiler (/home/jayesh/projects/hillridge/simulated-yield/node_modules/rescript/scripts/install.js:190:34)
    at Object.<anonymous> (/home/jayesh/projects/hillridge/simulated-yield/node_modules/rescript/scripts/install.js:219:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) {
  status: 2,
  signal: null,
  output: [ null, null, null ],
  pid: 51891,
  stdout: null,
  stderr: null
}

You can find the full log here: https://pastebin.com/Y2NyLvfH

I found an issue on ocaml repo (https://github.com/ocaml/ocaml/issues/10250 3) which talks about this issue. The root cause was determined to be a change in glibc 2.34.

glibc on my system is indeed 2.34.

$  ldd --version
ldd (GNU libc) 2.34

The problem has been fixed in the stock OCaml compiler, but in the more recent (and stock) versions of the compiler. However, because rescript maintains a customized 4.06 version, the fix needs to be backported. As per my understanding, even the pre-built binaries won't build once everything in the world upgrades to glibc 2.34.

@cknitt
Copy link
Member

cknitt commented Jul 2, 2022

For platforms without prebuilt binaries, ReScript is built from source in the npm postinstall script. If no usable OCaml compiler is found on the path, OCaml itself is built from source first. The OCaml sources are vendored inside the ReScript package as vendor/ocaml.tar.gz.

This used to be a customized 4.06 version, but the current master can be compiled with a stock OCaml 4.10+ compiler (CI is using 4.14.0).

I just checked the current contents of vendor/ocaml.tar.gz. The VERSION file says

4.10.3+dev0-2020-12-08

Looking at runtime/signals_nat.c, this still has static char sig_alt_stack[SIGSTKSZ]; and is therefore affected by the problem.

I guess we should replace this version with the OCaml 4.14.0 sources. This would resolve the problem for the upcoming ReScript 10 release, and it might be a good idea in any case to have npm postinstall builds use the same OCaml version as CI builds.

@jyssh
Copy link
Author

jyssh commented Jul 4, 2022

Thank you for the quick resolution.

Can I use this without having to wait for v10 release?

I tried npm install --save-dev "https://github.com/rescript-lang/rescript-compiler.git#master" but that failed with:

npm ERR! ninja not compatible? Error: Command failed: "/home/jayesh/.npm/_cacache/tmp/git-cloneUEZ9rD/linux/ninja.exe" --version
npm ERR! building ninja
npm ERR! ninja.tar.gz not availble in CI mode

@jyssh
Copy link
Author

jyssh commented Jul 5, 2022

Never mind. v10 alpha release is out! Works well. Thank you.

@PlabanJr
Copy link

I am facing the same issue with "rescript": "^9.1.4",.

Node version -> v16.19.0
Log -> https://pastebin.com/w9LzugHp

Dependencies:

 "dependencies": {
    "@apollo/client": "^3.6.6",
    "@datadog/browser-rum": "^4.19.1",
    "@date-io/core": "^1.3.6",
    "@date-io/moment": "1.x",
    "@react-google-maps/api": "^2.2.0",
    "@reasonml-community/graphql-ppx": "^1.2.3",
    "@rescript/std": "^9.1.3",
    "animate.css": "^4.1.0",
    "bs-let": "em/bs-let-m1-compat#master",
    "bs-webapi": "^0.17.1",
    "cors": "^2.8.4",
    "dd-trace": "^4.2.0",
    "decco": "^1.1.1",
    "express": "^4.16.3",
    "express-static-gzip": "^2.0.6",
    "re-formality": "^4.0.0-beta.16",
    "react": "^16.8.1",
    "react-app-polyfill": "^1.0.1",
    "react-autocomplete": "^1.8.1",
    "react-datepicker": "^2.9.6",
    "react-detect-offline": "^2.4.0",
    "react-dom": "^16.8.1",
    "react-ga4": "^2.1.0",
    "rescript-apollo-client": "^3.1.0"
  },
  "devDependencies": {
    "@glennsl/bs-jest": "^0.4.4",
    "@sentry/webpack-plugin": "^1.17.1",
    "chunks-2-json-webpack-plugin": "^1.0.2",
    "clean-webpack-plugin": "^3.0.0",
    "compression-webpack-plugin": "^4.0.0",
    "css-loader": "^3.5.3",
    "dotenv-webpack": "^1.7.0",
    "enzyme-adapter-react-16": "^1.6.0",
    "file-loader": "^6.0.0",
    "html-webpack-plugin": "^4.3.0",
    "moment-locales-webpack-plugin": "^1.0.7",
    "rescript": "^9.1.4",
    "sass": "^1.58.3",
    "sass-loader": "^8.0.2",
    "source-map-loader": "^0.2.4",
    "style-loader": "^1.2.1",
    "url-loader": "^4.1.0",
    "webpack": "^4.20.2",
    "webpack-cli": "^3.1.2",
    "webpack-dev-server": "^3.1.9",
    "webpack-merge": "^4.2.1"
  }

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

Successfully merging a pull request may close this issue.

3 participants