From 45cfa17197d4e92e06f8c8da2f30d76432d5504e Mon Sep 17 00:00:00 2001
From: wangweijie <wangweijie@loongson.cn>
Date: Tue, 19 Mar 2024 20:08:26 +0800
Subject: [PATCH] Add loong64 host build support

---
 hack/lib/golang.sh                                           | 4 ++++
 hack/lib/util.sh                                             | 5 ++++-
 hack/local-up-cluster.sh                                     | 5 ++++-
 vendor/github.com/cilium/ebpf/internal/endian_le.go          | 4 ++--
 .../runc/libcontainer/system/syscall_linux_64.go             | 4 ++--
 5 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh
index f3466ff7..29efb1c8 100755
--- a/hack/lib/golang.sh
+++ b/hack/lib/golang.sh
@@ -27,6 +27,7 @@ readonly KUBE_SUPPORTED_SERVER_PLATFORMS=(
   linux/arm64
   linux/s390x
   linux/ppc64le
+  linux/loong64
 )
 
 # The node platforms we build for
@@ -35,6 +36,7 @@ readonly KUBE_SUPPORTED_NODE_PLATFORMS=(
   linux/arm64
   linux/s390x
   linux/ppc64le
+  linux/loong64
   windows/amd64
 )
 
@@ -47,6 +49,7 @@ readonly KUBE_SUPPORTED_CLIENT_PLATFORMS=(
   linux/arm64
   linux/s390x
   linux/ppc64le
+  linux/loong64
   darwin/amd64
   darwin/arm64
   windows/amd64
@@ -61,6 +64,7 @@ readonly KUBE_SUPPORTED_TEST_PLATFORMS=(
   linux/arm64
   linux/s390x
   linux/ppc64le
+  linux/loong64
   darwin/amd64
   darwin/arm64
   windows/amd64
diff --git a/hack/lib/util.sh b/hack/lib/util.sh
index 70568f76..6c9ad7cc 100755
--- a/hack/lib/util.sh
+++ b/hack/lib/util.sh
@@ -185,8 +185,11 @@ kube::util::host_arch() {
     ppc64le*)
       host_arch=ppc64le
       ;;
+    loongarch64*)
+      host_arch=loong64
+      ;;
     *)
-      kube::log::error "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x or ppc64le."
+      kube::log::error "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x, ppc64le or loong64."
       exit 1
       ;;
   esac
diff --git a/hack/local-up-cluster.sh b/hack/local-up-cluster.sh
index 83bdd694..15e8338e 100755
--- a/hack/local-up-cluster.sh
+++ b/hack/local-up-cluster.sh
@@ -292,8 +292,11 @@ function detect_arch {
       ppc64le*)
         host_arch=ppc64le
         ;;
+      loongarch64*)
+        host_arch=loong64
+        ;;
       *)
-        echo "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x or ppc64le." >&2
+        echo "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x, ppc64le or loong64." >&2
         exit 1
         ;;
     esac
diff --git a/vendor/github.com/cilium/ebpf/internal/endian_le.go b/vendor/github.com/cilium/ebpf/internal/endian_le.go
index 41a68224..62480fb1 100644
--- a/vendor/github.com/cilium/ebpf/internal/endian_le.go
+++ b/vendor/github.com/cilium/ebpf/internal/endian_le.go
@@ -1,5 +1,5 @@
-//go:build 386 || amd64 || amd64p32 || arm || arm64 || mipsle || mips64le || mips64p32le || ppc64le || riscv64
-// +build 386 amd64 amd64p32 arm arm64 mipsle mips64le mips64p32le ppc64le riscv64
+//go:build 386 || amd64 || amd64p32 || arm || arm64 || mipsle || mips64le || mips64p32le || ppc64le || riscv64 || loong64
+// +build 386 amd64 amd64p32 arm arm64 mipsle mips64le mips64p32le ppc64le riscv64 loong64
 
 package internal
 
diff --git a/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go b/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go
index 1ed0dba1..ccb9340d 100644
--- a/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go
+++ b/vendor/github.com/opencontainers/runc/libcontainer/system/syscall_linux_64.go
@@ -1,6 +1,6 @@
-//go:build linux && (arm64 || amd64 || mips || mipsle || mips64 || mips64le || ppc || ppc64 || ppc64le || riscv64 || s390x)
+//go:build linux && (arm64 || amd64 || mips || mipsle || mips64 || mips64le || ppc || ppc64 || ppc64le || riscv64 || s390x || loong64)
 // +build linux
-// +build arm64 amd64 mips mipsle mips64 mips64le ppc ppc64 ppc64le riscv64 s390x
+// +build arm64 amd64 mips mipsle mips64 mips64le ppc ppc64 ppc64le riscv64 s390x loong64
 
 package system
 
-- 
2.38.1

