Skip to content

cmd/go: -buildmode=pie requires external (cgo) linking, but cgo is not enabled #64875

@andreas-schwab

Description

@andreas-schwab

Go version

go version go1.22rc1 linux/riscv64

What operating system and processor architecture are you using (go env)?

GO111MODULE=''
GOARCH='riscv64'
GOBIN=''
GOCACHE='/home/andreas/.cache/go-build'
GOENV='/home/andreas/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='riscv64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/andreas/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/andreas/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib64/go/1.22'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/lib64/go/1.22/pkg/tool/linux_riscv64'
GOVCS=''
GOVERSION='go1.22rc1'
GCCGO='gccgo'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1658771557=/tmp/go-build -gno-record-gcc-switches'

What did you do?

$ CGO_ENABLED=0 go build -buildmode=pie hellogo.go
-buildmode=pie requires external (cgo) linking, but cgo is not enabled

What did you expect to see?

$ CGO_ENABLED=0 /usr/lib64/go/1.21/bin/go build -buildmode=pie hellogo.go
# command-line-arguments
loadinternal: cannot find runtime/cgo

What did you see instead?

$ CGO_ENABLED=0 go build -buildmode=pie hellogo.go
-buildmode=pie requires external (cgo) linking, but cgo is not enabled

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.arch-riscvIssues solely affecting the riscv64 architecture.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions