mirror of
https://github.com/golang/go
synced 2024-11-23 19:50:06 -07:00
go/build: omit PkgObj for packages "unsafe" and "builtin"
Package "builtin" is not a real, importable package; it exists only for documentation. Package "unsafe" is not compiled into an object file from its source code; instead, imports of "unsafe" are handled specially by the compiler. (In Go 1.19.3, package "unsafe" did not have an install target, while package "builtin" did but that target was never written.) Fixes #56687. Updates #47257. Change-Id: I1d1e90ff9e1629b80e0df93e1f7e17242c8dab69 Reviewed-on: https://go-review.googlesource.com/c/go/+/449376 Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
b820fb8df1
commit
05cc8b5369
@ -436,7 +436,7 @@ func (rp *IndexPackage) Import(bctxt build.Context, mode build.ImportMode) (p *b
|
|||||||
p.PkgTargetRoot = ctxt.joinPath(p.Root, pkgtargetroot)
|
p.PkgTargetRoot = ctxt.joinPath(p.Root, pkgtargetroot)
|
||||||
|
|
||||||
// Set the install target if applicable.
|
// Set the install target if applicable.
|
||||||
if strings.ToLower(godebug.Get("installgoroot")) == "all" || !p.Goroot {
|
if !p.Goroot || (strings.EqualFold(godebug.Get("installgoroot"), "all") && p.ImportPath != "unsafe" && p.ImportPath != "builtin") {
|
||||||
p.PkgObj = ctxt.joinPath(p.Root, pkga)
|
p.PkgObj = ctxt.joinPath(p.Root, pkga)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
[short] skip
|
[short] skip
|
||||||
[!cgo] skip
|
|
||||||
|
|
||||||
# Most packages in std do not have an install target.
|
# Most packages in std do not have an install target.
|
||||||
go list -f '{{.Target}}' fmt
|
go list -f '{{.Target}}' fmt
|
||||||
@ -8,11 +7,11 @@ go list -export -f '{{.Export}}' fmt
|
|||||||
stdout $GOCACHE
|
stdout $GOCACHE
|
||||||
|
|
||||||
# Packages that use cgo still do.
|
# Packages that use cgo still do.
|
||||||
go list -f '{{.Target}}' runtime/cgo
|
[cgo] go list -f '{{.Target}}' runtime/cgo
|
||||||
stdout .
|
[cgo] stdout .
|
||||||
go list -export -f '{{.Export}}' runtime/cgo
|
[cgo] go list -export -f '{{.Export}}' runtime/cgo
|
||||||
! stdout $GOCACHE
|
[cgo] ! stdout $GOCACHE
|
||||||
stdout cgo\.a
|
[cgo] stdout cgo\.a
|
||||||
|
|
||||||
# With GODEBUG=installgoroot=all, fmt has a target.
|
# With GODEBUG=installgoroot=all, fmt has a target.
|
||||||
# (Though we can't try installing it without modifying goroot).
|
# (Though we can't try installing it without modifying goroot).
|
||||||
@ -20,6 +19,11 @@ env GODEBUG=installgoroot=all
|
|||||||
go list -f '{{.Target}}' fmt
|
go list -f '{{.Target}}' fmt
|
||||||
stdout fmt\.a
|
stdout fmt\.a
|
||||||
|
|
||||||
|
# However, the fake packages "builtin" and "unsafe" do not.
|
||||||
|
go list -f '{{.Target}}' builtin unsafe
|
||||||
|
! stdout .
|
||||||
|
go install builtin unsafe # Should succeed as no-ops.
|
||||||
|
|
||||||
# With CGO_ENABLED=0, packages that would have
|
# With CGO_ENABLED=0, packages that would have
|
||||||
# an install target with cgo on no longer do.
|
# an install target with cgo on no longer do.
|
||||||
env GODEBUG=
|
env GODEBUG=
|
||||||
|
@ -783,7 +783,7 @@ Found:
|
|||||||
p.PkgTargetRoot = ctxt.joinPath(p.Root, pkgtargetroot)
|
p.PkgTargetRoot = ctxt.joinPath(p.Root, pkgtargetroot)
|
||||||
|
|
||||||
// Set the install target if applicable.
|
// Set the install target if applicable.
|
||||||
if strings.ToLower(godebug.Get("installgoroot")) == "all" || !p.Goroot {
|
if !p.Goroot || (strings.EqualFold(godebug.Get("installgoroot"), "all") && p.ImportPath != "unsafe" && p.ImportPath != "builtin") {
|
||||||
p.PkgObj = ctxt.joinPath(p.Root, pkga)
|
p.PkgObj = ctxt.joinPath(p.Root, pkga)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user