From d80ea542a7e4b8562d002cb7aed40030681a245e Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 27 Dec 2021 09:41:00 -0500 Subject: [PATCH 1/3] src: add glibcCompiler and glibcRuntime to process.versions --- src/node_metadata.cc | 19 +++++++++++++++++++ src/node_metadata.h | 14 ++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/node_metadata.cc b/src/node_metadata.cc index d64236d9d834f5..fe2a9088747b6e 100644 --- a/src/node_metadata.cc +++ b/src/node_metadata.cc @@ -21,6 +21,10 @@ #include #endif +#if defined(__GLIBC__) && !defined(__UCLIBC__) +#include /* gnu_get_libc_version() */ +#endif + #ifdef NODE_HAVE_I18N_SUPPORT #include #include @@ -99,6 +103,21 @@ Metadata::Versions::Versions() { openssl = GetOpenSSLVersion(); #endif +#ifdef __GLIBC__ + glibcCompiler = __GLIBC__ + "." + __GLIBC_MINOR__; +#endif /* __GLIBC__ */ + +#ifndef _WIN32 +#ifdef RTLD_DEFAULT + const char* (*libc_version)(); + *(reinterpret_cast(&libc_version)) = + dlsym(RTLD_DEFAULT, "gnu_get_libc_version"); + if (libc_version != nullptr) { + glibcRuntime = (*libc_version)(); + } +#endif /* RTLD_DEFAULT */ +#endif /* _WIN32 */ + #ifdef NODE_HAVE_I18N_SUPPORT icu = U_ICU_VERSION; unicode = U_UNICODE_VERSION; diff --git a/src/node_metadata.h b/src/node_metadata.h index b7cacae4c3d430..8f72f9a464469f 100644 --- a/src/node_metadata.h +++ b/src/node_metadata.h @@ -45,6 +45,18 @@ namespace node { #define NODE_VERSIONS_KEY_CRYPTO(V) #endif +#ifdef __GLIBC__ +#define NODE_VERSIONS_KEY_GLIBC_COMPILER(V) V(glibcCompiler) +#else +#define NODE_VERSIONS_KEY_GLIBC_COMPILER(V) +#endif /* __GLIBC__ */ + +#ifndef _WIN32 +#define NODE_VERSIONS_KEY_GLIBC_RUNTIME(V) V(glibcRuntime) +#else +#define NODE_VERSIONS_KEY_GLIBC_RUNTIME(V) +#endif /* _WIN32 */ + #ifdef NODE_HAVE_I18N_SUPPORT #define NODE_VERSIONS_KEY_INTL(V) \ V(cldr) \ @@ -66,6 +78,8 @@ namespace node { #define NODE_VERSIONS_KEYS(V) \ NODE_VERSIONS_KEYS_BASE(V) \ NODE_VERSIONS_KEY_CRYPTO(V) \ + NODE_VERSIONS_KEY_GLIBC_COMPILER(V) \ + NODE_VERSIONS_KEY_GLIBC_RUNTIME(V) \ NODE_VERSIONS_KEY_INTL(V) \ NODE_VERSIONS_KEY_QUIC(V) From 3f55827cd06da5b8714002060deb7cb96d21b401 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 27 Dec 2021 18:36:31 -0500 Subject: [PATCH 2/3] fix: stringify concat per addaleax Co-authored-by: Anna Henningsen --- src/node_metadata.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/node_metadata.cc b/src/node_metadata.cc index fe2a9088747b6e..2b5432a5b419f7 100644 --- a/src/node_metadata.cc +++ b/src/node_metadata.cc @@ -104,7 +104,10 @@ Metadata::Versions::Versions() { #endif #ifdef __GLIBC__ - glibcCompiler = __GLIBC__ + "." + __GLIBC_MINOR__; + glibcCompiler = + NODE_STRINGIFY(__GLIBC__) + "." + NODE_STRINGIFY(__GLIBC_MINOR__); #endif /* __GLIBC__ */ #ifndef _WIN32 From b62a6c020680f59fc750900755359ff4935206d1 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 27 Dec 2021 19:09:54 -0500 Subject: [PATCH 3/3] fix: remove unused header --- src/node_metadata.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/node_metadata.cc b/src/node_metadata.cc index 2b5432a5b419f7..e16fa8c1f0e02a 100644 --- a/src/node_metadata.cc +++ b/src/node_metadata.cc @@ -21,10 +21,6 @@ #include #endif -#if defined(__GLIBC__) && !defined(__UCLIBC__) -#include /* gnu_get_libc_version() */ -#endif - #ifdef NODE_HAVE_I18N_SUPPORT #include #include