Add Arm64 support
Based on work of Sun Zhiyi <zhiyisun@gmail.com>.
Closes #5360.
PiperOrigin-RevId: 201339882
diff --git a/scripts/bootstrap/buildenv.sh b/scripts/bootstrap/buildenv.sh
index 0689b95..0c7e8d4 100755
--- a/scripts/bootstrap/buildenv.sh
+++ b/scripts/bootstrap/buildenv.sh
@@ -53,7 +53,7 @@
MACHINE_TYPE="$(uname -m)"
MACHINE_IS_64BIT='no'
-if [ "${MACHINE_TYPE}" = 'amd64' -o "${MACHINE_TYPE}" = 'x86_64' -o "${MACHINE_TYPE}" = 's390x' ]; then
+if [ "${MACHINE_TYPE}" = 'amd64' -o "${MACHINE_TYPE}" = 'x86_64' -o "${MACHINE_TYPE}" = 's390x' -o "${MACHINE_TYPE}" = 'aarch64' ]; then
MACHINE_IS_64BIT='yes'
fi
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java b/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java
index d63ffdd..32d25c8 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java
@@ -55,6 +55,8 @@
return "ppc";
case ARM:
return "arm";
+ case AARCH64:
+ return "aarch64";
case S390X:
return "s390x";
default:
diff --git a/src/main/java/com/google/devtools/build/lib/util/CPU.java b/src/main/java/com/google/devtools/build/lib/util/CPU.java
index e210eb5..a3f7308 100644
--- a/src/main/java/com/google/devtools/build/lib/util/CPU.java
+++ b/src/main/java/com/google/devtools/build/lib/util/CPU.java
@@ -24,7 +24,8 @@
X86_32("x86_32", ImmutableSet.of("i386", "i486", "i586", "i686", "i786", "x86")),
X86_64("x86_64", ImmutableSet.of("amd64", "x86_64", "x64")),
PPC("ppc", ImmutableSet.of("ppc", "ppc64", "ppc64le")),
- ARM("arm", ImmutableSet.of("aarch64", "arm", "armv7l")),
+ ARM("arm", ImmutableSet.of("arm", "armv7l")),
+ AARCH64("aarch64", ImmutableSet.of("aarch64")),
S390X("s390x", ImmutableSet.of("s390x", "s390")),
UNKNOWN("unknown", ImmutableSet.<String>of());
diff --git a/tools/cpp/lib_cc_configure.bzl b/tools/cpp/lib_cc_configure.bzl
index d7a46a3..ebb0a05 100644
--- a/tools/cpp/lib_cc_configure.bzl
+++ b/tools/cpp/lib_cc_configure.bzl
@@ -188,8 +188,10 @@
result = repository_ctx.execute(["uname", "-m"])
if result.stdout.strip() in ["power", "ppc64le", "ppc", "ppc64"]:
return "ppc"
- if result.stdout.strip() in ["arm", "armv7l", "aarch64"]:
+ if result.stdout.strip() in ["arm", "armv7l"]:
return "arm"
+ if result.stdout.strip() in ["aarch64"]:
+ return "aarch64"
return "k8" if result.stdout.strip() in ["amd64", "x86_64", "x64"] else "piii"
def is_cc_configure_debug(repository_ctx):
diff --git a/tools/platforms/BUILD b/tools/platforms/BUILD
index 4323b33..960c013 100644
--- a/tools/platforms/BUILD
+++ b/tools/platforms/BUILD
@@ -40,6 +40,11 @@
)
constraint_value(
+ name = "aarch64",
+ constraint_setting = ":cpu",
+)
+
+constraint_value(
name = "s390x",
constraint_setting = ":cpu",
)
@@ -107,6 +112,7 @@
":x86_64",
":ppc",
":arm",
+ ":aarch64",
":s390x",
],
host_platform = True,
@@ -128,6 +134,7 @@
":x86_64",
":ppc",
":arm",
+ ":aarch64",
":s390x",
],
os_constraints = [
diff --git a/tools/platforms/platforms.BUILD b/tools/platforms/platforms.BUILD
index 5ff4ba8..775bea7 100644
--- a/tools/platforms/platforms.BUILD
+++ b/tools/platforms/platforms.BUILD
@@ -28,6 +28,11 @@
)
constraint_value(
+ name = "aarch64",
+ constraint_setting = ":cpu",
+)
+
+constraint_value(
name = "s390x",
constraint_setting = ":cpu",
)
@@ -95,6 +100,7 @@
":x86_64",
":ppc",
":arm",
+ ":aarch64",
":s390x",
],
host_platform = True,
@@ -116,6 +122,7 @@
":x86_64",
":ppc",
":arm",
+ ":aarch64",
":s390x",
],
os_constraints = [