Skip to content

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

Closed

Description

@zirconnotfound

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

Description:

bazel build --config=openssl cannot build the compat/openssl prefixer tool on a Linux aarch64 host. The tool is compiled for aarch64 but linked against the x86_64 libstdc++.a:

ld.lld: error: external/envoy_toolshed++gcc_extension+gcc_runtime_linux_x86_64/lib64/libstdc++.a(compatibility.o) is incompatible with elf64-littleaarch64
ld.lld: error: external/envoy_toolshed++gcc_extension+gcc_runtime_linux_x86_64/lib64/libstdc++.a(compatibility-debug_list.o) is incompatible with elf64-littleaarch64
... (repeated for every object)
ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
Target //compat/openssl/prefixer:prefixer failed to build

//compat/openssl:prefixed_ossl_source runs the prefixer, so this blocks every --config=openssl build (including //source/exe:envoy-static) on aarch64, although bazel/SSL.md lists "Supported architectures: Linux x86_64, aarch64, ppc64le" for OpenSSL.

Repro steps:

  • Host: Linux aarch64 (I used an NVIDIA BlueField-3 DPU). Build container: the docker.io/envoyproxy/envoy-build image pinned in .github/config.yml. Bazel 9.3.2.
  • Source: main at 93aab93 (VERSION.txt = 1.41.0-dev).
bazel build -c opt --config=openssl //compat/openssl/prefixer:prefixer

I only reproduced this on the host above. The cause below is independent of the hardware, so I expect any Linux aarch64 host to behave the same, but I have not checked.

Cause:

At the commit above:

  • compat/openssl/prefixer/BUILD:8-11 declares

    label_flag(
        name = "libstdcxx",
        build_setting_default = "@gcc_runtime_linux_x86_64//:libstdcxx",
    )

    :libstdcxx is a dependency of the prefixer (BUILD:37; the target is built with -nostdinc++ and -nostdlib++), so both the libstdc++ headers and libstdc++.a come from the x86_64 repository regardless of the CPU the tool is built for.

  • MODULE.bazel:187-195 declares only gcc_runtime_linux_x86_64. There is no aarch64 counterpart, although sysroot_linux_arm64 and llvm_minimal_linux_arm64 are already declared in the same file.

Related: #48840 ("compat/openssl: statically link libstdc++ in the prefixer") and #39632 ("bazel: Switch to hermetic gcc toolchains") introduced the hermetic libstdc++ but kept an x86_64-only default. v1.39.6 instead hard-codes external/sysroot_linux_amd64/usr/include/c++/13 in compat/openssl/prefixer/BUILD:24-25.

Suggested fix:

Declare gcc_runtime_linux_aarch64 next to the x86_64 one in MODULE.bazel and make the default of the flag follow the CPU. build_setting_default of a label_flag cannot be a select, so the default becomes an alias that contains the select. I have a patch and will open a PR that references this issue.

With that change, on the same aarch64 host (offline):

  • //compat/openssl/prefixer:prefixer builds.
  • //compat/openssl:prefixed_ossl_source and //compat/openssl:bssl-compat build
    (2845 actions, exit code 0).

Not verified: a full //source/exe:envoy-static build, x86_64 hosts, cross-compilation.

Admin and Stats Output: N/A (build-time failure, no Envoy binary is produced).

Config: --config=openssl (see the command above).

Logs: the linker output is in the description. I can attach the full Bazel log if useful.

Call Stack: N/A (not a crash).

Activity

  1. added
    triage
    on Nov 11, 2026
  2. added a commit that references this issue on Nov 12, 2026
    882f00c
  3. added a commit that references this issue on Nov 12, 2026
    53bb2af
  4. added a commit that references this issue on Nov 12, 2026
    1de4e1f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtriage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions