Bug 1221095 - Go application packages can no longer set CGO_ENABLED=0 if external linker will be used
Summary: Go application packages can no longer set CGO_ENABLED=0 if external linker wi...
Status: IN_PROGRESS
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Development (show other bugs)
Version: Current
Hardware: Other Other
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Jeff Kowalczyk
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-06 23:52 UTC by Jeff Kowalczyk
Modified: 2024-06-20 12:29 UTC (History)
1 user (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Kowalczyk 2024-03-06 23:52:47 UTC
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.)
Comment 1 Ana Guerrero 2024-06-20 12:29:13 UTC
Hi Jeff, any update on this issue? 
For the record, the SR https://build.opensuse.org/request/show/1145428 is linked to this.