Skip to content

proxy: trim wasm + dynamic modules from the compiled-in extension set; arm64 leg on a native runner - #704

Merged
bpalermo merged 1 commit into
mainfrom
proxy/697-pr0-trim-extensions
Sep 5, 2026
Merged

bpalermo merged 1 commit into
mainfrom
proxy/697-pr0-trim-extensions

Conversation

@bpalermo

@bpalermo bpalermo commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Step 1 of the proxy/ bzlmod migration (#697), deliberately kept on WORKSPACE and Envoy v1.39.0. It lands the two riskiest semantic changes of that migration against a known-good build, so that if //:envoy fails to link we know it is the extension trim and not bzlmod — and it shrinks the bzlmod PR to purely mechanical work.

What the exploration found

proxy/bazel/extension_config/extensions_build_config.bzl was not a curated subset. It is byte-identical to Envoy v1.38.0's default (diff is empty) — a stale verbatim copy that customised nothing and had silently fallen a release behind the v1.39.0 source pin. Concretely it was missing nine extensions v1.39.0 added:

envoy.extensions.network.socket_interface.sockmap
envoy.filters.http.ai_protocol_manager
envoy.filters.http.bandwidth_share
envoy.filters.http.filter_chain
envoy.filters.http.upstream_rbac
envoy.filters.udp.session.ext_authz
envoy.filters.upstream_network.reverse_tunnel_lifecycle
envoy.load_balancing_policies.load_aware_locality
envoy.upstreams.http.reverse_tunnel

So "diff our 654-line dict against Envoy's default" resolved to: we drop nothing today, and we accidentally drop whatever upstream adds tomorrow. This PR is therefore also the first time we actually decide what to drop.

Both @envoy source patches existed only to serve @llvm_toolchain_aarch64, and both were only needed because envoy.filters.http.dynamic_modules (Rust / bindgen / llvm-objcopy) is compiled in. Dropping dynamic modules deletes both patches, CARGO_BAZEL_REPIN, and the whole Rust-SDK-on-arm64 problem class. aether does not use dynamic modules: proposal 012 replaced the Rust dynamic module with the compiled-in C++ aether_stats filter, and proposal 025's extension escape hatch is CRD-based.

Changes

1. Load-and-filter instead of a verbatim copy. extensions_build_config.bzl now loads @envoy//source/extensions:extensions_build_config.bzl at the pinned version and subtracts — the shape envoyproxy/examples/filter-cc (the new upstream downstream-build template) uses. All five symbols Envoy exports are present at v1.39.0 (EXTENSIONS, LEGACY_ALWAYSLINK, {CONTRIB_,MOBILE_,}EXTENSION_{CONFIG_,}PACKAGE_VISIBILITY) and all five are re-exported.

_DROPPED = ["wasm", "dynamic_module"] (substring match on the extension name), which at v1.39.0 removes 26 entries:

upstream v1.39.0 330
dropped (wasm + dynamic modules) 26
compiled in 304
(previously, from the stale v1.38.0 copy) 317

all_extensions.bzl force-adds _required_extensions (xff, uuid request-id, round-robin LB) regardless of this dict, so the core floor cannot be filtered away. aether_stats is unaffected: it is a dep of the binary (AETHER_EXTENSIONS in //BUILD.bazel), not an entry in this dict — exactly like filter-cc's :http_filter_config.

No wasm-engine flag is added: v1.39.0's WORKSPACE-era gate is --define wasm=disabled, whose only consumers are select()s inside the wasm extension packages, and those packages are no longer in the graph at all. (The bzlmod PR uses the module-flag form, --@proxy-wasm-cpp-host//bazel:engine=disabled, per the template.)

2. Deleted, all downstream of the dynamic-modules drop.

  • proxy/bazel/patches/ — envoy-rust-sdk-aarch64-libclang.patch and envoy-dynamic-modules-aarch64-objcopy.patch, plus their BUILD.bazel, plus the patches = / patch_args = on the @envoy http_archive.
  • The @llvm_toolchain_aarch64 block in proxy/WORKSPACE.
  • CARGO_BAZEL_REPIN: "true" from proxy.yml and proxy-release.yml — envoy_rust_crate_index is a lazily-fetched crate_universe repo and nothing depends on it any more.

3. proxy.yml's arm64 leg moves to runs-on: ubuntu-24.04-arm. @clang_platform is an arch_alias whose _arch_alias_impl reads ctx.os.arch — the driver host's arch — and toolchains_llvm likewise derives exec_compatible_with from rctx.os.arch. An x64 driver therefore produces a cc-toolchain-aarch64-linux with exec_compatible_with = x86_64: a cross tool that cannot satisfy an aarch64 exec platform. That is the entire reason @llvm_toolchain_aarch64 existed. proxy-release.yml already runs its arm64 leg on a native arm64 runner and already proves this works; proxy.yml now copies that exact shape, which is what makes the second toolchain removable. This is also unchanged by bzlmod — Envoy's bzlmod llvm.toolchain(...) uses the same host-arch detection — so it has to be true either way.

--modify_execution_info=Genrule=-local is kept on the arm64 overlay (its original justification — the wasm-only @v8//:generated_inspector_files genrule under an x64 driver — is void, but the flag is proven on this pool and removing it is an unforced risk on a cold multi-hour build).

.github/actions/setup-llvm-libs is not deleted here: it shims LLVM 18.1.8's libtinfo.so.5, and v1.39.0 is still on LLVM 18. It dies in the bzlmod PR, where the toolchain moves to LLVM 22.1.8.

Gate

proxy.yml builds //... on both arches on BuildBuddy RBE, which covers //:envoy, //:image_test, //integration:{build_id_test,symtab_test} and the three aether_stats tests (incl. aether_stats_integration_test, which boots a real Envoy with the filter and is the static-init / factory-registration canary). Both legs are fully cold.

If //:envoy fails to link, the fix is a one-line revert of "dynamic_module" in _DROPPED.

Refs #697

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

@bpalermo
bpalermo force-pushed the proxy/697-pr0-trim-extensions branch from 5023986 to 099d090 Compare September 5, 2026 18:06
@bpalermo
bpalermo force-pushed the proxy/697-pr0-trim-extensions branch from 099d090 to 589753b Compare September 5, 2026 18:22
…; arm64 leg on a native runner

`proxy/bazel/extension_config/extensions_build_config.bzl` was not a curated
subset — it was a 659-line VERBATIM copy of Envoy v1.38.0's default that
customised nothing and had silently fallen a release behind the v1.39.0 pin (it
was missing nine extensions v1.39.0 added). Replace it with the upstream
downstream-build shape (envoyproxy/examples/filter-cc): load Envoy's default at
the pinned version and subtract, so an Envoy bump picks up new upstream
extensions for free and the `_DROPPED` list is the whole of our policy.

Dropped:

  * `wasm` — aether emits no wasm filter/runtime/access-logger/stat-sink
    anywhere. Takes the v8/wasmtime/wamr/emsdk build with it.
  * `dynamic_module` — superseded for aether by proposal 012 (aether_stats is a
    compiled-in C++ filter; the Rust dynamic-module approach was dropped) and
    proposal 025's escape hatch is CRD-based. Takes the Rust toolchain,
    crate_universe, bindgen/libclang and llvm-objcopy with it.
  * `hickory` — `envoy.network.dns_resolver.hickory`, the one extension outside
    those two groups that reaches the dynamic-modules machinery. Its name
    carries no hint of it, so the first attempt kept it and `//:envoy` failed to
    link on both arches with ~every `envoy_dynamic_module_callback_*` symbol
    undefined: hickory deps on
    `//source/extensions/dynamic_modules/builtin_extensions:hickory_dns_static`,
    a Rust static library that CALLS those callbacks, while their definitions
    live in `//source/extensions/dynamic_modules:abi_impl`, which only the
    dropped extensions pull in. Safe to drop — aether configures no
    `typed_dns_resolver_config` anywhere, so Envoy uses its default c-ares
    resolver, and `dns_resolver.{cares,getaddrinfo}` both stay.

Net at v1.39.0: 330 upstream − 27 dropped = 303 compiled in, against 317 before.

Because the dynamic-modules extensions are gone, so is everything that existed
only to build them on arm64:

  * `proxy/bazel/patches/` — both @envoy source patches (Rust-SDK libclang,
    dynamic-modules llvm-objcopy) pointed at `@llvm_toolchain_aarch64`;
  * the `@llvm_toolchain_aarch64` WORKSPACE block itself.

`CARGO_BAZEL_REPIN` does NOT go away here, though: @envoy's
`bazel/dependency_imports_extra.bzl` has a top-level
`load("@envoy_rust_crate_index//:defs.bzl", ...)`, so WORKSPACE evaluation fetches
the crate_universe repo whatever the extension set is. It goes with bzlmod (#697).

`@llvm_toolchain_aarch64` (a second llvm_toolchain with `exec_arch = "aarch64"`)
existed because `@clang_platform` and Envoy's `@llvm_toolchain` derive their
exec constraints from the DRIVER host's arch, so an x64 driver produced an
x86_64-exec cross toolchain that cannot satisfy an aarch64 exec platform.
`proxy-release.yml` already sidesteps this by running its arm64 leg on
`ubuntu-24.04-arm`; `proxy.yml` now does the same, which is what makes the
second toolchain removable.

This lands the two riskiest *semantic* changes of the bzlmod migration (#697)
against a known-good WORKSPACE build at v1.39.0, so that if `//:envoy` fails to
link it is unambiguously the extension trim and not bzlmod. It already paid for
itself: the hickory link failure above would otherwise have surfaced inside the
bzlmod PR, indistinguishable from a migration bug.

Refs #697

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo force-pushed the proxy/697-pr0-trim-extensions branch from 589753b to 57e61c0 Compare September 5, 2026 18:22
@bpalermo

bpalermo commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

CI run 1 & 2 findings (both fixed, pushed)

Run 1 — CARGO_BAZEL_REPIN cannot go here. Dropping it failed both legs in ~60s:

ERROR: Error computing the main repository mapping: no such package
'@@envoy_rust_crate_index//': Digests do not match ...
The current `lockfile` is out of date for 'envoy_rust_crate_index'.

@envoy//bazel:dependency_imports_extra.bzl has a top-level
load("@envoy_rust_crate_index//:defs.bzl", "crate_repositories"), so WORKSPACE
evaluation fetches the crate_universe repo unconditionally — the extension set is
irrelevant. Restored, with a comment; it genuinely goes away in the bzlmod PR,
where the crate extension is only evaluated if a repo from it is needed.

Run 2 — hickory had to be dropped too. Both arches got all the way to the
link and failed identically:

ERROR: proxy/BUILD.bazel:13:16: Linking envoy failed
ld.lld: error: undefined symbol: envoy_dynamic_module_callback_dns_resolver_config_define_counter
ld.lld: error: undefined symbol: envoy_dynamic_module_callback_log
ld.lld: error: undefined symbol: envoy_dynamic_module_callback_upstream_http_tcp_bridge_send_response
... too many errors emitted, stopping now

envoy.network.dns_resolver.hickory — kept, because nothing in its name
says "dynamic module" — deps on
//source/extensions/dynamic_modules/builtin_extensions:hickory_dns_static, a
Rust static library that calls the ABI callbacks. Their definitions live in
//source/extensions/dynamic_modules:abi_impl, which only the dropped
extensions pull in. A grep of [email protected] confirms hickory is the only
non-test, non-dynamic_modules BUILD file referencing either target, so this is
the complete fix rather than the first of several.

Safe to drop: aether configures no typed_dns_resolver_config anywhere, so
Envoy uses its default c-ares resolver; dns_resolver.{cares,getaddrinfo} both
stay. It also makes "no Rust in the proxy build" true rather than nearly true —
hickory_dns_static was the last Rust consumer, and the deleted
envoy-dynamic-modules-aarch64-objcopy.patch existed precisely for its
_hickory_dns_static_renamed genrule.

Net at v1.39.0 is now 330 upstream − 27 dropped = 303 compiled in (was 317).

This is exactly the failure mode PR 0 exists to isolate: had it surfaced inside
the bzlmod PR it would have been indistinguishable from a migration bug.

@bpalermo
bpalermo merged commit dc85823 into main Sep 5, 2026
17 checks passed
@bpalermo
bpalermo deleted the proxy/697-pr0-trim-extensions branch September 5, 2026 18:30
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.

1 participant