aboutsummaryrefslogtreecommitdiffstats
path: root/testing/kubernetes/ensure-cgo-usage.patch
blob: a93ea161b0e8f82842ee307a36f8eee01e9ac2ac (plain)
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
From: Tiago Ilieve <tiago.myhro@gmail.com>
Date: Sat, 27 Oct 2018 10:47:42 +0000
Subject: [PATCH] Ensure CGO usage

There are checks to define if CGO is required by the platform, but those
are not enough to ensure its usage in Alpine. This leads to errors like:

/usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x8): undefined reference to `x_cgo_callers'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x10): undefined reference to `x_cgo_init'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x18): undefined reference to `x_cgo_mmap'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x20): undefined reference to `x_cgo_munmap'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x28): undefined reference to `x_cgo_notify_runtime_init_done'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x30): undefined reference to `x_cgo_sigaction'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x38): undefined reference to `x_cgo_thread_start'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x5b0): undefined reference to `x_cgo_setenv'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x5b8): undefined reference to `x_cgo_unsetenv'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x5c0): undefined reference to `_cgo_yield'
collect2: error: ld returned 1 exit status

---
--- a/hack/lib/golang.sh
+++ b/hack/lib/golang.sh
@@ -611,7 +611,7 @@
       -asmflags "${goasmflags:-}"
       -ldflags "${goldflags:-}"
     )
-    CGO_ENABLED=0 kube::golang::build_some_binaries "${statics[@]}"
+    CGO_ENABLED=1 kube::golang::build_some_binaries "${statics[@]}"
   fi
 
   if [[ "${#nonstatics[@]}" != 0 ]]; then