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

Change target GLIBC version #2317

Closed
mdemaredeb opened this issue Jan 27, 2021 · 2 comments
Closed

Change target GLIBC version #2317

mdemaredeb opened this issue Jan 27, 2021 · 2 comments

Comments

@mdemaredeb
Copy link

  • Node Version: Compiled using node 6.9.1 / npm 3.10.8; Run using nwjs 0.29.1 (which runs node 9.8.0)
  • Platform:
  • Compiler:
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) 
  • Module: It's a self made module that I use to connect to printers via driver. I compile it using nw-gyp rebuild --production --runtime=node-webkit --target=0.29.1

The full error message I get when I try to do require(printer) is:

/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /home/debtech/Descargas/debPlayerWeb-v3.15.8-linux64/debPlayerWeb/node_modules/printer/build/Printer/Printer.node)

And I can't really get a verbose output from this nwjs app, so this is all I've goto

The issue started happening when I upgraded the machine I compile on to Ubuntu 20. If my understanding is correct, the problem here is that it's getting compiled targeting GLIBC_2.28, but the PC it;s running on (Ubuntu 16) has an older version.
I've tried adding --libs=flib-2.26 to the cflags in the binding.gyp file, but I got the following warning on compile time, and the error persisted: cc1plus: warning: command line option ‘-flibs=glib-2.26’ is valid for Modula-2 but not for C++

I see here they mention that Snap may be causing the issue, but I'm not using Snap. Also, I've found in many forums that upgrading/downgrading your system's GLIBC version is not recommended, as it is highly likely that you'll break something systemwide

So the question is: Is there any way to change the target GLIBC version to an older one, so that my module can run in older systems?
Any help will be appreciated!

@rvagg
Copy link
Member

rvagg commented Jan 28, 2021

gee, Node.js 6.9.1, we're reaching quite a bit into history here.

Your problem is going to be that your gcc version is tied to your glibc version (and libc++). So your newer Ubuntu 20.04 compiler is producing binaries linked against newer glibc. There's no pleasant way to deal with this unfortunately. You could try and switch to clang and fiddle with that. But what I'd recommend doing is using Docker on your 20.04 machine to either compile on an older image with an older compiler and glibc version, or use Docker to run CentOS 7 (or Fedora, maybe, I'm not sure about that) and use whatever the latest devtoolset is that you can get on there and compile with that. The RHEL devtoolsets are hacked so that their gcc will compile against the glibc that's available on the base system (well, I think it statically compiles in some diffs, or something clever). This is how we make official Node.js binaries that support older systems.

This table is your friend: https://en.wikipedia.org/wiki/GNU_C_Library#Version_history - find the minimum system you want to support and find an OS that has a glibc at least that old. You'll see that RHEL7 is on there with a glibc compatible with even Ubuntu 13.04! So if you manage to compile on CentOS7, then you end up with binaries that are very compatible with older systems.

The further you push back the harder this process is, though. If I were you I'd work on getting a nice Docker container setup that will perform the compile for you and make a binary on exactly the system you want. Ubuntu 16.04 should be OK, but there are issues as you start to get to newer versions of Node.js that need a newer compiler, which brings in new challenges because if you upgrade the base compiler on Ubuntu (using the ubuntu-toolchain-r, for instance), then that brings in a newer version of glibc and libc++ than is on the base system so you lose out in your compatibility! So you need to find a sweet spot of not-too-complicated a setup and an old-enough glibc. If you know your target is always Ubuntu 16.04, then just try for a Docker container with that and see how you go.

@rvagg rvagg closed this as completed Jan 28, 2021
@mdemaredeb
Copy link
Author

Thanks for the answer! I'll have to learn to use Docker then

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

2 participants