Skip to content

bazel: Backport oci, pigz and compressed_tar to WORKSPACE, and allow the libcxx LLVM version to be set - #5616

Merged
phlax merged 5 commits into
envoyproxy:workspacefrom
phlax:workspace-oci-pigz
Nov 17, 2026
Merged

phlax merged 5 commits into
envoyproxy:workspacefrom
phlax:workspace-oci-pigz

Conversation

@phlax

@phlax phlax commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

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.

One commit per original PR, each with a backport note:

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 #5601, for the release preparation to set: the _release.yml step that does that comes with #5601 too. This branch has no source toolchain to fall back to, so until the hashes are set //pigz and the tests that run it are manual.

Not built locally: this PR's CI is the first test.

@phlax
phlax requested a balanced review from Copilot November 17, 2026 11:02
@phlax
phlax force-pushed the workspace-oci-pigz branch 3 times, most recently from abcd307 to 2a8e51f Compare November 17, 2026 11:17

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.

🟡 Changes recommended

The pigz integration breaks Bazel 7.7.1 and macOS builds and can point toolchains at missing artifacts; path validation also rejects valid edits and package mappings.

7 open issues
What changed in this PR

Backports OCI base-image editing and parallel gzip packaging to support Envoy release branches that use Bazel WORKSPACE.

Changes:

  • Adds oci_base_edit to extend base-image accounts and package metadata.
  • Adds prebuilt and host pigz toolchains, WORKSPACE registration, and release hash updates.
  • Adds gzip-only compressed_tar, with fixtures and tests.
File Description
bazel/​WORKSPACE Creates and registers pigz toolchains.
bazel/​versions.bzl Adds the pigz version and prebuilt hash placeholders.
bazel/​tarball/​test/​tool.sh Provides an executable-content fixture.
bazel/​tarball/​test/​plain.txt Provides a default-attributes fixture.
bazel/​tarball/​test/​hello.txt Provides an archive-content fixture.
bazel/​tarball/​test/​compressed_tar_test.bzl Tests mtree rendering and duplicate paths.
bazel/​tarball/​test/​BUILD Defines archive fixtures and tests.
bazel/​tarball/​test/​assert_compressed_tar.sh Checks compression, metadata, layout, and contents.
bazel/​tarball/​compressed_tar.bzl Implements bsdtar-to-pigz archive creation.
bazel/​tarball/​BUILD Exports the compressed tar rule.
bazel/​pigz/​toolchain.bzl Implements pigz providers, resolution, and fallback.
bazel/​pigz/​test/​pigz_test.bzl Tests toolchain rendering and platform handling.
bazel/​pigz/​test/​BUILD Defines pigz unit and round-trip tests.
bazel/​pigz/​test/​assert_pigz_roundtrip.sh Checks reproducible compression and decompression.
bazel/​pigz/​repositories.bzl Provides WORKSPACE setup and registration helpers.
bazel/​pigz/​README.md Documents pigz setup and consumption.
bazel/​pigz/​private/​pigz_prebuilt.bzl Defines prebuilt repositories and host-toolchain generation.
bazel/​pigz/​private/​BUILD Exports repository-rule definitions.
bazel/​pigz/​defs.bzl Exposes the public pigz toolchain API.
bazel/​pigz/​BUILD Defines the public executable and fallback toolchain.
bazel/​oci/​tests/​layout/​oci-layout Identifies the OCI layout fixture.
bazel/​oci/​tests/​layout/​index.json References the fixture image manifest.
bazel/​oci/​tests/​layout/​blobs/​sha256/​f6b0fb35ba53df14ac9e15793dd3408774c6d1520f80cd3d06d8b80ea397bf25 Describes the fixture image layers.
bazel/​oci/​tests/​layout/​blobs/​sha256/​0dabb676417a2f768d6464c2195ec31cc19e70ced763aa377056341a8a8d26e8 Provides fixture image configuration.
bazel/​oci/​tests/​BUILD Defines the base-edit fixture and test.
bazel/​oci/​tests/​base_edit_test.py Checks generated accounts, homes, and package status.
bazel/​oci/​README.md Documents base-image editing and limitations.
bazel/​oci/​private/​BUILD Exports the editing implementation files.
bazel/​oci/​private/​base_edit.sh Reads image layers and writes the edited layer.
bazel/​oci/​private/​base_edit.bzl Connects editing actions to jq and tar toolchains.
bazel/​oci/​defs.bzl Exposes the oci_base_edit macro.
bazel/​oci/​BUILD Exports the public OCI definitions.
.github/​workflows/​_release.yml Adds pigz hash updates during release preparation.

