aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/objabi
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2023-07-07 17:01:47 -0400
committerAustin Clements <austin@google.com>2023-08-22 19:18:34 +0000
commit56b3b244fdd7a50fcd9ffb20d7cfdbfae3af81f0 (patch)
treee209196818501db68c0a8f798bba7173d5c0bcaf /src/cmd/internal/objabi
parent83e0704c50c4269d90ec654b6590ae4db554f4eb (diff)
downloadgo-56b3b244fdd7a50fcd9ffb20d7cfdbfae3af81f0.tar.xz
cmd/internal/objabi,cmd/compile: move NoInstrumentPkgs and NoRacePkgs to PkgSpecials
This consolidates the NoInstrumentPkgs and NoRacePkgs lists into the objabi.LookupPkgSpecial mechanism. Change-Id: I411654afdd690fb01c412e7e8b57ddfbe85415e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/521702 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Austin Clements <austin@google.com>
Diffstat (limited to 'src/cmd/internal/objabi')
-rw-r--r--src/cmd/internal/objabi/pkgspecial.go39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/cmd/internal/objabi/pkgspecial.go b/src/cmd/internal/objabi/pkgspecial.go
index 144110b755..9bf07153a4 100644
--- a/src/cmd/internal/objabi/pkgspecial.go
+++ b/src/cmd/internal/objabi/pkgspecial.go
@@ -22,6 +22,17 @@ type PkgSpecial struct {
// set for additional packages.
Runtime bool
+ // NoInstrument indicates this package should not receive sanitizer
+ // instrumentation. In many of these, instrumentation could cause infinite
+ // recursion. This is all runtime packages, plus those that support the
+ // sanitizers.
+ NoInstrument bool
+
+ // NoRaceFunc indicates functions in this package should not get
+ // racefuncenter/racefuncexit instrumentation Memory accesses in these
+ // packages are either uninteresting or will cause false positives.
+ NoRaceFunc bool
+
// AllowAsmABI indicates that assembly in this package is allowed to use ABI
// selectors in symbol names. Generally this is needed for packages that
// interact closely with the runtime package or have performance-critical
@@ -47,6 +58,22 @@ var runtimePkgs = []string{
"internal/goos",
}
+// extraNoInstrumentPkgs is the set of packages in addition to runtimePkgs that
+// should have NoInstrument set.
+var extraNoInstrumentPkgs = []string{
+ "runtime/race",
+ "runtime/msan",
+ "runtime/asan",
+ // We omit bytealg even though it's imported by runtime because it also
+ // backs a lot of package bytes. Currently we don't have a way to omit race
+ // instrumentation when used from the runtime while keeping race
+ // instrumentation when used from user code. Somehow this doesn't seem to
+ // cause problems, though we may be skating on thin ice. See #61204.
+ "-internal/bytealg",
+}
+
+var noRaceFuncPkgs = []string{"sync", "sync/atomic"}
+
var allowAsmABIPkgs = []string{
"runtime",
"reflect",
@@ -74,7 +101,17 @@ func LookupPkgSpecial(pkgPath string) PkgSpecial {
pkgSpecials[elt] = s
}
for _, pkg := range runtimePkgs {
- set(pkg, func(ps *PkgSpecial) { ps.Runtime = true })
+ set(pkg, func(ps *PkgSpecial) { ps.Runtime = true; ps.NoInstrument = true })
+ }
+ for _, pkg := range extraNoInstrumentPkgs {
+ if pkg[0] == '-' {
+ set(pkg[1:], func(ps *PkgSpecial) { ps.NoInstrument = false })
+ } else {
+ set(pkg, func(ps *PkgSpecial) { ps.NoInstrument = true })
+ }
+ }
+ for _, pkg := range noRaceFuncPkgs {
+ set(pkg, func(ps *PkgSpecial) { ps.NoRaceFunc = true })
}
for _, pkg := range allowAsmABIPkgs {
set(pkg, func(ps *PkgSpecial) { ps.AllowAsmABI = true })