Add workaround for arm vs armv7 android issue (#1259)
When building for the armv7 android target, we would ideally specify a
cpu:armv7 constraint, but because of the linked bazel issue this is
currently hardcoded as arm in bazel's NDK setup. As far as I can tell
the platform we request for use with rules rust has to match the
constraints in bazel, otherwise it won't discover the NDK CC toolchain
for linking.
Co-authored-by: Marcel Hlopko <hlopko@google.com>
diff --git a/rust/platform/triple_mappings.bzl b/rust/platform/triple_mappings.bzl
index 50a9449..5f5be21 100644
--- a/rust/platform/triple_mappings.bzl
+++ b/rust/platform/triple_mappings.bzl
@@ -269,6 +269,13 @@
"@rules_rust//rust/platform/os:unknown",
]
+ # Workaround for https://github.com/bazelbuild/bazel/issues/14982
+ if target_triple in ("armv7-linux-androideabi", "thumbv7neon-linux-androideabi"):
+ return [
+ "@platforms//cpu:arm",
+ "@platforms//os:android",
+ ]
+
triple_struct = triple(target_triple)
constraint_set = []