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: "go test" needs gcc when importing "net" #33840

Closed
cespedes opened this issue Aug 26, 2019 · 3 comments
Closed

cmd/go: "go test" needs gcc when importing "net" #33840

cespedes opened this issue Aug 26, 2019 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@cespedes
Copy link

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

$ go version
go version go1.12.9 linux/amd64

Does this issue reproduce with the latest release?

Yes, tested with latest stable version (1.12.9).

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/cespedes/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/cespedes/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go-1.12"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.12/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build945969099=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ ls
foo.go
$ cat foo.go 
package foo

import _ "net"
$ go test foo.go 
# runtime/cgo
exec: "gcc": executable file not found in $PATH

"go build" runs without problems, but "go test" needs gcc.

AFAIK, this bug is the same as #27303, but not #26988. Both were closed, but the former is not fixed yet (at least with 1.12.9).

@bcmills bcmills changed the title "go test" needs gcc when importing "net" cmd/go: "go test" needs gcc when importing "net" Aug 26, 2019
@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 26, 2019
@bcmills bcmills added this to the Go1.14 milestone Aug 26, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@jingxu97
Copy link

jingxu97 commented Feb 1, 2020

Have the similar issue.
Based on #27303, the following works,
export CGO_ENABLED=0

But is this issue really solved?

@iwdgo
Copy link
Contributor

iwdgo commented Apr 3, 2022

Issue does not occur probably since https://go-review.googlesource.com/c/go/+/335409/
but other changes have occur.
Error now returned for case provided ? command-line-arguments [no test files] which seems appropriate.

@rsc
Copy link
Contributor

rsc commented Dec 12, 2022

I believe this was already fixed, but Go 1.20 will fix this again by automatically disabling cgo if there is no C compiler.

@rsc rsc closed this as completed Dec 12, 2022
@golang golang locked and limited conversation to collaborators Dec 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants