Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for arm64 / aarch64 #212

Closed
moderation opened this issue Jan 31, 2019 · 8 comments
Closed

Support for arm64 / aarch64 #212

moderation opened this issue Jan 31, 2019 · 8 comments

Comments

@moderation
Copy link

Envoy Proxy just implemented rules_foreign_cc today with PR envoyproxy/envoy#5218. My builds for Linux x86_64 and macOS are working fine. However my arm64 / aarch64 builds are failing with the following error.

ERROR: While resolving toolchains for target //bazel/foreign_cc:zlib: no matching toolchains found for types @rules_foreign_cc//tools/build_defs/shell_toolchain/toolchains:shell_commands

It looks like only Linux, Windows and macOS are supported on the x86_64 architecture after looking at https://github.com/bazelbuild/rules_foreign_cc/blob/master/tools/build_defs/shell_toolchain/toolchains/toolchain_mappings.bzl

/cc @htuch

@irengrig
Copy link
Contributor

Sorry.
Yes, this is a bug with rules_foreign_cc to not provide the default toolchain implementation.
I just added default toolchain in #213, with "linux" be assumed to be a os name to be passed to CMake. (I.e. that is what is recorded into CMake's crosstool file.
If the platform name should be different, it can be overridden with passing correct CMAKE_SYSTEM_NAME, but as we better try to pass the correct name, I will try to improve on that)

I will continue to check it with amd64/aarch64 later today in a Docker container. Are there more speicfic details to take into account?

Sorry again.

@moderation
Copy link
Author

Thanks. I can confirm that if I modify the following Envoy will build on aarch64.

diff --git a/~/Library/rules_foreign_cc/tools/build_defs/shell_toolchain//toolchains/toolchain_mappings.bzl b/~/Library/envoyproxy/moderation/rules_foreign_cc/tools/build_defs/shell_toolchain/toolchains/toolchain_mappings.bzl
index af9647e..42fa81a 100644
--- a/~/Library/rules_foreign_cc/tools/build_defs/shell_toolchain//toolchains/toolchain_mappings.bzl
+++ b/~/Library/envoyproxy/moderation/rules_foreign_cc/tools/build_defs/shell_toolchain/toolchains/toolchain_mappings.bzl
@@ -11,7 +11,7 @@ TOOLCHAIN_MAPPINGS = [
     _ToolchainMapping(
         exec_compatible_with = [
             "@bazel_tools//platforms:linux",
-            "@bazel_tools//platforms:x86_64",
+            "@bazel_tools//platforms:aarch64",
         ],
         file = "@rules_foreign_cc//tools/build_defs/shell_toolchain/toolchains/impl:linux_commands.bzl",
     ),

I'll try using CMAKE_SYSTEM_NAME. I did have a couple of tries at adding a new ToolchainMapping section but ran into errors. So hopefully it won't be too hard to add aarch64 in addition to x86_64. There are teams building Envoy for the IBM ppc64le architecture as well so I expect there will be several architectures that need to be added.

@irengrig
Copy link
Contributor

I just provided the possibility to introduce custom ToolchainMappings: #214.
Please refer to example there.
I will make it now that CMAKE_SYSTEM_NAME comes from os_name() function, if it is not windows-linux-osx.

Currently I am experimenting with the amd64/alpine container, should I select some better variant?

@moderation
Copy link
Author

I just tested the latest commit and it works on aarch64. Thanks for the quick turnaround.

@irengrig
Copy link
Contributor

I will make it now that CMAKE_SYSTEM_NAME comes from os_name() function

Done in #215.

@irengrig
Copy link
Contributor

I just tested the latest commit and it works on aarch64. Thanks for the quick turnaround.

Cool, thank you!

@irengrig
Copy link
Contributor

irengrig commented Feb 1, 2019

Can I close the issue then?

@moderation
Copy link
Author

Yes - thanks again for the quick turnaround.

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

No branches or pull requests

2 participants