Skip to content

Commit

Permalink
cmd/go: enable -msan on freebsd/amd64
Browse files Browse the repository at this point in the history
Enable -msan flag on freebsd/amd64 and amend PIE comment in
internal/work/init.go to indicate that MSAN requires PIE on all platforms
except linux/amd64.

R=go1.20

For #53298

Change-Id: I93d94efa95d7f292c23c433fb1d3f4301d820bde
Reviewed-on: https://go-review.googlesource.com/c/go/+/411275
Reviewed-by: Bryan Mills <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
dmgk committed Oct 14, 2022
1 parent 5fde02e commit e56c93f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/cmd/go/alldocs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/cmd/go/internal/work/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ and test commands:
linux/ppc64le and linux/arm64 (only for 48-bit VMA).
-msan
enable interoperation with memory sanitizer.
Supported only on linux/amd64, linux/arm64
Supported only on linux/amd64, linux/arm64, freebsd/amd64
and only with Clang/LLVM as the host C compiler.
On linux/arm64, pie build mode will be used.
PIE build mode will be used on all platforms except linux/amd64.
-asan
enable interoperation with address sanitizer.
Supported only on linux/arm64, linux/amd64.
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/go/internal/work/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ func instrumentInit() {
mode := "race"
if cfg.BuildMSan {
mode = "msan"
// MSAN does not support non-PIE binaries on ARM64.
// See issue #33712 for details.
if cfg.Goos == "linux" && cfg.Goarch == "arm64" && cfg.BuildBuildmode == "default" {
// MSAN needs PIE on all platforms except linux/amd64.
// https://github.com/llvm/llvm-project/blob/llvmorg-13.0.1/clang/lib/Driver/SanitizerArgs.cpp#L621
if cfg.BuildBuildmode == "default" && (cfg.Goos != "linux" || cfg.Goarch != "amd64") {
cfg.BuildBuildmode = "pie"
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/internal/platform/supported.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func MSanSupported(goos, goarch string) bool {
switch goos {
case "linux":
return goarch == "amd64" || goarch == "arm64"
case "freebsd":
return goarch == "amd64"
default:
return false
}
Expand Down

0 comments on commit e56c93f

Please sign in to comment.