Skip to content

compat/openssl: select the prefixer's libstdc++ by architecture - #49166

Merged
phlax merged 2 commits into
envoyproxy:mainfrom
zirconnotfound:compat-openssl-prefixer-aarch64
Nov 12, 2026
Merged

phlax merged 2 commits into
envoyproxy:mainfrom
zirconnotfound:compat-openssl-prefixer-aarch64

Conversation

@zirconnotfound

Copy link
Copy Markdown
Contributor

Commit Message:
compat/openssl: select the prefixer's libstdc++ by architecture

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: compat/openssl: statically link libstdc++ in the prefixer #48840 and bazel: Switch to hermetic gcc toolchains #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).

Release Notes: changelogs/current/bug_fixes/build__openssl-prefixer-aarch64.rst

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

Fixes #49165

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.

Fixes envoyproxy#49165

Signed-off-by: Cong Son <[email protected]>
@zirconnotfound
zirconnotfound temporarily deployed to external-contributors November 11, 2026 04:22 — with GitHub Actions Inactive
@repokitteh-read-only

Copy link
Copy Markdown

Hi @zirconnotfound, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #49166 was opened by zirconnotfound.

see: more, trace.

@phlax phlax self-assigned this Nov 11, 2026

@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.

thanks @zirconnotfound lets drop the changelog and land

@@ -0,0 +1,4 @@
Fixed ``--config=openssl`` builds on Linux ``aarch64`` hosts, where the ``compat/openssl``

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.

probabkly we can skip adding a changelog here - we do add sometimes for build changes - but not sure this qualifies

@zirconnotfound zirconnotfound Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks for reviewing. i thought that was necessary so i kept it in my commit.
i've pushed another commit to drop it, please let me know if anything else was raised

@zirconnotfound
zirconnotfound temporarily deployed to external-contributors November 12, 2026 01:28 — with GitHub Actions Inactive
@phlax

phlax commented Nov 12, 2026

Copy link
Copy Markdown
Member

/retest flakey infra

@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 @zirconnotfound

@phlax
phlax merged commit 53bb2af into envoyproxy:main Nov 12, 2026
29 checks passed
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]>

This branch was previously deployed

1 inactive deployment
external-contributors — c61d66bf Deployed Nov 12, 2026 by zirconnotfound via authorize #61860
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.

compat/openssl: prefixer fails to link on aarch64 hosts (x86_64 libstdc++.a)

2 participants