V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
mengjisang
V2EX  ›  程序员

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

  •  
  •   mengjisang · 2023-06-24 17:44:23 +08:00 · 1667 次点击
    这是一个创建于 526 天前的主题,其中的信息可能已经有所发展或是发生改变。
    # 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"
    
    4 条回复    2023-06-25 16:11:10 +08:00
    mengjisang
        1
    mengjisang  
    OP
       2023-06-24 17:49:07 +08:00
    看到有说法是 CGO_ENABLED=1 ,但我看 go env 有这个参数,就很疑惑
    seers
        2
    seers  
       2023-06-25 08:31:29 +08:00 via iPhone
    tidy 试试
    aapeli
        3
    aapeli  
       2023-06-25 10:21:51 +08:00
    mengjisang
        4
    mengjisang  
    OP
       2023-06-25 16:11:10 +08:00
    @seers
    @aapeli 谢谢各位佬,,后面我发现这个是因为华为的 kubernetes 源码的 patch 本身有问题,不打 patch 就不会报错,而且报错也不是意味着编译失败,目标二进制文件还是生成出来了的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2673 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 11:18 · PVG 19:18 · LAX 03:18 · JFK 06:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.