Skip to content
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: C compiler "gcc" not found building non-cgo code #50183

Open
lyderic opened this issue Dec 15, 2021 · 8 comments
Open

cmd/go: C compiler "gcc" not found building non-cgo code #50183

lyderic opened this issue Dec 15, 2021 · 8 comments

Comments

@lyderic
Copy link

@lyderic lyderic commented Dec 15, 2021

What version of Go are you using (go version)?

$ ~/go/bin/go1.18beta1 version
go version go1.18beta1 linux/amd64

Does this issue reproduce with the latest release?

It reproduces with the latest beta of 1.18. However, it is fine with go 1.17.5!

What operating system and processor architecture are you using (go env)?

go env Output
$ ~/go/bin/go1.18beta1 version
go version go1.18beta1 linux/amd64
I [unix@go118 foo]$ ~/go/bin/go1.18beta1 env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/unix/.cache/go-build"
GOENV="/home/unix/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/unix/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/unix/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/unix/sdk/go1.18beta1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/unix/sdk/go1.18beta1/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18beta1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/unix/foo/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2623523050=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I tried to compile this program:

$ cat main.go 
package main

import (
        t "github.com/lyderic/tools"
)

func main() {
        t.Magentaln("FOO")
}

What did you expect to see?

I expected it to compile with go 1.18 as it compiles with go 1.17

What did you see instead?

I got the following error:

$ ~/go/bin/go1.18beta1 build
# runtime/cgo
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH

@lyderic lyderic changed the title affected/package: go 1.18 go 1.18 beta1: cgo: C compiler "gcc" not found Dec 15, 2021
@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Dec 15, 2021

Does you program use cgo anywhere? Is there any build tag that could cause different code to be built with Go 1.17 and Go 1.18? Thanks.

If you don't have a C compiler installed, maybe try setting CGO_ENABLED=0?

@lyderic
Copy link
Author

@lyderic lyderic commented Dec 15, 2021

I confirm that I don't have a C compiler installed. I never needed one, don't need one for go 1.17. I confirm also that I don't use cgo anywhere.

I can work around the problem indeed as follows:

$ CGO_ENABLED=0 ~/go/bin/go1.18beta1 build

However, I would say this is a regression problem as setting CGO_ENABLED is not needed when using go 1.17.

@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Dec 15, 2021

How was go1.18beta1 installed?

@lyderic
Copy link
Author

@lyderic lyderic commented Dec 15, 2021

I installed go 1.17 on Arch with pacman and I ran the following commands:

$ sudo pacman -Syyu go go-tools
$ go install golang.org/dl/go1.18beta1@latest
$ ~/go/bin/go1.18beta1 download
$ ~/go/bin/go1.18beta1 version
go version go1.18beta1 linux/amd64

@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Dec 15, 2021

Seems reproducible with just: (tried with both archlinux:base and debian container images)

package main

import _ "net/http"

func main() {}

@lyderic
Copy link
Author

@lyderic lyderic commented Dec 15, 2021

Please note that we had the same regression issue when we moved from 1.16 to 1.17: #47215

It had been fixed then.

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Dec 15, 2021

cc @bcmills as this is perhaps related to #47215

Also cc @golang/release for if there is anything related to building the release.

Marking as release blocker as it is a regression and was previously a release blocker.

@bcmills bcmills self-assigned this Dec 16, 2021
@aclements aclements changed the title go 1.18 beta1: cgo: C compiler "gcc" not found cmd/go: C compiler "gcc" not found building non-cgo code Jan 4, 2022
@heschi
Copy link
Contributor

@heschi heschi commented Jan 12, 2022

Ping: we think this is an RC blocker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants