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: duplicate symbols when including two main packages in -coverpkg in module mode [1.12 backport] #30684

Closed
gopherbot opened this issue Mar 8, 2019 · 3 comments
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge
Milestone

Comments

@gopherbot
Copy link

@bcmills requested issue #30374 to be considered for backport to the next 1.12 minor release.

@gopherbot, please backport to 1.12. This is a significant regression from GOPATH mode and the fix is straightforward.

@gopherbot gopherbot added the CherryPickCandidate Used during the release process for point releases label Mar 8, 2019
@gopherbot gopherbot added this to the Go1.12.1 milestone Mar 8, 2019
@bcmills bcmills added the CherryPickApproved Used during the release process for point releases label Mar 8, 2019
@gopherbot gopherbot removed the CherryPickCandidate Used during the release process for point releases label Mar 8, 2019
@bcmills
Copy link
Contributor

bcmills commented Mar 8, 2019

@jayconrod, see http://golang.org/wiki/MinorReleases#making-cherry-pick-cls for instructions on how to cherry-pick the fix.

@gopherbot
Copy link
Author

Change https://golang.org/cl/166318 mentions this issue: [release-branch.go1.12] cmd/go: avoid link errors when -coverpkg covers main packages

@gopherbot
Copy link
Author

Closed by merging a40b76a to release-branch.go1.12.

gopherbot pushed a commit that referenced this issue Mar 13, 2019
…rs main packages

The -coverpkg lets users specify a list of packages that should have
coverage instrumentation. This may include packages not transitively
imported by tests. For each tested package, the synthetic main package
imports all covered packages so they can be registered with
testing.RegisterCover. This makes it possible for a main package to
import another main package.

When we compile a package with p.Internal.BuildInfo set (set on main
packages by Package.load in module mode), we set
runtime/debug.modinfo. Multiple main packages may be passed to the
linker because of the above scenario, so this causes duplicate symbol
errors.

This change copies p.Internal.BuildInfo to the synthetic main package
instead of the internal test package. Additionally, it forces main
packages imported by the synthetic test main package to be recompiled
for testing. Recompiled packages won't have p.Internal.BuildInfo set.

Fixes #30684

Change-Id: I06f028d55905039907940ec89d2835f5a1040203
Reviewed-on: https://go-review.googlesource.com/c/go/+/164877
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit 10156b6)
Reviewed-on: https://go-review.googlesource.com/c/go/+/166318
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Mar 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

2 participants