Go version
go version go1.21.4 linux/amd64
What operating system and processor architecture are you using (go env
)?
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/usr/local/google/home/gongt/.cache/go-build'
GOENV='/usr/local/google/home/gongt/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/usr/local/google/home/gongt/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/usr/local/google/home/gongt/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/google/home/gongt/goc'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/google/home/gongt/goc/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/usr/local/google/home/gongt/goc/src/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2742143614=/tmp/go-build -gno-record-gcc-switches'
What did you do?
On a clean checkout of go1.21.4
, run:
cd src
CC=clang CGO_ENABLED=0 ./make.bash
./run.bash
My clang version is 14.0.6.
What did you expect to see?
All tests pass.
What did you see instead?
--- FAIL: TestLibFuzzer (0.33s)
--- FAIL: TestLibFuzzer/libfuzzer1 (0.01s)
libfuzzer_test.go:49: /usr/local/google/home/gongt/goc/bin/go build -tags=libfuzzer -gcflags=-d=libfuzzer -buildmode=c-archive -o /tmp/TestLibFuzzer3296197254/libfuzzer1.a testdata/libfuzzer1.go exited with exit status 1
go: no Go source files
--- FAIL: TestLibFuzzer/libfuzzer2 (0.01s)
libfuzzer_test.go:49: /usr/local/google/home/gongt/goc/bin/go build -tags=libfuzzer -gcflags=-d=libfuzzer -buildmode=c-archive -o /tmp/TestLibFuzzer850547297/libfuzzer2.a testdata/libfuzzer2.go exited with exit status 1
go: no Go source files
--- FAIL: TestMSAN (0.27s)
msan_test.go:38: /usr/local/google/home/gongt/goc/bin/go build -msan std exited with exit status 2
go: -msan requires cgo; enable cgo by setting CGO_ENABLED=1
FAIL
FAIL cmd/cgo/internal/testsanitizers 0.648s
Comment From: ttttcrngyblflpp
Oh, forgot to mention that these tests pass if CC=gcc
for whatever reason.
Comment From: mauri870
It can be that CC=gcc trigger some code path that disable msan and fuzzer, given that -fsanitize=memory
and -fsanitize=fuzzer
are not supported by gcc, only clang.
Comment From: mauri870
So I think this is expected. If CC=clang it runs msan tests, which require CGO_ENABLED=1, so the error you get seems correct.
Comment From: mauri870
Well, now thinking more about it, if the user explicitly sets CGO_ENABLED=0, it indicates a preference to avoid running any tests that depend on cgo. Perhaps we should also consider skipping msan and fuzzer tests, given that we already skip race and asan tests under this condition.
cc @golang/runtime
Comment From: gopherbot
Change https://go.dev/cl/548715 mentions this issue: cmd/cgo/internal/testsanitizers: check for go build and cgo in fuzzer and msan tests
Comment From: cherrymui
All cmd/cgo/internal/ tests probably should be skipped if cgo is not enabled.