Skip to content

Enable aarch64 build on amd64 host#43826

Draft
mathetake wants to merge 8 commits intoenvoyproxy:mainfrom
mathetake:ilikeclaudecode
Draft

Enable aarch64 build on amd64 host#43826
mathetake wants to merge 8 commits intoenvoyproxy:mainfrom
mathetake:ilikeclaudecode

Conversation

@mathetake
Copy link
Member

Commit Message:
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

@repokitteh-read-only
Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #43826 was opened by mathetake.

see: more, trace.

@mathetake
Copy link
Member Author

After it is verified to work I will send a patch to toolshed and eliminate most of the crafty stuff here

@mathetake
Copy link
Member Author

Compilation -> Build

@mathetake mathetake changed the title Enable aarch64 compilation on amd64 host Enable aarch64 build on amd64 host Mar 7, 2026
@mathetake
Copy link
Member Author

/retest

Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
@mathetake
Copy link
Member Author

@phlax this is verified to work. I am thinking to add sysroot_linux_arm64_with_libcxx for arm64 cross compilation in toolshed rather than some clunky stuff here. wdyt?

@repokitteh-read-only repokitteh-read-only bot added the deps Approval required for changes to Envoy's external dependencies label Mar 7, 2026
@phlax
Copy link
Member

phlax commented Mar 7, 2026

so there is a sysroot with glibc here https://github.com/envoyproxy/toolshed/releases/download/bins-v0.1.47/sysroot-glibc2.28-libstdc++13-arm64.tar.xz

libc++ comes from the toolchain

what is quite possible - there is some setup in toolshed which might not be correct for arm x-compile

i think it was in toolshed - but i seem to rem when implementing the toolchains some point where i thought - hmm, that probs wont work if anyone actually tries to x-compile arm

fwiw - the arm toolchain and sysroot are tested in envoy ci (ie not x-compile)

@mathetake
Copy link
Member Author

@phlax so are you saying that instead of providing another toolchain like _with_libc or whatever like the current change, we should be able to fix the existing arm64 toolchain to be able to do x-compile/build?

@phlax
Copy link
Member

phlax commented Mar 7, 2026

ill try locally to x-compile assert lib or similar and get a bot on the case with any issues

@mathetake
Copy link
Member Author

cool - at least this lua patch is working perfectly for this cross compile usecase regardless of the toolchain change. I will also try to find the toolshed side fix to make this PR only have the luajit patch

@mathetake
Copy link
Member Author

mathetake commented Mar 7, 2026

toolshed's arm64 toolchain not carrying the libc++, so during the compilation bazel is looking at the local copy of libc++ is what I think is happening

@phlax
Copy link
Member

phlax commented Mar 7, 2026

when i say the toolchain provides libc++ im talking about this https://github.com/llvm/llvm-project/releases/ via this https://github.com/bazel-contrib/toolchains_llvm

@phlax
Copy link
Member

phlax commented Mar 7, 2026

one thing im 100% confident about - our x86/arm builds in ci do the right thing wrt glibc and libc++ - glibc comes from sysroot, and libc++ comes from the toolchains_llvm setup - the exception is GCC which does use the host glibc and libstdc++

@mathetake
Copy link
Member Author

cool - my claude is working now 🏃

@mathetake
Copy link
Member Author

yep you are right that this only happens in x-build

@bplotnick
Copy link
Contributor

when cross-compiling, toolchains_llvm falls back from builtin-libc++ to libstdc++ and so you get the host libstdc++ behavior.

@bplotnick
Copy link
Contributor

also it doesn't happen on darwin, so you have to test it on linux 🫠

@mathetake
Copy link
Member Author

mathetake commented Mar 7, 2026

@phlax yeah so we need either the current change here or the change like this where we modify the existing arm64 toolchain in toolshed so that we have an overlay libc++ when x-compiling due to the reason pointed out by @bplotnick - which one do you prefer?

@mathetake
Copy link
Member Author

luajit patch is necessary anyways for both cases

@phlax
Copy link
Member

phlax commented Mar 7, 2026

so - i think if there is a reasonable solution that we can implement in toolshed then that would probs be better

this pr feels like its reimplementing what is there already, and a bit brittle

i looked at the patch - but tbh - i would much rather review it as a pr to toolshed, and cant promise to do that before monday

high-level comment - wondering if we can make the x-compile work arch-agnostically

@mathetake
Copy link
Member Author

Yeah then I will send a PR to the tool shed soon. Absolutely no need to have this in before Monday but thank you!!

Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
name = "llvm_toolchain",
llvm_version = "18.1.8",
cxx_standard = {"": "c++20"},
stdlib = {"linux-aarch64": "libc++"},
Copy link
Member Author

Choose a reason for hiding this comment

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

this will force libc++ for arm64 target regardless of the host, otherwise it will be downgraded to stdlibc++ on the host, which is not ideal.

when cross-compiling, toolchains_llvm falls back from builtin-libc++ to libstdc++ and so you get the host libstdc++ behavior.

Copy link
Member

Choose a reason for hiding this comment

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

yeah - i think we need to guard this with a select - the toolchain should work with libstdc++ also i think

Copy link
Member

Choose a reason for hiding this comment

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

fwiw, we used to test this more

not sure what current testing is - maybe we dont test libstdc++ at all outside of gcc

that is why the the sysroots have libstdc++ bundled - because they cant get it from the toolchain, but perhaps we can now remove that - not sure

@mathetake
Copy link
Member Author

envoyproxy/toolshed#3779

Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deps Approval required for changes to Envoy's external dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants