]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/load: remove a special case for "unsafe"
authorBryan C. Mills <bcmills@google.com>
Thu, 10 Nov 2022 17:30:05 +0000 (12:30 -0500)
committerGopher Robot <gobot@golang.org>
Thu, 10 Nov 2022 19:14:42 +0000 (19:14 +0000)
We had a special case to zero out the Target field for package
"unsafe", which is not imported from a normal object file.

As of CL 449376 that special case has been folded into go/build's
logic for setting the PkgObj field, so the special case in
cmd/go/internal/load has become redundant.

(Noticed while investigating CL 449376.)

Updates #47257.
Updates #56687.

Change-Id: I1668123aa6230097aa75e55380d3e2c7937c4b64
Reviewed-on: https://go-review.googlesource.com/c/go/+/449515
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
src/cmd/go/internal/load/pkg.go

index da5b305dbbf87dfe6c1431ce97362231966955da..b43b9d493b3333c43c1a1e04a5358c82a8edd68c 100644 (file)
@@ -1814,6 +1814,9 @@ func (p *Package) load(ctx context.Context, opts PackageOpts, path string, stk *
                // Local import turned into absolute path.
                // No permanent install target.
                p.Target = ""
+       } else if p.Standard && cfg.BuildContext.Compiler == "gccgo" {
+               // gccgo has a preinstalled standard library that cmd/go cannot rebuild.
+               p.Target = ""
        } else {
                p.Target = p.Internal.Build.PkgObj
                if cfg.BuildBuildmode == "shared" && p.Internal.Build.PkgTargetRoot != "" {
@@ -1989,11 +1992,6 @@ func (p *Package) load(ctx context.Context, opts PackageOpts, path string, stk *
                p.setBuildInfo(opts.AutoVCS)
        }
 
-       // unsafe is a fake package.
-       if p.Standard && (p.ImportPath == "unsafe" || cfg.BuildContext.Compiler == "gccgo") {
-               p.Target = ""
-       }
-
        // If cgo is not enabled, ignore cgo supporting sources
        // just as we ignore go files containing import "C".
        if !cfg.BuildContext.CgoEnabled {