From 1e11eaa902083e2b39234d264c046f1e31a3ec03 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Thu, 10 Nov 2022 12:30:05 -0500 Subject: [PATCH] cmd/go/internal/load: remove a special case for "unsafe" 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 Auto-Submit: Bryan Mills Run-TryBot: Bryan Mills Reviewed-by: Michael Matloob --- src/cmd/go/internal/load/pkg.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index da5b305dbb..b43b9d493b 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -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 {