Review effort: Balanced

Comment thread .github/workflows/_release.yml Resolved
Comment thread bazel/pigz/BUILD Resolved
Comment thread bazel/pigz/private/pigz_prebuilt.bzl Resolved
Comment thread bazel/tarball/test/BUILD Resolved
Comment thread bazel/oci/private/base_edit.sh Resolved
Comment thread bazel/oci/private/base_edit.sh Resolved
Comment thread bazel/tarball/compressed_tar.bzl Resolved
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…and set up pigz

envoyproxy/toolshed#5616 with the pigz prebuilt hashes set, to test it
before the release: the bins release is 0.2.34 there, and `//pigz` is set
up with `setup_pigz()` and `load_pigz_toolchains()`.

Signed-off-by: Ryan Northey <[email protected]>
@phlax
phlax force-pushed the workspace-oci-pigz branch from 2a8e51f to d3ddeff Compare November 17, 2026 11:53
phlax added a commit to phlax/toolshed that referenced this pull request Nov 17, 2026
As the release preparation would, to test envoyproxy#5616 from Envoy before the release.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…and set up pigz

envoyproxy/toolshed#5616 with the pigz prebuilt hashes set, to test it
before the release: the bins release is 0.2.34 there, and `//pigz` is set
up with `setup_pigz()` and `load_pigz_toolchains()`.

Signed-off-by: Ryan Northey <[email protected]>
@phlax
phlax requested a balanced review from Copilot November 17, 2026 11:59

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.

Comment thread bazel/tarball/test/BUILD Resolved
phlax added a commit to phlax/toolshed that referenced this pull request Nov 17, 2026
As the release preparation would, to test envoyproxy#5616 from Envoy before the release.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…and set up pigz

envoyproxy/toolshed#5616 with the pigz prebuilt hashes set, to test it
before the release: the bins release is 0.2.34 there, and `//pigz` is set
up with `setup_pigz()` and `load_pigz_toolchains()`.

Signed-off-by: Ryan Northey <[email protected]>
@phlax phlax changed the title bazel: Backport oci, pigz and compressed_tar to WORKSPACE bazel: Backport oci, pigz and compressed_tar to WORKSPACE, and allow the libcxx LLVM version to be set Nov 17, 2026
phlax and others added 5 commits November 17, 2026 13:37
…nvoyproxy#5597)

rules_oci can not run anything in an image, so the `RUN` steps of a
Dockerfile that add users or install packages on a base image have to be
replaced. rules_distroless `passwd`, `group` and `dpkg_status` write the
whole of those files, which replaces those of the base.

`oci_base_edit` reads the passwd, group, shadow, gshadow and dpkg status
files from the layers of the base image, and creates a layer with users
and groups added as `adduser` adds them, their home directories, and
packages added to the dpkg status.

Backport note (workspace): as on `main`.

(cherry picked from commit 0dbd94a)
Signed-off-by: Ryan Northey <[email protected]>
`//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]>
`pigz_prebuilt_extension.setup(host_path = "/abs/path/pigz")` adds a
toolchain over that pigz for the host's OS and CPU, after the
prebuilts: so it is used where there is no prebuilt (eg macOS), or
where the prebuilt is disabled, rather than building pigz or failing.

The path must be absolute and exist (it is watched, so a change
re-evaluates the toolchains), and the host must be Linux or macOS on
x86_64 or aarch64; otherwise the hub fails, with the reason. The hub
is not reproducible with a host pigz.

The fallback's failure now points at the option too.

Backport note (workspace): the path is set with `setup_pigz(host_path = ...)`. The prebuilts are
not configurable here, so a prebuilt for the host always takes precedence.

(cherry picked from commit 77185d7)
Signed-off-by: Ryan Northey <[email protected]>
envoyproxy#5607)

`pkg_tar` writes tarballs in Python (~20MB/s), which dominates builds
of large tarballs (eg envoy's release binaries and container image
layers, several GB with the debug info).

`compressed_tar` takes the same `pkg_files` (their paths and
attributes), writes an mtree of them, and streams bsdtar (the hermetic
tar toolchain) into a hermetic compressor using all the cores: pigz
(`//pigz`, `-n`) for gzip, or zstd (`-T0`), with an optional level.

The tarball is reproducible: entries are sorted, owned by root unless
the `pkg_files` set an owner, with `pkg_tar`'s "portable" mtime; parent
directories are added (0755), and files without a mode are 0555, as
`pkg_tar` does.

Tests check the mtree rendering, the gzip and zstd tarballs (format,
layout, modes, owners, mtime and contents), and that a path given
twice fails.

Backport note (workspace): as on `main`, but tested for gzip only, on Linux only: zstd uses
the consumer's `@zstd` (this branch's toolshed has none), and the prebuilt pigz is for Linux.
The tests that gzip are `manual` until there is a prebuilt.

(cherry picked from commit 49947f3)
Signed-off-by: Ryan Northey <[email protected]>
`libcxx_libs` fetches the bundles for toolshed's LLVM version (22.1.8).
A consumer on another version (Envoy's `release/v1.39` and earlier are
on LLVM 18.1.8) then cross-compiles its LLVM's libc++ headers against
the `__config_site` of another, which fails:

  __config:483:6: error: "Only one of _LIBCPP_ABI_FORCE_ITANIUM and
  _LIBCPP_ABI_FORCE_MICROSOFT can be defined"

`setup_libcxx_libs(llvm_version = ...)` selects the bundles of that
version, from the bins release that published them (`*_version`, eg
0.1.59 for 18.1.8) and with their hashes (`*_sha256`).

Signed-off-by: Ryan Northey <[email protected]>
@phlax
phlax force-pushed the workspace-oci-pigz branch from 3220b92 to 61f545d Compare November 17, 2026 13:37
@phlax
phlax requested a balanced review from Copilot November 17, 2026 13:39
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…and set up pigz

envoyproxy/toolshed#5616 with the pigz prebuilt hashes set, to test it
before the release: the bins release is 0.2.34 there, and `//pigz` is set
up with `setup_pigz()` and `load_pigz_toolchains()`.

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.

Comment thread bazel/oci/private/base_edit.bzl Resolved
Comment thread bazel/tarball/compressed_tar.bzl Resolved
Comment thread bazel/compile/libcxx_libs.bzl Resolved
@phlax
phlax force-pushed the workspace-oci-pigz branch from 61f545d to ffc586f Compare November 17, 2026 14:18
@phlax
phlax requested a balanced review from Copilot November 17, 2026 14:18
@phlax
phlax force-pushed the workspace-oci-pigz branch from ffc586f to 61f545d Compare November 17, 2026 14:18
phlax added a commit to phlax/toolshed that referenced this pull request Nov 17, 2026
As the release preparation would, to test envoyproxy#5616 from Envoy before the release.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…and set up pigz

envoyproxy/toolshed#5616 with the pigz prebuilt hashes set, to test it
before the release: the bins release is 0.2.34 there, and `//pigz` is set
up with `setup_pigz()` and `load_pigz_toolchains()`.

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.

🟡 Changes recommended

The tarball action can oversubscribe local workers, and home creation can emit an invalid layer when an ancestor or the home itself is not a directory.

2 open issues
3 resolved since last review

Review effort: Balanced

local parent
parent="$(dirname "$1")"
while [[ "$parent" != "/" ]]; do
if ! in_image "$parent"; then
args.add(ctx.executable.compressor)
args.add(ctx.outputs.out)
args.add_all(ctx.attr.compressor_args)
ctx.actions.run_shell(
@phlax
phlax merged commit 1397431 into envoyproxy:workspace Nov 17, 2026
83 checks passed
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
0.4.13.post4 has, backported to the WORKSPACE line
(envoyproxy/toolshed#5616):

- `oci_base_edit`, `compressed_tar` and a hermetic pigz, to build the
  release container images with rules_oci, and to gzip with all the
  cores;
- `setup_libcxx_libs(llvm_version = ...)`, to cross-compile with the
  libc++ of this branch's LLVM.

It is also on toolshed's bins v0.2.34.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
0.4.13.post4 has, backported to the WORKSPACE line
(envoyproxy/toolshed#5616):

- `oci_base_edit`, `compressed_tar` and a hermetic pigz, to build the
  release container images with rules_oci, and to gzip with all the
  cores;
- `setup_libcxx_libs(llvm_version = ...)`, to cross-compile with the
  libc++ of this branch's LLVM.

It is also on toolshed's bins v0.2.34.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
0.4.13.post4 has, backported to the WORKSPACE line
(envoyproxy/toolshed#5616):

- `oci_base_edit`, `compressed_tar` and a hermetic pigz, to build the
  release container images with rules_oci, and to gzip with all the
  cores;
- `setup_libcxx_libs(llvm_version = ...)`, to cross-compile with the
  libc++ of this branch's LLVM.

It is also on toolshed's bins v0.2.34.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
0.4.13.post4 has, backported to the WORKSPACE line
(envoyproxy/toolshed#5616):

- `oci_base_edit`, `compressed_tar` and a hermetic pigz, to build the
  release container images with rules_oci, and to gzip with all the
  cores;
- `setup_libcxx_libs(llvm_version = ...)`, to cross-compile with the
  libc++ of this branch's LLVM.

It is also on toolshed's bins v0.2.34.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
0.4.13.post4 has, backported to the WORKSPACE line
(envoyproxy/toolshed#5616):

- `oci_base_edit`, `compressed_tar` and a hermetic pigz, to build the
  release container images with rules_oci, and to gzip with all the
  cores;
- `setup_libcxx_libs(llvm_version = ...)`, to cross-compile with the
  libc++ of this branch's LLVM.

It is also on toolshed's bins v0.2.34.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
0.4.13.post4 has, backported to the WORKSPACE line
(envoyproxy/toolshed#5616):

- `oci_base_edit`, `compressed_tar` and a hermetic pigz, to build the
  release container images with rules_oci, and to gzip with all the
  cores;
- `setup_libcxx_libs(llvm_version = ...)`, to cross-compile with the
  libc++ of this branch's LLVM.

It is also on toolshed's bins v0.2.34.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
0.4.13.post4 has, backported to the WORKSPACE line
(envoyproxy/toolshed#5616):

- `oci_base_edit`, `compressed_tar` and a hermetic pigz, to build the
  release container images with rules_oci, and to gzip with all the
  cores;
- `setup_libcxx_libs(llvm_version = ...)`, to cross-compile with the
  libc++ of this branch's LLVM.

It is also on toolshed's bins v0.2.34.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
0.4.13.post4 has, backported to the WORKSPACE line
(envoyproxy/toolshed#5616):

- `oci_base_edit`, `compressed_tar` and a hermetic pigz, to build the
  release container images with rules_oci, and to gzip with all the
  cores;
- `setup_libcxx_libs(llvm_version = ...)`, to cross-compile with the
  libc++ of this branch's LLVM.

It is also on toolshed's bins v0.2.34.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
0.4.13.post4 has, backported to the WORKSPACE line
(envoyproxy/toolshed#5616):

- `oci_base_edit`, `compressed_tar` and a hermetic pigz, to build the
  release container images with rules_oci, and to gzip with all the
  cores;
- `setup_libcxx_libs(llvm_version = ...)`, to cross-compile with the
  libc++ of this branch's LLVM.

It is also on toolshed's bins v0.2.34.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
0.4.13.post4 has, backported to the WORKSPACE line
(envoyproxy/toolshed#5616):

- `oci_base_edit`, `compressed_tar` and a hermetic pigz, to build the
  release container images with rules_oci, and to gzip with all the
  cores;
- `setup_libcxx_libs(llvm_version = ...)`, to cross-compile with the
  libc++ of this branch's LLVM.

It is also on toolshed's bins v0.2.34.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
0.4.13.post4 has, backported to the WORKSPACE line
(envoyproxy/toolshed#5616):

- `oci_base_edit`, `compressed_tar` and a hermetic pigz, to build the
  release container images with rules_oci, and to gzip with all the
  cores;
- `setup_libcxx_libs(llvm_version = ...)`, to cross-compile with the
  libc++ of this branch's LLVM.

It is also on toolshed's bins v0.2.34.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 18, 2026
0.4.13.post4 has, backported to the WORKSPACE line
(envoyproxy/toolshed#5616):

- `oci_base_edit`, `compressed_tar` and a hermetic pigz, to build the
  release container images with rules_oci, and to gzip with all the
  cores;
- `setup_libcxx_libs(llvm_version = ...)`, to cross-compile with the
  libc++ of this branch's LLVM.

It is also on toolshed's bins v0.2.34.

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