Support build bazel on s390x platform

Signed-off-by: clyang82 <clyang@cn.ibm.com>

Closes #8079.

PiperOrigin-RevId: 245020401
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD
index d84818f..d4dc253 100644
--- a/tools/cpp/BUILD
+++ b/tools/cpp/BUILD
@@ -92,6 +92,7 @@
         "local|compiler": ":cc-compiler-local",
         "x64_windows|compiler": ":cc-compiler-x64_windows",
         "x64_windows_msvc|compiler": ":cc-compiler-x64_windows_msvc",
+        "s390x|compiler": ":cc-compiler-s390x",
         "ppc|compiler": ":cc-compiler-ppc",
         "k8": ":cc-compiler-local",
         "piii": ":cc-compiler-local",
@@ -169,6 +170,34 @@
 )
 
 cc_toolchain(
+    name = "cc-compiler-s390x",
+    all_files = ":empty",
+    ar_files = ":empty",
+    as_files = ":empty",
+    compiler_files = ":empty",
+    cpu = "s390x",
+    dwp_files = ":empty",
+    linker_files = ":empty",
+    objcopy_files = ":empty",
+    strip_files = ":empty",
+    supports_param_files = 1,
+    toolchain_config = ":local_linux",
+    toolchain_identifier = "local_linux",
+)
+
+toolchain(
+    name = "cc-toolchain-s390x",
+    exec_compatible_with = [
+        "@bazel_tools//platforms:s390x",
+    ],
+    target_compatible_with = [
+        "@bazel_tools//platforms:s390x",
+    ],
+    toolchain = ":cc-compiler-s390x",
+    toolchain_type = ":toolchain_type",
+)
+
+cc_toolchain(
     name = "cc-compiler-armeabi-v7a",
     all_files = ":empty",
     ar_files = ":empty",
diff --git a/tools/cpp/lib_cc_configure.bzl b/tools/cpp/lib_cc_configure.bzl
index db9a634..062ab68 100644
--- a/tools/cpp/lib_cc_configure.bzl
+++ b/tools/cpp/lib_cc_configure.bzl
@@ -188,6 +188,8 @@
     result = repository_ctx.execute(["uname", "-m"])
     if result.stdout.strip() in ["power", "ppc64le", "ppc", "ppc64"]:
         return "ppc"
+    if result.stdout.strip() in ["s390x"]:
+        return "s390x"
     if result.stdout.strip() in ["arm", "armv7l"]:
         return "arm"
     if result.stdout.strip() in ["aarch64"]: