Reland "Fix issues with 32-bit ARM builds"

PiperOrigin-RevId: 324293928
Change-Id: Ifc28dc29cd33af42f7d80c9f87f27692cc505854
diff --git a/tensorflow/BUILD b/tensorflow/BUILD
index c4963a8..d1c1d7d 100644
--- a/tensorflow/BUILD
+++ b/tensorflow/BUILD
@@ -261,6 +261,36 @@
 )
 
 config_setting(
+    name = "armeabi",
+    values = {"cpu": "armeabi"},
+    visibility = ["//visibility:public"],
+)
+
+config_setting(
+    name = "armeabi-v7a",
+    values = {"cpu": "armeabi-v7a"},
+    visibility = ["//visibility:public"],
+)
+
+config_setting(
+    name = "arm64-v8a",
+    values = {"cpu": "arm64-v8a"},
+    visibility = ["//visibility:public"],
+)
+
+selects.config_setting_group(
+    name = "arm_any",
+    match_any = [
+        ":arm",
+        ":armeabi",
+        ":armeabi-v7a",
+        ":arm64-v8a",
+        ":linux_aarch64",
+        ":linux_armhf",
+    ],
+)
+
+config_setting(
     name = "freebsd",
     values = {"cpu": "freebsd"},
     visibility = ["//visibility:public"],
diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD
index 0f50727..a9884ee 100644
--- a/tensorflow/core/kernels/BUILD
+++ b/tensorflow/core/kernels/BUILD
@@ -810,10 +810,9 @@
     srcs = ["eigen_contraction_kernel.cc"],
     hdrs = ["eigen_contraction_kernel.h"],
     defines = select({
-        "//tensorflow:android": [],
-        "//tensorflow:arm": [],
+        "//tensorflow:android_x86": [],
+        "//tensorflow:arm_any": [],
         "//tensorflow:ios": [],
-        "//tensorflow:linux_aarch64": [],
         "//tensorflow:linux_ppc64le": [],
         "//conditions:default": [
             "TENSORFLOW_USE_CUSTOM_CONTRACTION_KERNEL",
@@ -825,10 +824,9 @@
         "//third_party/eigen3",
         "//tensorflow/core/platform:dynamic_annotations",
     ] + select({
-        "//tensorflow:android": [],
-        "//tensorflow:arm": [],
+        "//tensorflow:android_x86": [],
+        "//tensorflow:arm_any": [],
         "//tensorflow:ios": [],
-        "//tensorflow:linux_aarch64": [],
         "//tensorflow:linux_ppc64le": [],
         "//conditions:default": ["@mkl_dnn//:mkldnn_single_threaded"],
     }),
@@ -3179,8 +3177,8 @@
     name = "eigen_mkldnn_contraction_kernel_test",
     size = "small",
     srcs = select({
-        "//tensorflow:android": [],
-        "//tensorflow:arm": [],
+        "//tensorflow:android_x86": [],
+        "//tensorflow:arm_any": [],
         "//tensorflow:ios": [],
         "//tensorflow:linux_ppc64le": [],
         ":no_mkldnn_contraction_kernel": [],
diff --git a/tensorflow/core/platform/platform.h b/tensorflow/core/platform/platform.h
index a840d7b..3375a6e 100644
--- a/tensorflow/core/platform/platform.h
+++ b/tensorflow/core/platform/platform.h
@@ -41,18 +41,22 @@
 #elif defined(_WIN32)
 #define PLATFORM_WINDOWS
 
-#elif defined(__arm__)
-#define PLATFORM_POSIX
-
 #elif defined(__EMSCRIPTEN__)
 #define PLATFORM_PORTABLE_GOOGLE
 #define PLATFORM_POSIX
+// EMSCRIPTEN builds are considered "mobile" for the sake of portability.
+#define IS_MOBILE_PLATFORM
+
+#elif defined(__arm__) || defined(__aarch64__)
+// If no platform specified, use:
+#define PLATFORM_POSIX
 
 // Require an outside macro to tell us if we're building for Raspberry Pi or
 // another ARM device that's not a mobile platform.
-#if !defined(RASPBERRY_PI) && !defined(ARM_NON_MOBILE)
+#if !defined(RASPBERRY_PI) && !defined(ARM_NON_MOBILE) && \
+    !defined(PLATFORM_GOOGLE)
 #define IS_MOBILE_PLATFORM
-#endif  // !defined(RASPBERRY_PI) && !defined(ARM_NON_MOBILE)
+#endif
 
 #else
 // If no platform specified, use:
diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl
index 3edf2a4..86369a6 100644
--- a/tensorflow/tensorflow.bzl
+++ b/tensorflow/tensorflow.bzl
@@ -220,7 +220,7 @@
 
 # Config setting selector used when building for products
 # which requires restricted licenses to be avoided.
-def if_not_lgpl_restricted(a):
+def if_not_mobile_or_arm_or_lgpl_restricted(a):
     _ = (a,)
     return select({
         "//conditions:default": [],