Skip to content

Commit f5921d4

Browse files
krytarowskibradfitz
authored andcommitted
runtime/cgo: Add initial NetBSD Thread Sanitizer support
Recognize NetBSD in: - go/internal/work/init.go - race.bash - runtime/race/race.go Add __ps_strings symbol in runtime/cgo/netbsd.go as this is used internally in the TSan library for NetBSD and used for ReExec(). Tested on NetBSD/amd64 v. 8.99.12. Around 98% tests are passing for the ./race.bash target. Updates #19273 Change-Id: Ic0e48d2fb159a7868aab5e17156eeaca1225e513 GitHub-Last-Rev: d6e0827 GitHub-Pull-Request: #24322 Reviewed-on: https://go-review.googlesource.com/99835 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
1 parent 9776d02 commit f5921d4

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

src/cmd/go/internal/work/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ func instrumentInit() {
4747
platform := cfg.Goos + "/" + cfg.Goarch
4848
switch platform {
4949
default:
50-
fmt.Fprintf(os.Stderr, "go %s: -race is only supported on linux/amd64, linux/ppc64le, freebsd/amd64, darwin/amd64 and windows/amd64\n", flag.Args()[0])
50+
fmt.Fprintf(os.Stderr, "go %s: -race is only supported on linux/amd64, linux/ppc64le, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64\n", flag.Args()[0])
5151
os.Exit(2)
52-
case "linux/amd64", "linux/ppc64le", "freebsd/amd64", "darwin/amd64", "windows/amd64":
52+
case "linux/amd64", "linux/ppc64le", "freebsd/amd64", "netbsd/amd64", "darwin/amd64", "windows/amd64":
5353
// race supported on these platforms
5454
}
5555
}

src/race.bash

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
set -e
1010

1111
function usage {
12-
echo 'race detector is only supported on linux/amd64, linux/ppc64le, freebsd/amd64 and darwin/amd64' 1>&2
12+
echo 'race detector is only supported on linux/amd64, linux/ppc64le, freebsd/amd64, netbsd/amd64 and darwin/amd64' 1>&2
1313
exit 1
1414
}
1515

@@ -30,6 +30,11 @@ case $(uname) in
3030
usage
3131
fi
3232
;;
33+
"NetBSD")
34+
if [ $(uname -m) != "amd64" ]; then
35+
usage
36+
fi
37+
;;
3338
*)
3439
usage
3540
;;

src/runtime/cgo/netbsd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import _ "unsafe" // for go:linkname
1414

1515
//go:linkname _environ environ
1616
//go:linkname _progname __progname
17+
//go:linkname ___ps_strings __ps_strings
1718

1819
var _environ uintptr
1920
var _progname uintptr
21+
var ___ps_strings uintptr

src/runtime/race/race.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build race,linux,amd64 race,freebsd,amd64 race,darwin,amd64 race,windows,amd64 race,linux,ppc64le
5+
// +build race,linux,amd64 race,freebsd,amd64 race,netbsd,amd64 race,darwin,amd64 race,windows,amd64 race,linux,ppc64le
66

77
package race
88

0 commit comments

Comments
 (0)