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 all packages #23180

Closed
aarzilli opened this issue Dec 19, 2017 · 3 comments
Closed

cmd/go: go test -c does not apply specified gcflags to all packages #23180

aarzilli opened this issue Dec 19, 2017 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
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 +3aeb395 Mon Dec 18 20:24:12 2017 +0000 linux/amd64

What did you do?

This is very similar to #22831, that problem was fixed however if I run go test -gcflags='all=-N -l' with https://github.com/aarzilli/testflags I expect to see all the compile units in the resulting binary have the flags -N and -l applied to them, but one is spared:

 <0><8fc96>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <8fc97>   DW_AT_name        : github.com/aarzilli/testflags
    <8fcb5>   DW_AT_language    : 22    (Go)
    <8fcb6>   DW_AT_stmt_list   : 0x16b8d
    <8fcba>   DW_AT_low_pc      : 0x531650
    <8fcc2>   DW_AT_ranges      : 0x530
    <8fcc6>   DW_AT_comp_dir    : .
    <8fcc8>   DW_AT_producer    : Go cmd/compile devel +3aeb395 Mon Dec 18 20:24:12 2017 +0000

also all functions in that compile unit are assigned to the package github.com/aarzilli/testflags when really they were defined in main.

@bradfitz bradfitz added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Dec 19, 2017
@bradfitz bradfitz added this to the Go1.10 milestone Dec 19, 2017
@aarzilli
Copy link
Contributor Author

aarzilli commented Jan 2, 2018

I looked a bit into this, it turns out that the flags are actually applied to all packages, the reason they are not reported in debug_info is because the compiler for testflags is called with -p main which means the producer symbol is called go.cuinfo.producer.main, but then the linker imports it as github.com/aarzilli/testflags which means the linker will look for go.cuinfo.producer.github.com/aarzilli/testflags.

This part:

all functions in that compile unit are assigned to the package github.com/aarzilli/testflags when really they were defined in main.

isn't new to 1.10, 1.9 also did this.

@rsc
Copy link
Contributor

rsc commented Jan 4, 2018

Thanks for chasing this down. CL sent to fix the -p option in this case.

@gopherbot
Copy link

Change https://golang.org/cl/86235 mentions this issue: cmd/go: fix compile -p flag for building test of main package

@golang golang locked and limited conversation to collaborators Jan 4, 2019
@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.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

4 participants