Skip to content

Commit 17f1964

Browse files
committed
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. Signed-off-by: Kamil Rytarowski <[email protected]>
1 parent 7093171 commit 17f1964

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
@@ -43,8 +43,8 @@ func instrumentInit() {
4343
fmt.Fprintf(os.Stderr, "-msan is not supported on %s/%s\n", cfg.Goos, cfg.Goarch)
4444
os.Exit(2)
4545
}
46-
if cfg.Goarch != "amd64" || cfg.Goos != "linux" && cfg.Goos != "freebsd" && cfg.Goos != "darwin" && cfg.Goos != "windows" {
47-
fmt.Fprintf(os.Stderr, "go %s: -race and -msan are only supported on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64\n", flag.Args()[0])
46+
if cfg.Goarch != "amd64" || cfg.Goos != "linux" && cfg.Goos != "freebsd" && cfg.Goos != "netbsd" && cfg.Goos != "darwin" && cfg.Goos != "windows" {
47+
fmt.Fprintf(os.Stderr, "go %s: -race and -msan are only supported on linux/amd64, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64\n", flag.Args()[0])
4848
os.Exit(2)
4949
}
5050

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, freebsd/amd64 and darwin/amd64' 1>&2
12+
echo 'race detector is only supported on linux/amd64, 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
5+
// +build race,linux,amd64 race,freebsd,amd64 race,netbsd,amd64 race,darwin,amd64 race,windows,amd64
66

77
package race
88

0 commit comments

Comments
 (0)