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

Runtime information about libc version and type #39877

Closed
Brooooooklyn opened this issue Aug 25, 2021 · 8 comments
Closed

Runtime information about libc version and type #39877

Brooooooklyn opened this issue Aug 25, 2021 · 8 comments
Labels
feature request Issues that request new features to be added to Node.js. stale

Comments

@Brooooooklyn
Copy link

Is your feature request related to a problem? Please describe.

I need to dectect the libc version and type on Linux systems to determined which native addon I need to load.

The most common ways in Node.js to do such things is using the detect-libc package, which is actully invoke shell scripts and try to read messages in the stdout, not elegant at all.

The other way is using try ... catch on Linux:

try {
  return require('my-native-addon.x64-linux-gnu.node')
} catch {
  return require('my-native-addon.x64-linux-musl.node')
}

not elegant either and more complicated.

Describe the solution you'd like

I want get libc information on process.versions directly, like:

console.log(process.versions.libc)

{
  family: 'glibc',
  version: '2.24'
}

For the other systems don't need to consider about libc problem, just leave the fields as null.

@richardlau
Copy link
Member

FWIW we do attempt to determine glibc versions (compile and runtime versions) for inclusion in a diagnostics report

node/src/node_report.cc

Lines 363 to 376 in 99a3d55

#ifndef _WIN32
// Report compiler and runtime glibc versions where possible.
const char* (*libc_version)();
*(reinterpret_cast<void**>(&libc_version)) =
dlsym(RTLD_DEFAULT, "gnu_get_libc_version");
if (libc_version != nullptr)
writer->json_keyvalue("glibcVersionRuntime", (*libc_version)());
#endif /* _WIN32 */
#ifdef __GLIBC__
buf << __GLIBC__ << "." << __GLIBC_MINOR__;
writer->json_keyvalue("glibcVersionCompiler", buf.str());
buf.str("");
#endif

    glibcVersionRuntime: '2.28',
    glibcVersionCompiler: '2.17'

@mhdawson
Copy link
Member

@Brooooooklyn this seems like a small addition and reasonable to me at first glance. The best way to move forward is likely to submit a PR. Is that something you can do?

@Brooooooklyn
Copy link
Author

@mhdawson I will try it

@styfle
Copy link
Member

styfle commented Nov 9, 2021

We're experiencing the optionalDependenices issue with Next.js and I think this process.versions.libc proposal would be a great solution!

@Brooooooklyn Did you start working on this yet? I can try an help out if needed. The npm team (@MylesBorins) is also interested in this solution 🙂

@Brooooooklyn
Copy link
Author

@styfle not yet, I'm busy on the napi-rs 2.0, feel free to start this one

@styfle
Copy link
Member

styfle commented Dec 27, 2021

I created PR #41338 but it needs some work.

I'm unsure if this information is sufficient to solve the related npm install issue since you would likely need to detect musl too.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 4, 2022

There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Jul 4, 2022
@juanarbol
Copy link
Member

Based on #41338 this seems to be resolved.

I'm proceeding to close this, but feel free to re-open if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. stale
Projects
Development

Successfully merging a pull request may close this issue.

8 participants
@styfle @Brooooooklyn @richardlau @Ayase-252 @mhdawson @juanarbol and others