]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/go: enable -msan on freebsd/amd64
authorDmitri Goutnik <dgoutnik@gmail.com>
Wed, 8 Jun 2022 15:55:42 +0000 (10:55 -0500)
committerDmitri Goutnik <dgoutnik@gmail.com>
Fri, 14 Oct 2022 12:48:27 +0000 (12:48 +0000)
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 <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/cmd/go/alldocs.go
src/cmd/go/internal/work/build.go
src/cmd/go/internal/work/init.go
src/internal/platform/supported.go

index 6a348dbb75df01b9f1bb4b135f193858741df182..a8206c475ccc6fc20ba89a32274047c3055ee470 100644 (file)
 //             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.
index 6a83ec6232fe78b95a929e45e5aa8366538dddfd..d27d114d912d6d9b4e47de68adf58d2904b33ba8 100644 (file)
@@ -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.
index 458a81bead96321913013f6c264dbca3a9dfce92..cfd5a505d3706e93cc637a73caafdad02b33fa18 100644 (file)
@@ -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"
                }
        }
index c9264c03ee2da628e5b2b59d10cbd9c93c97ae9d..fddc5441235d9587c0db7ab02239f08318a836aa 100644 (file)
@@ -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
        }