Skip to content

compat/openssl: statically link libstdc++ in the prefixer - #48840

Merged
jwendell merged 1 commit into
envoyproxy:mainfrom
jwendell:openssl-prefixer-static-libstdcxx
Oct 29, 2026
Merged

jwendell merged 1 commit into
envoyproxy:mainfrom
jwendell:openssl-prefixer-static-libstdcxx

Conversation

@jwendell

Copy link
Copy Markdown
Member

The prefixer is an exec-config tool compiled against the gcc headers from envoy_toolshed's libstdcxx sysroot, so its objects reference that gcc's GLIBCXX symbol versions. Linking libstdc++ dynamically makes the tool require those versions from the build host's libstdc++.so.6 at runtime, so it aborts with "GLIBCXX_ not found" on any host whose system libstdc++ is older than the sysroot's gcc.

Link the matching static libstdc++.a (already shipped in the -L dir and already a linker input via @libstdcxx_sysroot_linux_amd64//:libs) so the tool is self-contained. libclang-cpp stays dynamic and resolves its own libstdc++ needs from the host.

The prefixer is an exec-config tool compiled against the gcc headers from
envoy_toolshed's libstdcxx sysroot, so its objects reference that gcc's
GLIBCXX symbol versions. Linking libstdc++ dynamically makes the tool
require those versions from the build host's libstdc++.so.6 at runtime,
so it aborts with "GLIBCXX_<ver> not found" on any host whose system
libstdc++ is older than the sysroot's gcc.

Link the matching static libstdc++.a (already shipped in the -L dir and
already a linker input via @libstdcxx_sysroot_linux_amd64//:libs) so the
tool is self-contained. libclang-cpp stays dynamic and resolves its own
libstdc++ needs from the host.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Jonh Wendell <[email protected]>
@jwendell
jwendell requested a review from phlax October 29, 2026 17:41

@phlax phlax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, thanks @jwendell

@jwendell
jwendell merged commit 468dfec into envoyproxy:main Oct 29, 2026
27 checks passed
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 9, 2026
…#48840)

The prefixer is an exec-config tool compiled against the gcc headers
from envoy_toolshed's libstdcxx sysroot, so its objects reference that
gcc's GLIBCXX symbol versions. Linking libstdc++ dynamically makes the
tool require those versions from the build host's libstdc++.so.6 at
runtime, so it aborts with "GLIBCXX_<ver> not found" on any host whose
system libstdc++ is older than the sysroot's gcc.

Link the matching static libstdc++.a (already shipped in the -L dir and
already a linker input via @libstdcxx_sysroot_linux_amd64//:libs) so the
tool is self-contained. libclang-cpp stays dynamic and resolves its own
libstdc++ needs from the host.

Signed-off-by: Jonh Wendell <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
(cherry picked from commit 468dfec)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 11, 2026
…#48840)

The prefixer is an exec-config tool compiled against the gcc headers
from envoy_toolshed's libstdcxx sysroot, so its objects reference that
gcc's GLIBCXX symbol versions. Linking libstdc++ dynamically makes the
tool require those versions from the build host's libstdc++.so.6 at
runtime, so it aborts with "GLIBCXX_<ver> not found" on any host whose
system libstdc++ is older than the sysroot's gcc.

Link the matching static libstdc++.a (already shipped in the -L dir and
already a linker input via @libstdcxx_sysroot_linux_amd64//:libs) so the
tool is self-contained. libclang-cpp stays dynamic and resolves its own
libstdc++ needs from the host.

Signed-off-by: Jonh Wendell <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
(cherry picked from commit 468dfec)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 11, 2026
…#48840)

The prefixer is an exec-config tool compiled against the gcc headers
from envoy_toolshed's libstdcxx sysroot, so its objects reference that
gcc's GLIBCXX symbol versions. Linking libstdc++ dynamically makes the
tool require those versions from the build host's libstdc++.so.6 at
runtime, so it aborts with "GLIBCXX_<ver> not found" on any host whose
system libstdc++ is older than the sysroot's gcc.

Link the matching static libstdc++.a (already shipped in the -L dir and
already a linker input via @libstdcxx_sysroot_linux_amd64//:libs) so the
tool is self-contained. libclang-cpp stays dynamic and resolves its own
libstdc++ needs from the host.

Signed-off-by: Jonh Wendell <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
(cherry picked from commit 468dfec)
Signed-off-by: Ryan Northey <[email protected]>
jwendell added a commit that referenced this pull request Nov 11, 2026
The prefixer is an exec-config tool compiled against the gcc headers
from envoy_toolshed's libstdcxx sysroot, so its objects reference that
gcc's GLIBCXX symbol versions. Linking libstdc++ dynamically makes the
tool require those versions from the build host's libstdc++.so.6 at
runtime, so it aborts with "GLIBCXX_<ver> not found" on any host whose
system libstdc++ is older than the sysroot's gcc.

Link the matching static libstdc++.a (already shipped in the -L dir and
already a linker input via @libstdcxx_sysroot_linux_amd64//:libs) so the
tool is self-contained. libclang-cpp stays dynamic and resolves its own
libstdc++ needs from the host.

Signed-off-by: Jonh Wendell <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
(cherry picked from commit 468dfec)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit that referenced this pull request Nov 12, 2026
The `prefixer` links the hermetic GCC runtime's `libstdc++.a`
(`//compat/openssl/prefixer:libstdcxx`), which defaulted to
`@gcc_runtime_linux_x86_64`. On a Linux aarch64 host the tool is built
for aarch64 but linked against the x86_64 archive, so `--config=openssl`
fails with `libstdc++.a(...) is incompatible with elf64-littleaarch64`.

Declare `gcc_runtime_linux_aarch64` (toolshed's `gcc_extension` already
supports `arch = "aarch64"`) and make the flag's default follow the CPU
via an `alias` and a `select`. The x86_64 default is unchanged.

Additional Description:

- `build_setting_default` of a `label_flag` cannot be a `select`, hence
the `alias`.
- The `select` is evaluated in the configuration the `prefixer` is built
for, so an aarch64 build picks the aarch64 runtime and any other CPU
keeps the previous x86_64 default.
- aarch64 builds now fetch toolshed's aarch64 GCC runtime archive for
the `prefixer`.
- No C++ is added, so there is no unit test or coverage to add
(CONTRIBUTING.md asks for an explanation when 100% coverage is not
possible). This is a BUILD/MODULE-only change that is verified by
building.
- Related: #48840 and #39632 introduced the hermetic libstdc++ but kept
an x86_64-only default.
- AI assistance: this change was drafted and tested with the help of
Claude Code. I reviewed it and understand every line of it, and I will
answer review comments myself.

Risk Level: Low (build configuration of a build-time tool; the default
branch is unchanged).

Testing:
Manual, on a Linux aarch64 host (NVIDIA BlueField-3 DPU), Bazel 9.3.2,
from a clean output base, with this commit on top of `main` 363c84b
(`envoy_toolshed` 0.5.20):

```
bazel build -c opt --config=openssl //compat/openssl/prefixer:prefixer //compat/openssl:prefixed_ossl_source //compat/openssl:bssl-compat
```

- After: the build completes successfully (2861 actions).
- After: `file` on the `prefixer` reports `ELF 64-bit LSB pie
executable, ARM aarch64`, and the `CppLink` action of the `prefixer`
(`bazel aquery`) references only
`gcc_runtime_linux_aarch64/aarch64-linux/lib64/libstdc++.a`.
- After: the only `gcc_runtime` and `llvm_minimal` repositories in the
output base are `gcc_runtime_linux_aarch64` and
`llvm_minimal_linux_arm64`; the x86_64 ones are not fetched.
- Before (same host, `main` without this change, earlier base 93aab93):
`//compat/openssl/prefixer:prefixer` fails with `libstdc++.a(...) is
incompatible with elf64-littleaarch64`.

Not tested: a full `//source/exe:envoy-static` build, x86_64 hosts (left
to CI), cross-compilation.

Docs Changes: N/A (`bazel/SSL.md` already lists aarch64 as supported for
OpenSSL).

Platform Specific Features: Linux aarch64 only; other platforms are
unchanged.

Fixes #49165

---------

Signed-off-by: Cong Son <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 12, 2026
…yproxy#49166)

The `prefixer` links the hermetic GCC runtime's `libstdc++.a`
(`//compat/openssl/prefixer:libstdcxx`), which defaulted to
`@gcc_runtime_linux_x86_64`. On a Linux aarch64 host the tool is built
for aarch64 but linked against the x86_64 archive, so `--config=openssl`
fails with `libstdc++.a(...) is incompatible with elf64-littleaarch64`.

Declare `gcc_runtime_linux_aarch64` (toolshed's `gcc_extension` already
supports `arch = "aarch64"`) and make the flag's default follow the CPU
via an `alias` and a `select`. The x86_64 default is unchanged.

Additional Description:

- `build_setting_default` of a `label_flag` cannot be a `select`, hence
the `alias`.
- The `select` is evaluated in the configuration the `prefixer` is built
for, so an aarch64 build picks the aarch64 runtime and any other CPU
keeps the previous x86_64 default.
- aarch64 builds now fetch toolshed's aarch64 GCC runtime archive for
the `prefixer`.
- No C++ is added, so there is no unit test or coverage to add
(CONTRIBUTING.md asks for an explanation when 100% coverage is not
possible). This is a BUILD/MODULE-only change that is verified by
building.
- Related: envoyproxy#48840 and envoyproxy#39632 introduced the hermetic libstdc++ but kept
an x86_64-only default.
- AI assistance: this change was drafted and tested with the help of
Claude Code. I reviewed it and understand every line of it, and I will
answer review comments myself.

Risk Level: Low (build configuration of a build-time tool; the default
branch is unchanged).

Testing:
Manual, on a Linux aarch64 host (NVIDIA BlueField-3 DPU), Bazel 9.3.2,
from a clean output base, with this commit on top of `main` 363c84b
(`envoy_toolshed` 0.5.20):

```
bazel build -c opt --config=openssl //compat/openssl/prefixer:prefixer //compat/openssl:prefixed_ossl_source //compat/openssl:bssl-compat
```

- After: the build completes successfully (2861 actions).
- After: `file` on the `prefixer` reports `ELF 64-bit LSB pie
executable, ARM aarch64`, and the `CppLink` action of the `prefixer`
(`bazel aquery`) references only
`gcc_runtime_linux_aarch64/aarch64-linux/lib64/libstdc++.a`.
- After: the only `gcc_runtime` and `llvm_minimal` repositories in the
output base are `gcc_runtime_linux_aarch64` and
`llvm_minimal_linux_arm64`; the x86_64 ones are not fetched.
- Before (same host, `main` without this change, earlier base 93aab93):
`//compat/openssl/prefixer:prefixer` fails with `libstdc++.a(...) is
incompatible with elf64-littleaarch64`.

Not tested: a full `//source/exe:envoy-static` build, x86_64 hosts (left
to CI), cross-compilation.

Docs Changes: N/A (`bazel/SSL.md` already lists aarch64 as supported for
OpenSSL).

Platform Specific Features: Linux aarch64 only; other platforms are
unchanged.

Fixes envoyproxy#49165

---------

Signed-off-by: Cong Son <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit that referenced this pull request Nov 12, 2026
The `prefixer` links the hermetic GCC runtime's `libstdc++.a`
(`//compat/openssl/prefixer:libstdcxx`), which defaulted to
`@gcc_runtime_linux_x86_64`. On a Linux aarch64 host the tool is built
for aarch64 but linked against the x86_64 archive, so `--config=openssl`
fails with `libstdc++.a(...) is incompatible with elf64-littleaarch64`.

Declare `gcc_runtime_linux_aarch64` (toolshed's `gcc_extension` already
supports `arch = "aarch64"`) and make the flag's default follow the CPU
via an `alias` and a `select`. The x86_64 default is unchanged.

Additional Description:

- `build_setting_default` of a `label_flag` cannot be a `select`, hence
the `alias`.
- The `select` is evaluated in the configuration the `prefixer` is built
for, so an aarch64 build picks the aarch64 runtime and any other CPU
keeps the previous x86_64 default.
- aarch64 builds now fetch toolshed's aarch64 GCC runtime archive for
the `prefixer`.
- No C++ is added, so there is no unit test or coverage to add
(CONTRIBUTING.md asks for an explanation when 100% coverage is not
possible). This is a BUILD/MODULE-only change that is verified by
building.
- Related: #48840 and #39632 introduced the hermetic libstdc++ but kept
an x86_64-only default.
- AI assistance: this change was drafted and tested with the help of
Claude Code. I reviewed it and understand every line of it, and I will
answer review comments myself.

Risk Level: Low (build configuration of a build-time tool; the default
branch is unchanged).

Testing:
Manual, on a Linux aarch64 host (NVIDIA BlueField-3 DPU), Bazel 9.3.2,
from a clean output base, with this commit on top of `main` 363c84b
(`envoy_toolshed` 0.5.20):

```
bazel build -c opt --config=openssl //compat/openssl/prefixer:prefixer //compat/openssl:prefixed_ossl_source //compat/openssl:bssl-compat
```

- After: the build completes successfully (2861 actions).
- After: `file` on the `prefixer` reports `ELF 64-bit LSB pie
executable, ARM aarch64`, and the `CppLink` action of the `prefixer`
(`bazel aquery`) references only
`gcc_runtime_linux_aarch64/aarch64-linux/lib64/libstdc++.a`.
- After: the only `gcc_runtime` and `llvm_minimal` repositories in the
output base are `gcc_runtime_linux_aarch64` and
`llvm_minimal_linux_arm64`; the x86_64 ones are not fetched.
- Before (same host, `main` without this change, earlier base 93aab93):
`//compat/openssl/prefixer:prefixer` fails with `libstdc++.a(...) is
incompatible with elf64-littleaarch64`.

Not tested: a full `//source/exe:envoy-static` build, x86_64 hosts (left
to CI), cross-compilation.

Docs Changes: N/A (`bazel/SSL.md` already lists aarch64 as supported for
OpenSSL).

Platform Specific Features: Linux aarch64 only; other platforms are
unchanged.

Fixes #49165

---------

Signed-off-by: Cong Son <[email protected]>
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