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

Race detector should not require cgo #38955

Closed
rittneje opened this issue May 8, 2020 · 1 comment
Closed

Race detector should not require cgo #38955

rittneje opened this issue May 8, 2020 · 1 comment

Comments

@rittneje
Copy link

rittneje commented May 8, 2020

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

$ go version
go version go1.13.10 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="/tmp/.gocache"
GOENV="/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH=""
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build323659760=/tmp/go-build -gno-record-gcc-switches"

What did you do?

CGO_ENABLED=0 go install -race <cmd>

What did you expect to see?

I expected it to create an executable without cgo that has race detection instrumentation.

We want to be able to run the resulting executable inside a FROM scratch docker container, so any dynamic linking against C libraries is not acceptable.

What did you see instead?

go install: -race requires cgo; enable cgo by setting CGO_ENABLED=1

If I turn on cgo, I can see there are some dynamically linked libraries, so the executable is not usable.

linux-vdso.so.1 (0x00007ffd8db6e000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fcf44b3e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcf4474d000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcf44d5d000)

@randall77
Copy link
Contributor

Dup of #9918 and #6508 .

@golang golang locked and limited conversation to collaborators May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants