From 6f69a95a25dc6fb1b3d0e024cb28f5c83022dc58 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Tue, 3 Jan 2023 14:19:44 +0800
Subject: fix compile options

Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
 hack/lib/golang.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh
index 2865da28..ed64483e 100755
--- a/hack/lib/golang.sh
+++ b/hack/lib/golang.sh
@@ -709,6 +709,7 @@ kube::golang::build_binaries_for_platform() {
       -installsuffix=static
       ${goflags:+"${goflags[@]}"}
       -gcflags="${gogcflags}"
+      -buildmode=pie
       -asmflags="${goasmflags}"
       -ldflags="${goldflags}"
       -tags="${gotags:-}"
@@ -720,6 +721,7 @@ kube::golang::build_binaries_for_platform() {
     build_args=(
       ${goflags:+"${goflags[@]}"}
       -gcflags="${gogcflags}"
+      -buildmode=pie
       -asmflags="${goasmflags}"
       -ldflags="${goldflags}"
       -tags="${gotags:-}"
@@ -808,7 +810,7 @@ kube::golang::build_binaries() {
         gogcflags="${gogcflags} -N -l"
     fi
 
-    goldflags="all=$(kube::version::ldflags) ${GOLDFLAGS:-}"
+    goldflags="all=$(kube::version::ldflags) ${GOLDFLAGS:-} -linkmode=external"
     if [[ "${DBG:-}" != 1 ]]; then
         # Not debugging - disable symbols and DWARF.
         goldflags="${goldflags} -s -w"
-- 
2.25.1

