-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/cgo: removal of pre-built standard libraries results in compilation errors #58119
Comments
I don't like the idea of adding extra complexity (and potentially latency) to GCC 4.6 was released in March 2011 — over a decade ago! Is there some widely-used distro that is still actively supported by its distributor and still uses such an old compiler? Even then, you should be able to set (CC @ianlancetaylor) |
We have a rather large build system, so finding the right places to set CGO_ENABLED=0 where it fixes all the broken builds, but doesn't break others that are setting CGO_ENABLED=1 is difficult. And our Linux distribution is definitely old (and we've been "deprecating" it for a long time...). I can definitely see the hesitance in adding the check due to complexity/latency concerns (why I figured I'd feel it out before putting together a proper PR), especially given it probably isn't common for the average Go dev to run into this combination. But I can see the argument that if |
The complexity for (Do note that for custom build systems you may be able to set |
What C compiler are you using? GCC has supported Assuming you are using an earlier release, you could perhaps set |
4.1 unfortunately :(. Thank you both for the suggestions. I can check and see if the CGO_CFLAGS will flow through without being overwritten in too many places. With flags, I'm just a little worried about them being overwritten by other systems in the future (I'm still waiting/working on that future where I don't have to try and keep things building on a linux distribution from 2006/7 😄...). And overall, I don't disagree that this type of change could be a bit heavyweight for such a niche use-case, so feel free to close! |
Currently on https://go.dev/wiki/MinimumRequirements we document that GCC 4.6 is required, so I think it's OK that we don't support GCC 4.1. Sorry. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, go1.20rc3
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I introduced go1.20rc3 into our build system, which unfortunately still has some old Linux platforms we support.
What did you expect to see?
Builds to continue to function.
What did you see instead?
With our older Linux platforms, the change in 1.20rc* to remove the pre-built standard libraries has resulted in those platforms attempting to use cgo to compile
net
or similar packages. Since their default version of gcc is < 4.6, the builds now break on the diagnostic pragmas. I don't disagree with the removal of the pre-built libraries, it makes sense (and greatly reduced our internal distribution size). I'd like to discuss the possibility of modifying theCgoEnabled
detection incmd/go/internal/cfg
to check that the gcc version meets the minimum requirements (even if CC is set). When it fails the min version check, it would default to disabling CGO (when CGO_ENABLED isn't set). We have a local patch to Go that I modeled off thecompilerVersion()
function ingo/internal/work/init.go
to accomplish this check. If that type of check seems reasonable, I could work on cleaning up our patch and submitting a PR.The text was updated successfully, but these errors were encountered: