编译 kubernetes 源码,但是出现了以下报错, cannot find runtime/cgo,大佬来看看吧

2023-06-24 17:44:23 +08:00
 mengjisang
# k8s.io/kubernetes/cmd/kubectl
loadinternal: cannot find runtime/cgo
# k8s.io/kubernetes/cmd/kubeadm
loadinternal: cannot find runtime/cgo
# k8s.io/kubernetes/cmd/kube-proxy
loadinternal: cannot find runtime/cgo
# k8s.io/kubernetes/cmd/kube-scheduler
loadinternal: cannot find runtime/cgo
# k8s.io/kubernetes/cmd/kube-apiserver
loadinternal: cannot find runtime/cgo
# k8s.io/kubernetes/cmd/kube-controller-manager
loadinternal: cannot find runtime/cgo
# k8s.io/kubernetes/cluster/gce/gci/mounter
loadinternal: cannot find runtime/cgo
^Cmake: *** [Makefile:93: all] Interrupt

go 的环境参数如下

hj@ubuntu:~/Desktop/kubernetes/kubernetes-1.20.2$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/hj/.cache/go-build"
GOENV="/home/hj/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/hj/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/hj/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/hj/Desktop/kubernetes/kubernetes-1.20.2/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4160134575=/tmp/go-build -gno-record-gcc-switches"
1641 次点击
所在节点    程序员
4 条回复
mengjisang
2023-06-24 17:49:07 +08:00
看到有说法是 CGO_ENABLED=1 ,但我看 go env 有这个参数,就很疑惑
seers
2023-06-25 08:31:29 +08:00
tidy 试试
aapeli
2023-06-25 10:21:51 +08:00
mengjisang
2023-06-25 16:11:10 +08:00
@seers
@aapeli 谢谢各位佬,,后面我发现这个是因为华为的 kubernetes 源码的 patch 本身有问题,不打 patch 就不会报错,而且报错也不是意味着编译失败,目标二进制文件还是生成出来了的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/951235

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX