go build: produces broken static pie files when build with go build
instead of go build -o outfile source.go
#62173
Labels
go build
instead of go build -o outfile source.go
#62173
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
No. While filing this bug, I noticed that it works with go 1.21 (build pipelines are still using 1.20) and I figured would be still worth reporting
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Compiling a static PIE binary with forced external linking. (
-tags netgo,osusergo,static_build -buildmode=pie -trimpath -ldflags '-extldflags -static-pie -extld gcc -linkmode external'
).Note: The bug only manifests if the binary was build with
go build $FLAGS
, not when build withgo build $FLAGS -o outfile main.go
What did you expect to see?
Compiles successfully and runs.
What did you see instead?
Sometimes an error/warning
loadinternal: cannot find runtime/cgo
but build ends successfully. The binary then crashes on startupbuild output
The text was updated successfully, but these errors were encountered: