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 -c does not apply specified gcflags to the test package #22831

Closed
aarzilli opened this issue Nov 21, 2017 · 3 comments
Closed
Milestone

Comments

@aarzilli
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

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

go version devel +5f29a7a Mon Nov 20 20:29:43 2017 +0000 linux/amd64

What did you do?

go get github.com/aarzilli/testflags
cd $GOPATH/src/github.com/aarzilli/testflags
go clean -cache && go test -c -gcflags '-N -l'

What did you expect to see?

flags -N -l applied to the test package (i.e. the one defined in main_test.go)

What did you see instead?

The flags are applied to github.com/aarzilli/testflags but not to the test package.

@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone Nov 21, 2017
@rsc
Copy link
Contributor

rsc commented Dec 1, 2017

Indeed. Will fix.

@gopherbot
Copy link

Change https://golang.org/cl/81496 mentions this issue: cmd/go: apply same per-package flags to test and xtest builds

@gopherbot
Copy link

Change https://golang.org/cl/83879 mentions this issue: cmd/go: apply same per-package flags to compile and link of test

gopherbot pushed a commit that referenced this issue Dec 14, 2017
If package strings has a particular set of gcflags, then the strings_test
pseudo-package built as part of the test binary started inheriting the
same flags in CL 81496, to fix #22831.

Now the package main and final test binary link built as part of the
strings test binary also inherit the same flags, to fix #22994.

I am slightly uneasy about reusing package strings's flags for
package main, but the alternative would be to introduce some
kind of special case, which I'd be even more uneasy about.

This interpretation preserves the Go 1.9 behavior of existing
commands like:

	go test -c -ldflags=-X=mypkg.debugString=foo mypkg

Fixes #22994.

Change-Id: I9ab83bf1a9a6adae530a7715b907e709fd6c1b5d
Reviewed-on: https://go-review.googlesource.com/83879
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@golang golang locked and limited conversation to collaborators Dec 14, 2018
@rsc rsc removed their assignment Jun 23, 2022
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

4 participants