Bug ID 1221095
Summary Go application packages can no longer set CGO_ENABLED=0 if external linker will be used
Classification openSUSE
Product openSUSE Tumbleweed
Version Current
Hardware Other
OS Other
Status NEW
Severity Normal
Priority P5 - None
Component Development
Assignee screening-team-bugs@suse.de
Reporter jkowalczyk@suse.com
QA Contact qa-bugs@suse.de
Target Milestone ---
Found By ---
Blocker ---

Per Go upstream change https://go-review.googlesource.com/c/website/+/569296,
as of go1.21.8+ and go1.22.1+ go build commands cannot set CGO_ENABLED=0 if the
external linker will be used. (Cgo lets Go packages call C code, see
https://go.dev/blog/cgo, 2011) The most commonly used option that triggers the
external linker is -buildmode=pie, which we aspirationally use in most Go
application packages behind conditionals for architectures where it is
unsupported, currently only ppc64le.

We first encountered this issue when trying to set the go metapackage from
go1.21 to go1.22. Approximately 40+ Go application packages in Factory set 
CGO_ENABLED=0 and -buildmode=pie together. On arch i586, builds started to fail
with error:

-buildmode=pie requires external (cgo) linking, but cgo is not enabled

This tracking bug will be referenced for SR submissions to Go application
packages to adapt to the new requirements. Most of these submissions will to
remove CGO_ENABLED=0 absent a requirement for its use by a specific package.

Upstream comments from the above change:

https://go.dev/issue/31544, CL 477839
When using an external (C) linker with cgo enabled, the `runtime/cgo` package
is
now supplied to the Go linker as an additional dependency to ensure that the Go
runtime is compatible with any additional libraries added by the C linker.

https://go.dev/issue/46330, CL 522239
go build commands that invoke the linker now error out if an external (C)
linker will be used but cgo is not enabled. (The Go runtime requires cgo
support to ensure that it is compatible with any additional libraries added by
the C linker.)


You are receiving this mail because: