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

Cannot disable checkptr in go 1.14 #2400

Closed
prestonvanloon opened this issue Mar 11, 2020 · 2 comments
Closed

Cannot disable checkptr in go 1.14 #2400

prestonvanloon opened this issue Mar 11, 2020 · 2 comments

Comments

@prestonvanloon
Copy link
Contributor

What version of rules_go are you using?

0.22.1

What version of gazelle are you using?

0.22.0

What version of Bazel are you using?

2.1.1

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

linux amd64

Any other potentially useful information about your toolchain?

What did you do?

go 1.14 enabled checkptr by default when compiling with -race or -msan. This check causes boltdb to fail at runtime (see etcd-io/bbolt#187). So I've tried to add gc_goopts to my test target (see: prysmaticlabs/prysm@b4f042e)

    gc_goopts = [
        "-d=checkptr=0",
    ],

However, this flag doesn't seem to be applied when bazel is building the testmain, while the race flag is still applied.

What did you expect to see?

gcflags applied to testmain compilation. -gcflags '-d=checkptr=0 -race'

What did you see instead?

Only race flags applied. -gcflags -race

@jayconrod
Copy link
Contributor

I tried to put together a smaller example.

-- BUILD.bazel --
load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
    name = "go_default_test",
    srcs = ["x_test.go"],
    gc_goopts = ["-d=checkptr=0"],
    race = "on",
)
-- x_test.go --
package x

import (
	"testing"
	"unsafe"
)

func Test(t *testing.T) {
	p := (*int)(unsafe.Pointer(uintptr(12345)))
	t.Logf("%p", p)
}

I've verified -d=checkptr=0 is passed when compiling the test package. The test passes with that flag, and it fails if the gc_goopts attribute is removed.

Why is it important though that -d=checkptr=0 is used when compiling the testmain package. It sounds like github.com/etcd-io/bbolt is the package that has the problem. Have you tried setting gc_goopts = ["-d=checkptr=0"] on that go_library? gc_goopts only applies to one package, not its dependencies.

@prestonvanloon
Copy link
Contributor Author

Ah! I thought compiler flag needed to be on the final compile and link step. Adding the flag to boltdb's go_library fixed my problem indeed. Thanks for looking into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants