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

src: fix dynamically linked zlib version #51007

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

richardlau
Copy link
Member

Report the version of the dynamically linked zlib if built with configure --shared-zlib instead of the hardcoded version that corresponds to the bundled version of zlib in deps.

Refs: #50910 (comment)
Refs: #50158


This should unblock #50910 by fixing the regression caused by #50158.

Report the version of the dynamically linked zlib if built with
`configure --shared-zlib` instead of the hardcoded version that
corresponds to the bundled version of zlib in `deps`.
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/gyp

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Dec 1, 2023
@richardlau richardlau added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 1, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 1, 2023
@nodejs-github-bot
Copy link
Collaborator

@richardlau
Copy link
Member Author

richardlau commented Dec 1, 2023

So this fixes the immediate bug -- prior to this PR process.versions.zlib would incorrectly report 1.2.13.1-motley-5daffc7 which is the value in src/zlib_version.h that was set the last time deps/zlib was updated.

One interesting observation is that, after building with --shared-zlib if I run with a different (but ABI compatible) version of zlib, process.versions still reports the version linked against but process.report.getReport().header.componentVersions shows the expected version.
e.g.

iojs@bd40e8f13f4d:/node$ LD_LIBRARY_PATH=/opt/zlib_1.2.12/lib/ ./node -p process.config.target_defaults
{
  cflags: [],
  default_configuration: 'Release',
  defines: [
    'NODE_OPENSSL_CONF_NAME=nodejs_conf',
    'NODE_OPENSSL_HAS_QUIC',
    'ICU_NO_USER_DATA_OVERRIDE'
  ],
  include_dirs: [ '/opt/zlib_1.2.12/include/' ],
  libraries: [ '-L/opt/zlib_1.2.12/lib/', '-lz' ]
}
iojs@bd40e8f13f4d:/node$ LD_LIBRARY_PATH=/opt/zlib_1.2.12/lib/ ./node -p process.versions.zlib
1.2.12
iojs@bd40e8f13f4d:/node$ LD_LIBRARY_PATH=/opt/zlib_1.2.12/lib/ ./node -p "process.report.getReport().header.componentVersions.zlib"
1.2.12
iojs@bd40e8f13f4d:/node$ LD_LIBRARY_PATH=/opt/zlib_1.2.12/lib/ ./node -p "process.report.getReport().sharedObjects"
[
  'linux-vdso.so.1',
  '/opt/zlib_1.2.12/lib/libz.so.1',
  '/lib/x86_64-linux-gnu/libdl.so.2',
  '/lib/x86_64-linux-gnu/libstdc++.so.6',
  '/lib/x86_64-linux-gnu/libm.so.6',
  '/lib/x86_64-linux-gnu/libgcc_s.so.1',
  '/lib/x86_64-linux-gnu/libpthread.so.0',
  '/lib/x86_64-linux-gnu/libc.so.6',
  '/lib64/ld-linux-x86-64.so.2'
]
iojs@bd40e8f13f4d:/node$

which so far is consistent, but when changing LD_LIBRARY_PATH to pick up a different version of zlib (1.2.11):

iojs@bd40e8f13f4d:/node$ LD_LIBRARY_PATH=/lib/x86_64-linux-gnu/ ./node -p process.versions.zlib
1.2.12
iojs@bd40e8f13f4d:/node$ LD_LIBRARY_PATH=/lib/x86_64-linux-gnu/ ./node -p "process.report.getReport().header.componentVersions.zlib"
1.2.11
iojs@bd40e8f13f4d:/node$ LD_LIBRARY_PATH=/lib/x86_64-linux-gnu/ ./node -p "process.report.getReport().sharedObjects"
[
  'linux-vdso.so.1',
  '/lib/x86_64-linux-gnu/libz.so.1',
  '/lib/x86_64-linux-gnu/libdl.so.2',
  '/lib/x86_64-linux-gnu/libstdc++.so.6',
  '/lib/x86_64-linux-gnu/libm.so.6',
  '/lib/x86_64-linux-gnu/libgcc_s.so.1',
  '/lib/x86_64-linux-gnu/libpthread.so.0',
  '/lib/x86_64-linux-gnu/libc.so.6',
  '/lib64/ld-linux-x86-64.so.2'
]
iojs@bd40e8f13f4d:/node$

i.e. process.report seems to be correct but process.versions is not. Are the versions in process.versions coming from the snapshot? cc @joyeecheung

@kapouer
Copy link
Contributor

kapouer commented Dec 1, 2023

@richardlau serendipitously, I have a similar problem, as a distributor, when embedding builtins from system source at build time (the ones officially supported + the ones I added manually, acorn &al).
For example at build time I do this ugly stuff.

@joyeecheung
Copy link
Member

Yes I think process.versions is captured in the snapshot at build time. If this needs to be dynamic (or any other) I think we can just reset the versions at pre-execution (something like if the process.config indicates that some library is dynamically linked, reset the version retrieved from C++ land)

@richardlau richardlau added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 3, 2023
Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mhdawson mhdawson added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 4, 2023
@richardlau richardlau added commit-queue Add this label to land a pull request using GitHub Actions. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Dec 4, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 4, 2023
@nodejs-github-bot nodejs-github-bot merged commit 7b3eb31 into nodejs:main Dec 4, 2023
69 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 7b3eb31

@richardlau richardlau deleted the zlibver branch December 5, 2023 17:33
RafaelGSS pushed a commit that referenced this pull request Dec 15, 2023
Report the version of the dynamically linked zlib if built with
`configure --shared-zlib` instead of the hardcoded version that
corresponds to the bundled version of zlib in `deps`.

PR-URL: #51007
Refs: #50910
Refs: #50158
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
@RafaelGSS RafaelGSS mentioned this pull request Dec 15, 2023
richardlau added a commit that referenced this pull request Mar 25, 2024
Report the version of the dynamically linked zlib if built with
`configure --shared-zlib` instead of the hardcoded version that
corresponds to the bundled version of zlib in `deps`.

PR-URL: #51007
Refs: #50910
Refs: #50158
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
@richardlau richardlau mentioned this pull request Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. build Issues and PRs related to build files or the CI. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants