-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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/go: build fails requiring C compiler for runtime/cgo #47215
Comments
How did you install 1.16.5 and 1.17rc1 ? |
I installed go 1.16.5 as follows: $ sudo pacman -S go Then I installed go 1.17rc1 as follows: $ go get golang.org/dl/go1.17rc1 $ go1.17rc1 download Then I set up my PATH to include ${HOME}/go/bin |
To rule out any Archlinux / Pacman effect, I did a manual install of go 1.16.6 : $ curl -LOs https://golang.org/dl/go1.16.6.linux-amd64.tar.gz $ sudo tar xzf go1.16.6.linux-amd64.tar.gz -C /usr/local $ export PATH=${PATH}:/usr/local/go/bin $ go version go version go1.16.6 linux/amd64 $ go get golang.org/dl/go1.17rc1 go: downloading golang.org/dl v0.0.0-20210713194856-38ddc79c2163 $ ~/go/bin/go1.17rc1 download Downloaded 0.0% ( 3273 / 134784935 bytes) ... [...] Downloaded 91.8% (123780176 / 134784935 bytes) ... Downloaded 93.4% (125844544 / 134784935 bytes) ... Downloaded 100.0% (134740992 / 134784935 bytes) ... Downloaded 100.0% (134784935 / 134784935 bytes) Unpacking /home/unix/sdk/go1.17rc1/go1.17rc1.linux-amd64.tar.gz ... Success. You may now run 'go1.17rc1' $ export PATH=${PATH}:${HOME}/go/bin $ go1.17rc1 version go version go1.17rc1 linux/amd64 It didn't fix the problem. The most notable thing is that the simple example program I use compiles fine with 1.16 but not with go 1.17. So there is a regression issue, I guess. Many thanks L. |
I tried the above manual install on a fresh ubuntu 20.04 LXC container: same error: $ go1.17rc1 build # runtime/cgo cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH However: $ go version go version go1.16.6 linux/amd64 $ go build $ ./foo Hello, World! |
It looks like
|
Yes indeed. If I disable CGO_ENABLED, it works: $ go1.17rc1 build # runtime/cgo cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH $ CGO_ENABLED=0 go1.17rc1 build $ ./foo Hello, World! |
The issue is that compilation works independently of how CGO_ENABLED is set when the same program is compiled with 1.16. So it looks like a regression problem to me... $ CGO_ENABLED=0 go build $ CGO_ENABLED=1 go build $ CGO_ENABLED=0 go1.17rc1 build $ CGO_ENABLED=1 go1.17rc1 build # runtime/cgo cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH |
@lyderic I expect this is because of the build cache. If you run |
Yes it does: $ go clean -cache $ CGO_ENABLED=1 go build |
Interesting. Reopening to investigate this more. I wonder if we changed how the cache key is calculated? |
We did change how the cache key is calculated. I've opened #47251 with an explanation and possible solution. |
Ok, so here's an idea for 1.18 (if we don't do #47257 or #47251 instead). What if we bake the C compiler ID used to build the standard library into I guess that would allow
But that seems too fragile to me. I prefer #47251 (don't default to |
Change https://go.dev/cl/452677 mentions this issue: |
This was an oversight from CL 452457 that I noticed while investigating #56889. This change essentially undoes CL 335409, which is no longer needed after CL 450739 because we no longer attempt to use cgo by default when no C compiler is present. Updates #47257. Updates #40042. Updates #47215. Change-Id: I29c7ce777a9ec7ba5820dc1d836b12a61b86bc37 Reviewed-on: https://go-review.googlesource.com/c/go/+/452677 Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Bryan Mills <[email protected]>
What version of Go are you using (
go version
)?I am running go 1.16.5, but I am also testing go 1.17rc1:
Does this issue reproduce with the latest release?
It's ok with the latest stable release (1.16.5), not with 1.17rc1
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOOS="linux"
I am running Archlinux, fully up to date as of July 15 2021, 10:15 BST. I am running in an LXD container (LXD 4.16)
go env
OutputWhat did you do?
This is the full script of what I ran:
What did you expect to see?
With go 1.16.5, the above program compiles with no error. I use only one external lib: github.com/lyderic/tools
What did you see instead?
With go 1.17rc1, I get the following error:
$ go1.17rc1 build
# runtime/cgo
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH
Note: if I install gcc, the error (obviously) goes away. However, the program compiles with no gcc installed if I compile with go 1.16.5, so there might be a bug.
Thanks
L.
The text was updated successfully, but these errors were encountered: