Skip to content

bazel/pigz: Build pigz against zlib-ng - #5606

Merged
phlax merged 1 commit into
envoyproxy:mainfrom
phlax:pigz-zlib-ng
Nov 14, 2026
Merged

phlax merged 1 commit into
envoyproxy:mainfrom
phlax:pigz-zlib-ng

Conversation

@phlax

@phlax phlax commented Nov 14, 2026

Copy link
Copy Markdown
Member

Build the published pigz (and toolshed's source toolchain) against zlib-ng, zlib-compatible, in place of zlib: faster compression at the same level, with standard gzip output.

pigz is a dev dependency, so the override applies only to toolshed's own builds (the packages, and its tests): a patch to the pigz module's binary deps, to the canonical @@zlib-ng+//:zlib - the patched module still depends on zlib in the module graph, so @zlib-ng is not visible from it. bazel query confirms zlib-ng's is the only zlib library pigz links.

The packages ship zlib-ng's license (share/doc/zlib-ng/LICENSE.md) in place of zlib's; the package test checks it.

Being measured in envoy-ci-staging (envoy's release image layers).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the pigz migration to zlib-ng.

No open issues 🎉

What changed in this PR

Switches toolshed’s published pigz binaries and source toolchain from zlib to zlib-ng, aiming to improve compression speed while preserving standard gzip output.

Changes:

  • Adds a development-only zlib-ng dependency and patches pigz to link against it.
  • Replaces the packaged zlib license with zlib-ng’s license and updates package assertions.
  • Updates documentation and refreshes Bazel lockfile metadata.
File Description
bazel/​pigz/​test/​assert_pigz_package.sh Checks for the zlib-ng license and updates the static-linking comment.
bazel/​pigz/​source/​BUILD Packages the zlib-ng license.
bazel/​pigz/​README.md Documents zlib-ng linkage and package contents.
bazel/​pigz/​private/​pigz-zlib-ng.patch Redirects pigz’s zlib dependency to zlib-ng.
bazel/​pigz/​private/​licenses/​zlib-ng Adds the zlib-ng license notice.
bazel/​pigz/​private/​licenses/​zlib Removes the replaced zlib license notice.
bazel/​pigz/​private/​BUILD Exports the new license and dependency patch.
bazel/​MODULE.bazel.lock Records zlib-ng metadata and refreshes cached repository specifications.
bazel/​MODULE.bazel Adds zlib-ng and applies the pigz module patch.

Review effort: Balanced

Build the published pigz (and toolshed's source toolchain) against
zlib-ng, zlib-compatible, in place of zlib: faster compression at the
same level, with standard gzip output.

pigz is a dev dependency, so the override (a patch to the `pigz`
module's binary, to the canonical `@@zlib-ng+//:zlib`, as the patched
module still depends on `zlib`) applies only to toolshed's own builds:
the packages, and its tests. The packages ship zlib-ng's license in
place of zlib's.

Signed-off-by: Ryan Northey <[email protected]>
@phlax
phlax merged commit 9094b93 into envoyproxy:main Nov 14, 2026
56 checks passed
phlax added a commit to phlax/toolshed that referenced this pull request Nov 17, 2026
Build the published pigz (and toolshed's source toolchain) against
zlib-ng, zlib-compatible, in place of zlib: faster compression at the
same level, with standard gzip output.

pigz is a dev dependency, so the override (a patch to the `pigz`
module's binary, to the canonical `@@zlib-ng+//:zlib`, as the patched
module still depends on `zlib`) applies only to toolshed's own builds:
the packages, and its tests. The packages ship zlib-ng's license in
place of zlib's.

Backport note (workspace): the build is on `main`: this takes its prebuilts (bins v0.2.34).

(cherry picked from commit 9094b93)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/toolshed that referenced this pull request Nov 17, 2026
Build the published pigz (and toolshed's source toolchain) against
zlib-ng, zlib-compatible, in place of zlib: faster compression at the
same level, with standard gzip output.

pigz is a dev dependency, so the override (a patch to the `pigz`
module's binary, to the canonical `@@zlib-ng+//:zlib`, as the patched
module still depends on `zlib`) applies only to toolshed's own builds:
the packages, and its tests. The packages ship zlib-ng's license in
place of zlib's.

Backport note (workspace): the build is on `main`, so only the description of the prebuilts changes here.

(cherry picked from commit 9094b93)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/toolshed that referenced this pull request Nov 17, 2026
Build the published pigz (and toolshed's source toolchain) against
zlib-ng, zlib-compatible, in place of zlib: faster compression at the
same level, with standard gzip output.

pigz is a dev dependency, so the override (a patch to the `pigz`
module's binary, to the canonical `@@zlib-ng+//:zlib`, as the patched
module still depends on `zlib`) applies only to toolshed's own builds:
the packages, and its tests. The packages ship zlib-ng's license in
place of zlib's.

Backport note (workspace): the build is on `main`, so only the description of the prebuilts changes here.

(cherry picked from commit 9094b93)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/toolshed that referenced this pull request Nov 17, 2026
`//pigz` is pigz (parallel gzip) resolved for the platform it runs on,
for use as a tool, eg as the `compressor` of a `pkg_tar`, to gzip with
all the cores. It resolves `//pigz:toolchain_type`, in order:

- the prebuilt toolchains (`pigz_prebuilt_extension`), from the bins
  release's `pigz-<version>-linux-{x86_64,aarch64}.tar.zst`;
- a source toolchain, if the consumer registers one (the README shows
  how);
- otherwise a fallback toolchain, with which `//pigz` fails with a
  message, rather than building pigz.

toolshed builds the `pigz` module only as a dev dependency (for the
packages, and as the source toolchain of its own tests), so consumers
never fetch and compile pigz unless they ask to.

The toolchains match on `target_compatible_with`: as a tool, in the
exec configuration, the target platform is the one pigz runs on.

The bins release builds the packages (`//pigz/source:pigz_packages`):
the binary built against the glibc 2.31 sysroot and stripped, with the
pigz, zlib and zopfli licenses; the release preparation sets
`VERSIONS["pigz_sha256"]` from it. Tests check the packages (layout,
modes, stripping, arch, runtime deps, glibc floor), a compress /
decompress roundtrip with the resolved and source binaries (also on
macOS), the hub rendering, and the failure without a pigz for the
platform.

Backport note (workspace): the toolchain and the prebuilt repositories only, set up with
`setup_pigz()` and `load_pigz_toolchains()` (`//pigz:repositories.bzl`) in place of the
module extension. The source build and its packaging stay on `main`, which publishes the
prebuilts. Their hashes are empty, as here on `main`, for the release preparation to set:
until then `//pigz` and its test are `manual`, as this branch has no source toolchain. The
README describes the prebuilts as `main` now publishes them (against zlib-ng, envoyproxy#5606).

(cherry picked from commit fc8e06e)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/toolshed that referenced this pull request Nov 17, 2026
`//pigz` is pigz (parallel gzip) resolved for the platform it runs on,
for use as a tool, eg as the `compressor` of a `pkg_tar`, to gzip with
all the cores. It resolves `//pigz:toolchain_type`, in order:

- the prebuilt toolchains (`pigz_prebuilt_extension`), from the bins
  release's `pigz-<version>-linux-{x86_64,aarch64}.tar.zst`;
- a source toolchain, if the consumer registers one (the README shows
  how);
- otherwise a fallback toolchain, with which `//pigz` fails with a
  message, rather than building pigz.

toolshed builds the `pigz` module only as a dev dependency (for the
packages, and as the source toolchain of its own tests), so consumers
never fetch and compile pigz unless they ask to.

The toolchains match on `target_compatible_with`: as a tool, in the
exec configuration, the target platform is the one pigz runs on.

The bins release builds the packages (`//pigz/source:pigz_packages`):
the binary built against the glibc 2.31 sysroot and stripped, with the
pigz, zlib and zopfli licenses; the release preparation sets
`VERSIONS["pigz_sha256"]` from it. Tests check the packages (layout,
modes, stripping, arch, runtime deps, glibc floor), a compress /
decompress roundtrip with the resolved and source binaries (also on
macOS), the hub rendering, and the failure without a pigz for the
platform.

Backport note (workspace): the toolchain and the prebuilt repositories only, set up with
`setup_pigz()` and `load_pigz_toolchains()` (`//pigz:repositories.bzl`) in place of the
module extension. The source build and its packaging stay on `main`, which publishes the
prebuilts. Their hashes are empty, as here on `main`, for the release preparation to set:
`//pigz` is `manual`, as this branch has no source toolchain (so no pigz without a prebuilt
for the platform), and its test until then. `repository_ctx.repo_metadata` is only called
where Bazel has it: Envoy's `release/v1.38` and earlier use Bazel 7. The
README describes the prebuilts as `main` now publishes them (against zlib-ng, envoyproxy#5606).

(cherry picked from commit fc8e06e)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/toolshed that referenced this pull request Nov 17, 2026
…allow the libcxx LLVM version to be set

Port `//oci` (`oci_base_edit`), `//pigz` and `//tarball:compressed_tar.bzl` from `main` at
bazel-v0.5.22, so Envoy's WORKSPACE release branches (`release/v1.39` and earlier) can build their
release container images with rules_oci and gzip the packages with all the cores, as `main` and
`release/v1.40` do.

Backported, with what differs from `main`:

- envoyproxy#5597 `oci_base_edit`: as on `main`.
- envoyproxy#5601 hermetic pigz: the toolchain and the prebuilt repositories only. `setup_pigz()` and
`load_pigz_toolchains()` (`//pigz:repositories.bzl`) replace the module extension, as `//pgp` does
for `sq`, and this repo's `WORKSPACE` calls both. The source build and its packaging stay on
`main`, which publishes the prebuilts. The README describes them as `main` now builds them (against
zlib-ng, envoyproxy#5606, which has nothing else to backport here). `repository_ctx.repo_metadata` is only
called where Bazel has it: Envoy's `release/v1.38` and earlier use Bazel 7.
- envoyproxy#5605 a pigz on the host, by path: `setup_pigz(host_path = ...)`. The prebuilts are not
configurable here, so a prebuilt for the host always takes precedence.
- envoyproxy#5607 `compressed_tar`: as on `main`. zstd uses the consumer's `@zstd` (Envoy has one; this
branch's toolshed does not), so only gzip is tested here, on Linux only.

Also, not a backport: `setup_libcxx_libs(llvm_version = ...)`. The libc++ bundles for
cross-compiling are fetched for toolshed's LLVM (22.1.8), but Envoy's `release/v1.39` and earlier
compile with LLVM 18.1.8, so a cross-compile there (arm64 from x64, as the one-job release build
does) gets LLVM 18's headers with LLVM 22's `__config_site` and fails. The option selects the
bundles of the consumer's LLVM, from the bins release that published them (0.1.59 for 18.1.8).

The prebuilt hashes (`VERSIONS["pigz_sha256"]`) are empty, as in envoyproxy#5601, for the release preparation
to set: the `_release.yml` step that does that comes with envoyproxy#5601 too. This branch has no source
toolchain to fall back to, so `//pigz` is `manual` (there is no pigz without a prebuilt for the
platform), and the tests that run it are `manual` until the hashes are set.

(cherry picked from commit 0dbd94a)
(cherry picked from commit fc8e06e)
(cherry picked from commit 77185d7)
(cherry picked from commit 49947f3)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit that referenced this pull request Nov 17, 2026
`//pigz` is pigz (parallel gzip) resolved for the platform it runs on,
for use as a tool, eg as the `compressor` of a `pkg_tar`, to gzip with
all the cores. It resolves `//pigz:toolchain_type`, in order:

- the prebuilt toolchains (`pigz_prebuilt_extension`), from the bins
  release's `pigz-<version>-linux-{x86_64,aarch64}.tar.zst`;
- a source toolchain, if the consumer registers one (the README shows
  how);
- otherwise a fallback toolchain, with which `//pigz` fails with a
  message, rather than building pigz.

toolshed builds the `pigz` module only as a dev dependency (for the
packages, and as the source toolchain of its own tests), so consumers
never fetch and compile pigz unless they ask to.

The toolchains match on `target_compatible_with`: as a tool, in the
exec configuration, the target platform is the one pigz runs on.

The bins release builds the packages (`//pigz/source:pigz_packages`):
the binary built against the glibc 2.31 sysroot and stripped, with the
pigz, zlib and zopfli licenses; the release preparation sets
`VERSIONS["pigz_sha256"]` from it. Tests check the packages (layout,
modes, stripping, arch, runtime deps, glibc floor), a compress /
decompress roundtrip with the resolved and source binaries (also on
macOS), the hub rendering, and the failure without a pigz for the
platform.

Backport note (workspace): the toolchain and the prebuilt repositories only, set up with
`setup_pigz()` and `load_pigz_toolchains()` (`//pigz:repositories.bzl`) in place of the
module extension. The source build and its packaging stay on `main`, which publishes the
prebuilts. Their hashes are empty, as here on `main`, for the release preparation to set:
`//pigz` is `manual`, as this branch has no source toolchain (so no pigz without a prebuilt
for the platform), and its test until then. `repository_ctx.repo_metadata` is only called
where Bazel has it: Envoy's `release/v1.38` and earlier use Bazel 7. The
README describes the prebuilts as `main` now publishes them (against zlib-ng, #5606).

(cherry picked from commit fc8e06e)
Signed-off-by: Ryan Northey <[email protected]>
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