[node] node-gyp dependent packages may not work correctly due to node-lts ld.so.cache

  • Open
  • quality assurance status badge
One participant
  • Abhishek Cherath
Submitted by
Abhishek Cherath
Abhishek Cherath wrote on 20 Nov 2022 01:06
(address . bug-guix@gnu.org)

This is a fairly involved bug report, the basic idea is that several npm
packages depend on [node-gyp](https://www.npmjs.com/package/node-gyp),
which is a build tool (written in python) that compiles native plugins
for nodejs (so generally C/C++ code).

This tool uses the *system* C/C++ compiler, so on a guix system with
gcc-toolchain, that would be gcc-12. this allows for the compilation and
installation of these packages in node_modules fine. However, at runtime
(which happens as `node program.js`) since the dynamic linker looks in
the node-lts package's ld.so.cache, it tries to link against gcc-10's
libstdc++.so.6, and errors out because of missing symbols.

To Reproduce, attempt the following (this isn't a particularly minimal
1. guix shell --pure gcc-toolchain libuv mesa make python2 pkg-config
libx11 libxext libxi node
2. cd <<SOME-DIR>>
3. CC=gcc npm i gl
4. guix shell gcc-toolchain libuv mesa make python2 pkg-config libx11
libxext libxi node
5. echo "var gl = require('gl')(64, 64, { preserveDrawingBuffer: true
})" > test.js
6. node test.js

observe "ERR_DLOPEN_FAILED", with Error:
version `GLIBCXX_3.4.29' not found

running with LD_DEBUG=all, shows that node-14.19.3's linked gcc's
libstdc++ is used:

3608: find library=libstdc++.so.6 [0]; searching
3608: search
3608: trying

I'm not really certain how one would go about solving this tbh, I'm
planning to look a little deeper into how node-gyp decides what C++
compiler to use, might be a matter of setting some env vars or
something? any ideas are appreciated.

Thank you,