Skip to content

Commit f3c69c2

Browse files
callthingsoffprattmic
authored andcommitted
cmd/go/internal/load,cmd/link/internal/ld: use objabi.LookupPkgSpecial(pkg).Runtime
As suggested by Michael in CL 655515. Change-Id: Idf0b879287bd777d03443aebc7351fcb0d724885 GitHub-Last-Rev: 58eda02 GitHub-Pull-Request: #72806 Reviewed-on: https://go-review.googlesource.com/c/go/+/656856 Reviewed-by: David Chase <[email protected]> Reviewed-by: Michael Pratt <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent fb8691e commit f3c69c2

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

src/cmd/go/internal/load/pkg.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package load
77

88
import (
99
"bytes"
10+
"cmd/internal/objabi"
1011
"context"
1112
"encoding/json"
1213
"errors"
@@ -3561,7 +3562,7 @@ func SelectCoverPackages(roots []*Package, match []func(*Package) bool, op strin
35613562
// $GOROOT/src/internal/coverage/pkid.go dealing with
35623563
// hard-coding of runtime package IDs.
35633564
cmode := cfg.BuildCoverMode
3564-
if cfg.BuildRace && p.Standard && p.ImportPath == "runtime" {
3565+
if cfg.BuildRace && p.Standard && objabi.LookupPkgSpecial(p.ImportPath).Runtime {
35653566
cmode = "regonly"
35663567
}
35673568

src/cmd/link/internal/ld/data.go

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,8 @@ import (
5555
)
5656

5757
// isRuntimeDepPkg reports whether pkg is the runtime package or its dependency.
58-
// TODO: just compute from the runtime package, and remove this hardcoded list.
5958
func isRuntimeDepPkg(pkg string) bool {
60-
switch pkg {
61-
case "runtime",
62-
"sync/atomic", // runtime may call to sync/atomic, due to go:linkname // TODO: this is not true?
63-
"internal/abi", // used by reflectcall (and maybe more)
64-
"internal/asan",
65-
"internal/bytealg", // for IndexByte
66-
"internal/byteorder",
67-
"internal/chacha8rand", // for rand
68-
"internal/coverage/rtcov",
69-
"internal/cpu", // for cpu features
70-
"internal/goarch",
71-
"internal/godebugs",
72-
"internal/goexperiment",
73-
"internal/goos",
74-
"internal/msan",
75-
"internal/profilerecord",
76-
"internal/race",
77-
"internal/stringslite",
78-
"unsafe":
79-
return true
80-
}
81-
return strings.HasPrefix(pkg, "internal/runtime/") && !strings.HasSuffix(pkg, "_test")
59+
return objabi.LookupPkgSpecial(pkg).Runtime
8260
}
8361

8462
// Estimate the max size needed to hold any new trampolines created for this function. This

0 commit comments

Comments
 (0)