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/compile: cannot build runtime in coverage mode on Wasm #70510

Open
Tracked by #271
Zxilly opened this issue Nov 21, 2024 · 7 comments
Open
Tracked by #271

cmd/compile: cannot build runtime in coverage mode on Wasm #70510

Zxilly opened this issue Nov 21, 2024 · 7 comments
Labels
arch-wasm WebAssembly issues compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@Zxilly
Copy link
Member

Zxilly commented Nov 21, 2024

Go version

go version go1.23.3 linux/s390x

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='s390x'
GOBIN=''
GOCACHE='/home/linux1/.cache/go-build'
GOENV='/home/linux1/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='s390x'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/linux1/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/linux1/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/snap/go/10737'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/snap/go/10737/pkg/tool/linux_s390x'
GOVCS=''
GOVERSION='go1.23.3'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/linux1/.config/go/telemetry'
GCCGO='gccgo'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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 -march=z196 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3325072388=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Run following command

git clone https://github.com/Zxilly/go-size-analyzer.git
GOOS=js GOARCH=wasm go test -v -covermode=atomic -cover -coverpkg=../../...

Then build failed.

What did you see happen?

# runtime
../../_tool/go/1.23.2/s390x/src/runtime/panic.go:652:10: write barrier prohibited by caller; preprintpanics
	../../_tool/go/1.23.2/s390x/src/runtime/panic.go:802:77: called by gopanic
	../../_tool/go/1.23.2/s390x/src/runtime/panic.go:171:7: called by goPanicSlice3AlenU
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:253:71: called by (*bucket).stk
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:309:68: called by stkbucket
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:854:16: called by saveBlockEventStack
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:840:21: called by (*mLockProfile).store
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:773:13: called by (*mLockProfile).recordUnlock
../../_tool/go/1.23.2/s390x/src/runtime/panic.go:819:12: write barrier prohibited by caller; (*_panic).start
	../../_tool/go/1.23.2/s390x/src/runtime/panic.go:779:9: called by gopanic
	../../_tool/go/1.23.2/s390x/src/runtime/panic.go:171:7: called by goPanicSlice3AlenU
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:253:71: called by (*bucket).stk
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:309:68: called by stkbucket
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:854:16: called by saveBlockEventStack
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:840:21: called by (*mLockProfile).store
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:773:13: called by (*mLockProfile).recordUnlock
../../_tool/go/1.23.2/s390x/src/runtime/panic.go:872:69: write barrier prohibited by caller; (*_panic).nextDefer
	../../_tool/go/1.23.2/s390x/src/runtime/panic.go:781:24: called by gopanic
	../../_tool/go/1.23.2/s390x/src/runtime/panic.go:171:7: called by goPanicSlice3AlenU
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:253:71: called by (*bucket).stk
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:309:68: called by stkbucket
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:854:16: called by saveBlockEventStack
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:840:21: called by (*mLockProfile).store
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:773:13: called by (*mLockProfile).recordUnlock
../../_tool/go/1.23.2/s390x/src/runtime/malloc.go:1187:19: write barrier prohibited by caller; mallocgc
	../../_tool/go/1.23.2/s390x/src/runtime/iface.go:360:74: called by convTnoptr
	../../_tool/go/1.23.2/s390x/src/runtime/panic.go:171:19: called by goPanicSlice3AlenU
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:253:71: called by (*bucket).stk
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:309:68: called by stkbucket
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:854:16: called by saveBlockEventStack
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:840:21: called by (*mLockProfile).store
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:773:13: called by (*mLockProfile).recordUnlock
../../_tool/go/1.23.2/s390x/src/runtime/runtime.go:172:8: write barrier prohibited by caller; (*godebugInc).IncNonDefault
	../../_tool/go/1.23.2/s390x/src/runtime/panic.go:740:26: called by gopanic
	../../_tool/go/1.23.2/s390x/src/runtime/panic.go:171:7: called by goPanicSlice3AlenU
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:253:71: called by (*bucket).stk
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:309:68: called by stkbucket
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:854:16: called by saveBlockEventStack
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:840:21: called by (*mLockProfile).store
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:773:13: called by (*mLockProfile).recordUnlock
../../_tool/go/1.23.2/s390x/src/runtime/trace.go:493:17: write barrier prohibited by caller; traceAdvance
	../../_tool/go/1.23.2/s390x/src/runtime/panic.go:795:15: called by gopanic
	../../_tool/go/1.23.2/s390x/src/runtime/panic.go:171:7: called by goPanicSlice3AlenU
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:253:71: called by (*bucket).stk
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:309:68: called by stkbucket
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:854:16: called by saveBlockEventStack
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:840:21: called by (*mLockProfile).store
	../../_tool/go/1.23.2/s390x/src/runtime/mprof.go:773:13: called by (*mLockProfile).recordUnlock
FAIL	github.com/Zxilly/go-size-analyzer [build failed]

What did you expect to see?

Works correctly

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Nov 21, 2024
@Zxilly
Copy link
Member Author

Zxilly commented Nov 21, 2024

cc @golang/s390x

@dmitshur dmitshur added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. arch-s390x Issues solely affecting the s390x architecture. labels Nov 21, 2024
@dmitshur dmitshur added this to the Backlog milestone Nov 21, 2024
@cherrymui
Copy link
Member

cherrymui commented Nov 23, 2024

I don't think this is S390X specific.
GOOS=js GOARCH=wasm go test -v -covermode=atomic -cover -coverpkg=all cmd/compile fails on my darwin/arm64 machine as well. So does GOOS=js GOARCH=wasm go build -cover runtime.

So it seems coverage mode doesn't fully work on Wasm, at least for the runtime package.

@cherrymui cherrymui added arch-wasm WebAssembly issues and removed arch-s390x Issues solely affecting the s390x architecture. labels Nov 23, 2024
@cherrymui cherrymui changed the title cmd/compile: failed to cross-compile to wasm on s390x cmd/compile: cannot build runtime in coverage mode on Wasm Nov 23, 2024
@Zxilly
Copy link
Member Author

Zxilly commented Nov 23, 2024

This is strange because these test codes have always passed on other architectures, including darwin arm64/amd64, windows/linux amd64. this error only occurs on the newly added s390x machine.

See Zxilly/go-size-analyzer#270

Maybe it's because of the different go versions? I will check these differences further.

I checked the ci logs and apparently they are all running under go 1.23.2.

@cherrymui
Copy link
Member

cherrymui commented Nov 23, 2024

Maybe it's because of the different go versions?

On my machine (darwin/arm64), GOOS=js GOARCH=wasm go1 build -cover runtime works for Go 1.21, but fails on 1.22. So there is indeed a version dependence... (and a regression)

Perhaps your -coverpkg=../../... matches different things on different machines depending on your local file tree?

What exactly do you want to cover? Why do you put .. in that pattern? (which looks weird to me)

@Zxilly
Copy link
Member Author

Zxilly commented Nov 23, 2024

I run a unit test within a sub-package, but would like to report on the coverage of this test within the entire repository. I don't remember finding any good way to fix this.

@cherrymui
Copy link
Member

If you want to cover (just) your module, -coverpkg=github.com/Zxilly/go-size-analyzer/... will probably do, regardless of your working directory.

git clone https://github.com/Zxilly/go-size-analyzer.git
GOOS=js GOARCH=wasm go test -v -covermode=atomic -cover -coverpkg=../../...

Which directory are you running the build from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly issues compiler/runtime Issues related to the Go compiler and/or runtime. 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

5 participants