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

deps: delete deps/zlib #47157

Closed
wants to merge 3 commits into from
Closed

deps: delete deps/zlib #47157

wants to merge 3 commits into from

Conversation

kvakil
Copy link
Contributor

@kvakil kvakil commented Mar 19, 2023

We currently have two copies of Chromium's zlib: one in deps/zlib and another in deps/v8/third_party/zlib. This has a couple of disadvantages:

  1. There is an additional cost to keeping both dependencies up-to-date, and in fact they were already out-of-sync (see the refs).
  2. People who compile with --shared-zlib (i.e. distro maintainers) will probably not be thrilled to learn that there is still a copy of zlib inside.
  3. It's aesthetically unpleasing.

Centralize on the version in V8 rather than the one in deps, and delete the one in deps. Basically I just copied deps/zlib/zlib.gyp to tools/v8_gypfiles/zlib.gyp, since the former had a better build configuration (see the refs). This approach seemed better than the opposite approach of centralizing on deps/zlib because:

  1. We would need to occasionally bump deps/zlib manually after bumping deps/v8, which seemed annoying.
  2. The maintenance steps for bumping zlib seemed more onerous than the maintenance steps for bumping V8.

(If we would prefer the opposite approach, I actually have another patch locally.)

One discrepancy was that V8's version of zlib had all symbols to be prefixed with Cr_z_ per deps/v8/third_party/zlib/chromeconf.h, which seemed undesirable, so I added define CHROMIUM_ZLIB_NO_CHROMECONF to the build to remove it. (deps/zlib handled this by just commenting out the relevant include, but floating a patch seemed less desirable.)

I tested this on Linux with the default build and a --shared-zlib build. I checked that the shared-zlib build correctly linked zlib according to ldd. I would appreciate if the reviewers could suggest some other build configurations to try.

Refs: #47145
Refs: #47151

We currently have two copies of Chromium's zlib: one in deps/zlib and
another in deps/v8/third_party/zlib. This has a couple of disadvantages:

1. There is an additional cost to keeping both dependencies up-to-date,
    and in fact they were already out-of-sync (see the refs).
2. People who compile with --shared-zlib (i.e. distro maintainers) will
   probably not be thrilled to learn that there is still a copy of zlib
   inside.
3. It's aesthetically unpleasing.

Centralize on the version in V8 rather than the one in deps, and delete
the one in deps. Basically I just copied deps/zlib/zlib.gyp to
tools/v8_gypfiles/zlib.gyp, since the former had a better build
configuration (see the refs). This approach seemed better than the
opposite approach of centralizing on deps/zlib because:

1. We would need to occasionally bump deps/zlib manually after bumping
   deps/v8, which seemed annoying.
2. The maintenance steps for bumping zlib seemed more onerous than the
   maintenance steps for bumping V8.

(If we would prefer the opposite approach, I actually have another patch
 locally.)

One discrepancy was that V8's version of zlib had all symbols to be
prefixed with `Cr_z_` per deps/v8/third_party/zlib/chromeconf.h, which
seemed undesirable, so I added define `CHROMIUM_ZLIB_NO_CHROMECONF`
to the build to remove it. (deps/zlib handled this by just commenting
out the relevant include, but floating a patch seemed less desirable.)

I tested this on Linux with the default build and a --shared-zlib build.
I checked that the shared-zlib build correctly linked zlib according to
ldd. I would appreciate if the reviewers could suggest some other build
configurations to try.

Refs: nodejs#47145
Refs: nodejs#47151
@nodejs-github-bot nodejs-github-bot added dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run. zlib Issues and PRs related to the zlib subsystem. labels Mar 19, 2023
@kvakil kvakil marked this pull request as draft March 19, 2023 03:18
@kvakil kvakil marked this pull request as ready for review March 19, 2023 03:26
@kvakil
Copy link
Contributor Author

kvakil commented Mar 19, 2023

I wasn't sure what to do with deps/zlib/win32/zlib.def so I just left it there. Maybe it makes more sense to put it in deps/v8/third_party/zlib/win32/zlib.def instead?

@lpinca
Copy link
Member

lpinca commented Mar 19, 2023

  1. Can we update zlib without updating V8?
  2. Can we backport updates and security fixes to the earlier release lines without updating V8?

@nodejs-github-bot
Copy link
Collaborator

@kvakil
Copy link
Contributor Author

kvakil commented Mar 19, 2023

  1. Can we update zlib without updating V8?

    1. Can we backport updates and security fixes to the earlier release lines without updating V8?

We could cherry-pick the update patch like we do for adhoc V8 patches. In practice the changes to deps/zlib look pretty small & independent so I don't think it'd be difficult to backport a patch across release lines. I don't think this new approach causes any new ABI compatibility concerns.

(Also, how do we deal with zlib security fixes today? My assumption is that we're currently just updating the copy in deps/zlib and not updating the one in deps/v8/third_party/zlib. If we already have a process in place for updating deps/v8/third_party/zlib, then we can just use that going forward, it's strictly less work than before.)

@kvakil
Copy link
Contributor Author

kvakil commented Mar 19, 2023

The remaining failing test is caused by addons/zlib-binding/binding.gyp having the include path ../../../deps/zlib. I could update that path obviously, but does that make this change semver-major, since it would break addons which didn't update?

'include_dirs': ['../../../deps/zlib'],

@bnoordhuis
Copy link
Member

I'd do it the other way around. deps/zlib is what backs the built-in zlib module. We don't want to change that to whatever random zlib fork V8 is using today.

The flip side - V8 now depending on deps/zlib - should be a lot less problematic. V8 doesn't really do anything out of the ordinary with zlib. (I may be wrong about that but I don't think so.)

@kvakil
Copy link
Contributor Author

kvakil commented Mar 19, 2023

I'd do it the other way around. deps/zlib is what backs the built-in zlib module. We don't want to change that to whatever random zlib fork V8 is using today.

OK, I'll put up the PR which does the opposite of this PR later today. FWIW deps/zlib and V8's zlib are the same codebase -- they're both Chromium's fork of zlib. This is more of a question of maintenance & upgrades rather than what code we're running.

kvakil added a commit to kvakil/node that referenced this pull request Apr 10, 2023
We currently have two copies of Chromium's zlib: one in deps/zlib and
another in deps/v8/third_party/zlib. This has a couple of disadvantages:

1. There is an additional cost to keeping both dependencies up-to-date,
   and in fact they were already out-of-sync (see the refs).

2. People who compile with --shared-zlib (i.e. distro maintainers) will
   probably not be thrilled to learn that there is still a copy of zlib
   inside.

3. It's aesthetically unpleasing.

This diff (per discussion in the refs) centralizes on deps/zlib and
deletes deps/v8/third_party/zlib. That requires changing the include
headers in two files in deps/v8/src, which was pretty straightforward.

When the user requests compiling with a shared zlib build, we still need
to compile the contents of deps/zlib/google. This is not ideal but it's
also not a change in behavior: prior to this diff those files were
being compiled in the deps/v8/third_party/zlib version.

I tested this on Linux with the default build and a --shared-zlib build.
I checked that the shared-zlib build dynamically linked zlib according
to ldd, and that the regular build did not. I would appreciate if the
reviewers could suggest some other build configurations to try.

Refs: nodejs#47145
Refs: nodejs#47157
kvakil added a commit to kvakil/node that referenced this pull request Apr 10, 2023
We currently have two copies of Chromium's zlib: one in deps/zlib and
another in deps/v8/third_party/zlib. This has a couple of disadvantages:

1. There is an additional cost to keeping both dependencies up-to-date,
   and in fact they were already out-of-sync (see the refs).

2. People who compile with --shared-zlib (i.e. distro maintainers) will
   probably not be thrilled to learn that there is still a copy of zlib
   inside.

3. It's aesthetically unpleasing.

This diff (per discussion in the refs) centralizes on deps/zlib and
deletes deps/v8/third_party/zlib. That requires changing the include
headers in two files in deps/v8/src, which was pretty straightforward.

When the user requests compiling with a shared zlib build, we still need
to compile the contents of deps/zlib/google. This is not ideal but it's
also not a change in behavior: prior to this diff those files were
being compiled in the deps/v8/third_party/zlib version.

I tested this on Linux with the default build and a --shared-zlib build.
I checked that the shared-zlib build dynamically linked zlib according
to ldd, and that the regular build did not. I would appreciate if the
reviewers could suggest some other build configurations to try.

Refs: nodejs#47145
Refs: nodejs#47157
kvakil added a commit to kvakil/node that referenced this pull request Apr 10, 2023
We currently have two copies of Chromium's zlib: one in deps/zlib and
another in deps/v8/third_party/zlib. This has a couple of disadvantages:

1. There is an additional cost to keeping both dependencies up-to-date,
   and in fact they were already out-of-sync (see the refs).

2. People who compile with --shared-zlib (i.e. distro maintainers) will
   probably not be thrilled to learn that there is still a copy of zlib
   inside.

3. It's aesthetically unpleasing.

This diff (per discussion in the refs) centralizes on deps/zlib and
deletes deps/v8/third_party/zlib. That requires changing the include
headers in two files in deps/v8/src, which was pretty straightforward.

When the user requests compiling with a shared zlib build, we still need
to compile the contents of deps/zlib/google. This is not ideal but it's
also not a change in behavior: prior to this diff those files were
being compiled in the deps/v8/third_party/zlib version.

I tested this on Linux with the default build and a --shared-zlib build.
I checked that the shared-zlib build dynamically linked zlib according
to ldd, and that the regular build did not. I would appreciate if the
reviewers could suggest some other build configurations to try.

Refs: nodejs#47145
Refs: nodejs#47157
kvakil added a commit to kvakil/node that referenced this pull request Jun 22, 2023
We currently have two copies of Chromium's zlib: one in deps/zlib and
another in deps/v8/third_party/zlib. This has a couple of disadvantages:

1. There is an additional cost to keeping both dependencies up-to-date,
   and in fact they were already out-of-sync (see the refs).

2. People who compile with --shared-zlib (i.e. distro maintainers) will
   probably not be thrilled to learn that there is still a copy of zlib
   inside.

3. It's aesthetically unpleasing.

This diff (per discussion in the refs) centralizes on deps/zlib and
deletes deps/v8/third_party/zlib. That requires changing the include
headers in two files in deps/v8/src, which was pretty straightforward.

When the user requests compiling with a shared zlib build, we still need
to compile the contents of deps/zlib/google. This is not ideal but it's
also not a change in behavior: prior to this diff those files were
being compiled in the deps/v8/third_party/zlib version.

I tested this on Linux with the default build and a --shared-zlib build.
I checked that the shared-zlib build dynamically linked zlib according
to ldd, and that the regular build did not. I would appreciate if the
reviewers could suggest some other build configurations to try.

Refs: nodejs#47145
Refs: nodejs#47157
kvakil added a commit to kvakil/node that referenced this pull request Jun 22, 2023
This is the first of a series of patches. This patch is contains changes
to the existing zlib.gyp file to allow it to be used by our v8.gyp.

---

We currently have two copies of Chromium's zlib: one in deps/zlib and
another in deps/v8/third_party/zlib. This has a couple of disadvantages:

1. There is an additional cost to keeping both dependencies up-to-date,
   and in fact they were already out-of-sync (see the refs).

2. People who compile with --shared-zlib (i.e. distro maintainers) will
   probably not be thrilled to learn that there is still a copy of zlib
   inside.

3. It's aesthetically unpleasing.

This diff (per discussion in the refs) centralizes on deps/zlib and
deletes deps/v8/third_party/zlib.

When the user requests compiling with a shared zlib build, we still need
to compile the contents of deps/zlib/google. This is not ideal but it's
also not a change in behavior: prior to this diff those files were
being compiled in the deps/v8/third_party/zlib version.

I tested this on Linux with the default build and a --shared-zlib build.
I checked that the shared-zlib build dynamically linked zlib according
to ldd, and that the regular build did not. I would appreciate if the
reviewers could suggest some other build configurations to try.

Refs: nodejs#47145
Refs: nodejs#47157
@kvakil
Copy link
Contributor Author

kvakil commented Jun 22, 2023

Closing for #47493. In addition this issue is sort of already fixed on the V8 side by https://chromium-review.googlesource.com/c/v8/v8/+/4571989.

@kvakil kvakil closed this Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run. zlib Issues and PRs related to the zlib subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants