forked from bottlerocket-os/bottlerocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0001-always-set-relevant-variables-for-cross-compiling.patch
77 lines (72 loc) · 2.43 KB
/
0001-always-set-relevant-variables-for-cross-compiling.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
From 77cc9ceb6296f634e2068d6ca6137978d767a5ac Mon Sep 17 00:00:00 2001
From: Ben Cressey <[email protected]>
Date: Sat, 18 May 2019 16:57:12 +0000
Subject: [PATCH 1/3] always set relevant variables for cross compiling
Signed-off-by: Ben Cressey <[email protected]>
---
hack/lib/golang.sh | 52 ++++++++++++++++++++++++++--------------------
1 file changed, 30 insertions(+), 22 deletions(-)
diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh
index bc7c065e..a82880a5 100755
--- a/hack/lib/golang.sh
+++ b/hack/lib/golang.sh
@@ -394,29 +394,37 @@ kube::golang::set_platform_envs() {
export GOOS=${platform%/*}
export GOARCH=${platform##*/}
- # Do not set CC when building natively on a platform, only if cross-compiling from linux/amd64
- if [[ $(kube::golang::host_platform) == "linux/amd64" ]]; then
- # Dynamic CGO linking for other server architectures than linux/amd64 goes here
- # If you want to include support for more server platforms than these, add arch-specific gcc names here
- case "${platform}" in
- "linux/arm")
- export CGO_ENABLED=1
- export CC=arm-linux-gnueabihf-gcc
- ;;
- "linux/arm64")
- export CGO_ENABLED=1
- export CC=aarch64-linux-gnu-gcc
- ;;
- "linux/ppc64le")
- export CGO_ENABLED=1
- export CC=powerpc64le-linux-gnu-gcc
- ;;
- "linux/s390x")
- export CGO_ENABLED=1
- export CC=s390x-linux-gnu-gcc
- ;;
- esac
+ # Apply standard values for CGO_ENABLED and CC unless KUBE_BUILD_PLATFORMS is set.
+ if [ -z "${KUBE_BUILD_PLATFORMS}" ] ; then
+ export CGO_ENABLED=0
+ export CC=gcc
+ return
fi
+
+ # Dynamic CGO linking for other server architectures goes here
+ # If you want to include support for more server platforms than these, add arch-specific gcc names here
+ case "${platform}" in
+ "linux/amd64")
+ export CGO_ENABLED=1
+ export CC=x86_64-bottlerocket-linux-gnu-gcc
+ ;;
+ "linux/arm")
+ export CGO_ENABLED=1
+ export CC=arm-bottlerocket-linux-gnueabihf-gcc
+ ;;
+ "linux/arm64")
+ export CGO_ENABLED=1
+ export CC=aarch64-bottlerocket-linux-gnu-gcc
+ ;;
+ "linux/ppc64le")
+ export CGO_ENABLED=1
+ export CC=powerpc64le-bottlerocket-linux-gnu-gcc
+ ;;
+ "linux/s390x")
+ export CGO_ENABLED=1
+ export CC=s390x-bottlerocket-linux-gnu-gcc
+ ;;
+ esac
}
kube::golang::unset_platform_envs() {
--
2.21.0