Skip to content

Fix libc detection on various platforms #6840

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ItsHarper
Copy link

@ItsHarper ItsHarper commented Jul 1, 2025

What's the problem this PR addresses?

Two problems:

  1. Improve libc presence detection #6170 broke libc detection on at least Alpine Linux and Chimera Linux (and probably on all other musl-based distributions as well) by looking for the generic string libc in /usr/bin/ldd. On both Chimera and Alpine, ldd --version prints musl libc among the output.

  2. getLibc() was doing unnecessary work on OSes other than Windows, Mac, and Linux (I originally thought it would have been crashing, but that's incorrect). It strongly appears to me that getLibc() would throw an error on any OS other than Windows, Mac, and Linux, as the other OSes supported by node have their own libc implementations that are neither glibc nor musl.
    ...

How did you fix it?

  1. The strings GNU libc and GNU C Library are searched for instead of just libc.

    • By default, ldd contains the text GNU libc in its --version output, but that can be easily customized at build time using a build configuration option (see here and here). As a fallback, the text GNU C Library is found in the header of the ldd script, and it will probably remain there as long as that file remains a script (as opposed to a compiled binary).
  2. I made getLibc() immediately return null on all non-Linux platforms (not just Windows and macOS).

...

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@ItsHarper ItsHarper changed the title Fix libc detection on some musl-based distributions Fix libc detection on musl-based Linux distributions Jul 1, 2025
@ItsHarper ItsHarper marked this pull request as draft July 1, 2025 23:19
ItsHarper added 2 commits July 1, 2025 18:39
By default, glib's version of ldd uses the text "GNU libc", but that
text is provided by the build system, so it's not guaranteed to be there
@ItsHarper ItsHarper changed the title Fix libc detection on musl-based Linux distributions Fix libc detection on various platforms Jul 1, 2025
@ItsHarper ItsHarper marked this pull request as ready for review July 2, 2025 00:07
@ItsHarper
Copy link
Author

ItsHarper commented Jul 2, 2025

As a side note, while it took a year for anyone to notice that musl support was broken, you'd only notice that it was broken when you tried to install a native package that published musl binaries separately (some of them combine them in a single package).

On the other hand, support for the Unix platforms (not counting Linux and macOS) has almost certainly been broken for 3.5 years (since #3981), and I'm pretty sure yarn was fully crashing on those systems, regardless of which packages you're installing.

Disregard, that last part, I misunderstood how that mapAndFind() code worked.

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 this pull request may close these issues.

2 participants