Skip to content

bazel: Add a hermetic pigz, with prebuilt toolchains - #5601

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

phlax merged 1 commit into
envoyproxy:mainfrom
phlax:pigz-prebuilt

Conversation

@phlax

@phlax phlax commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

//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 (envoy's release container image layers, envoyproxy/envoy#49259).

It resolves //pigz:toolchain_type, in order:

  1. the prebuilt toolchains (pigz_prebuilt_extension), from the bins release's pigz-<version>-linux-{x86_64,aarch64}.tar.zst (VERSIONS["pigz_sha256"] starts empty, until a bins release publishes them);
  2. a source toolchain, if the consumer registers one (the README shows how);
  3. otherwise a fallback toolchain, with which //pigz fails with a message.

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 (and zlib and zopfli) 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.

Mirrors //hunspell:

  • //pigz/source:pigz_packages, built and uploaded with the bins: 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 a bins release;
  • tests: the packages (layout, modes, stripping, arch, runtime deps, glibc floor), a compress / decompress roundtrip (with -n, checking the output is reproducible) with the resolved and the source binaries (also on macOS, in a macos-pigz job), the hub rendering, and the failure without a pigz for the platform (an analysis test on a Windows platform).

The lockfile also picks up extension facts that were stale on main (bins 0.2.30 -> 0.2.32).

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.

🔵 Needs a closer look

Cross-platform toolchain selection and published ELF compatibility still require Bazel/runtime validation, while empty prebuilt hashes leave the resolved-binary roundtrip covering only the source fallback.

No open issues 🎉

What changed in this PR

Adds hermetic parallel gzip compression to toolshed’s Bazel tooling through //pigz, for uses such as compressing Envoy release container layers.

Changes:

  • Adds platform-resolved pigz toolchains, preferring Linux prebuilts once release hashes are populated and otherwise building from source.
  • Integrates Linux packaging, bundled licenses, artifact uploads, and release hash updates.
  • Adds package validation, reproducible compression roundtrip tests, hub-rendering tests, and macOS CI coverage.
File Description
bazel/​versions.bzl Defines pigz version and initially empty prebuilt hashes.
bazel/​pigz/​toolchain.bzl Implements the toolchain provider and resolved executable.
bazel/​pigz/​test/​pigz_test.bzl Tests platform-specific and empty hub rendering.
bazel/​pigz/​test/​BUILD Registers toolchain, source, and package tests.
bazel/​pigz/​test/​assert_pigz_roundtrip.sh Checks reproducible compression and decompression.
bazel/​pigz/​test/​assert_pigz_package.sh Validates package layout, binaries, and runtime requirements.
bazel/​pigz/​source/​BUILD Declares source fallback toolchains and Linux packages.
bazel/​pigz/​README.md Documents consumption, package layout, and fallback behavior.
bazel/​pigz/​private/​pigz_prebuilt.bzl Downloads prebuilts and generates the toolchain hub.
bazel/​pigz/​private/​pigz_package.bzl Builds stripped, per-platform release archives.
bazel/​pigz/​private/​licenses/​zopfli Bundles the zopfli license.
bazel/​pigz/​private/​licenses/​zlib Bundles the zlib license.
bazel/​pigz/​private/​licenses/​pigz Bundles the pigz license.
bazel/​pigz/​private/​BUILD Exports packaging rules and licenses.
bazel/​pigz/​extensions.bzl Configures prebuilt repositories with hash overrides.
bazel/​pigz/​defs.bzl Exposes the public toolchain API.
bazel/​pigz/​BUILD Exposes //pigz and its toolchain type.
bazel/​MODULE.bazel.lock Records new dependencies and refreshes extension metadata.
bazel/​MODULE.bazel Adds pigz and registers prebuilt and fallback toolchains.
.github/​workflows/​bazel.yml Builds and uploads packages; adds macOS tests.
.github/​workflows/​_release.yml Populates pigz hashes from release artifacts.

Review effort: Balanced

`//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.

Signed-off-by: Ryan Northey <[email protected]>

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 hermetic pigz toolchain integration.

No open issues 🎉

Review effort: Balanced

@phlax
phlax merged commit fc8e06e into envoyproxy:main Nov 14, 2026
359 checks passed
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: pinned here to bins v0.2.33 with its own `pigz_bins_release`, as this branch's
bins release is earlier.

(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:
until then `//pigz` and its test are `manual`, as this branch has no source toolchain.

(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:
until then `//pigz` and its test are `manual`, as this branch has no source toolchain.

(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:
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