From 9fbe0413b5ebe8082b446a9f62b2b27490ffac5d Mon Sep 17 00:00:00 2001 From: Kamil Rytarowski Date: Wed, 6 Dec 2017 00:35:23 +0100 Subject: [PATCH] Add initial TSan/NetBSD support Changes: - recognize NetBSD in -race sanitizer in internal/work/init.go - recognize and accept NetBSD/amd64 in src/race.bash - add symbol linkage __ps_string in runtime/cgo/netbsd.go - add NetBSD/amd64 in runtime/race/race.go Local src/runtime/race/race_netbsd_amd64.syso has been generated from LLVM compiler-rt SVN rev. 319795. Passed 340 of 347 tests (97.98%, 0+, 7-) 0 expected failures (0 has not fail) --- src/cmd/go/internal/work/init.go | 4 ++-- src/race.bash | 7 ++++++- src/runtime/cgo/netbsd.go | 2 ++ src/runtime/race/race.go | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/cmd/go/internal/work/init.go b/src/cmd/go/internal/work/init.go index 7f894f5c6d..1df9963521 100644 --- a/src/cmd/go/internal/work/init.go +++ b/src/cmd/go/internal/work/init.go @@ -43,8 +43,8 @@ func instrumentInit() { fmt.Fprintf(os.Stderr, "-msan is not supported on %s/%s\n", cfg.Goos, cfg.Goarch) os.Exit(2) } - if cfg.Goarch != "amd64" || cfg.Goos != "linux" && cfg.Goos != "freebsd" && cfg.Goos != "darwin" && cfg.Goos != "windows" { - 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]) + if cfg.Goarch != "amd64" || cfg.Goos != "linux" && cfg.Goos != "freebsd" && cfg.Goos != "netbsd" && cfg.Goos != "darwin" && cfg.Goos != "windows" { + 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]) os.Exit(2) } diff --git a/src/race.bash b/src/race.bash index adf2297c2f..84b8df24c7 100755 --- a/src/race.bash +++ b/src/race.bash @@ -9,7 +9,7 @@ set -e function usage { - echo 'race detector is only supported on linux/amd64, freebsd/amd64 and darwin/amd64' 1>&2 + echo 'race detector is only supported on linux/amd64, freebsd/amd64, netbsd/amd64 and darwin/amd64' 1>&2 exit 1 } @@ -30,6 +30,11 @@ case $(uname) in usage fi ;; +"NetBSD") + if [ $(uname -m) != "amd64" ]; then + usage + fi + ;; *) usage ;; diff --git a/src/runtime/cgo/netbsd.go b/src/runtime/cgo/netbsd.go index 2cecd0c57a..74d0aed014 100644 --- a/src/runtime/cgo/netbsd.go +++ b/src/runtime/cgo/netbsd.go @@ -14,6 +14,8 @@ import _ "unsafe" // for go:linkname //go:linkname _environ environ //go:linkname _progname __progname +//go:linkname ___ps_strings __ps_strings var _environ uintptr var _progname uintptr +var ___ps_strings uintptr diff --git a/src/runtime/race/race.go b/src/runtime/race/race.go index 15e20112a8..ac479fd65a 100644 --- a/src/runtime/race/race.go +++ b/src/runtime/race/race.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build race,linux,amd64 race,freebsd,amd64 race,darwin,amd64 race,windows,amd64 +// +build race,linux,amd64 race,freebsd,amd64 race,netbsd,amd64 race,darwin,amd64 race,windows,amd64 package race -- 2.15.0