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 -race' fails with 'relocation target __popcountdi2 not defined' when GCC not installed #56937

Closed
candlerb opened this issue Nov 25, 2022 · 2 comments
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. RaceDetector
Milestone

Comments

@candlerb
Copy link

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

$ go version
go version go1.19.3 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/brian/.cache/go-build"
GOENV="/home/brian/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/brian/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/brian/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/brian/z/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 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3661110452=/tmp/go-build -gno-record-gcc-switches"

NOTE: this is running on an ubuntu-minimal lxd container (22.04.1) which does not have gcc installed.

What did you do?

$ cat go.mod
module example.com/test

go 1.19

$ cat main_test.go
package main

$ go test -race . -vet=off
# example.com/test.test
runtime/race(.text): relocation target __popcountdi2 not defined
FAIL	example.com/test [build failed]
FAIL

There is a separate but possibly related problem #56755, which is why -vet=off is required. Without it:

$ go test -race .
# runtime/cgo
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH
FAIL	example.com/test [build failed]
FAIL

What did you expect to see?

Successful test execution.

Or: documentation that the race detector does not work without GCC. I checked here and here.

What did you see instead?

See above.

Possibly relates to #3261 (old ticket, but it does reference missing __popcountdi2 explicitly)

@candlerb candlerb changed the title cmd/go: go test -race fails with relocation target __popcountdi2 not defined when GCC not installed cmd/go: 'go test -race' fails with 'relocation target __popcountdi2 not defined' when GCC not installed Nov 25, 2022
@ianlancetaylor
Copy link
Contributor

In general using -race does require that cgo be enabled, which does require that GCC be available. This is #6508. This requirement is documented at https://go.dev/doc/articles/race_detector#Requirements, but looking at that I see that it is unclear unless you understand that cgo requires a C compiler. I'll send a patch.

@gopherbot
Copy link

Change https://go.dev/cl/453435 mentions this issue: _content/doc/articles/race_detector: cgo requires a C compiler

@dmitshur dmitshur added Documentation NeedsFix The path to resolution is known, but the work has not been done. labels Nov 25, 2022
@dmitshur dmitshur added this to the Unreleased milestone Nov 25, 2022
@golang golang locked and limited conversation to collaborators Nov 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. RaceDetector
Projects
None yet
Development

No branches or pull requests

4 participants