Commit 23f73986 authored by fanzha02's avatar fanzha02 Committed by Ian Lance Taylor

cmd/go/internal/work: use pie link mode when using MSAN on arm64

Currently, when running the "CC=clang go run -msan misc/cgo/
testsanitizers/testdata/msan.go" command on arm64, it will
report an error and the error is reported by llvm/compiler-rt/
lib/msan and it is "Make sure to compile with -fPIE and to link
with -pie".

This CL fixes this issue, using PIE link mode when using MSAN
on arm64.

This CL also updates the related document and go build help message.

Fixes #33712

Change-Id: I0cc9d95f3fa264d6c042c27a40ccbb82826922fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/190482
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent f6c691e0
...@@ -110,11 +110,13 @@ ...@@ -110,11 +110,13 @@
// The default is the number of CPUs available. // The default is the number of CPUs available.
// -race // -race
// enable data race detection. // enable data race detection.
// Supported only on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64. // Supported only on linux/amd64, freebsd/amd64, darwin/amd64, windows/amd64,
// linux/ppc64le and linux/arm64 (only for 48-bit VMA).
// -msan // -msan
// enable interoperation with memory sanitizer. // enable interoperation with memory sanitizer.
// Supported only on linux/amd64, linux/arm64 // Supported only on linux/amd64, linux/arm64
// and only with Clang/LLVM as the host C compiler. // and only with Clang/LLVM as the host C compiler.
// On linux/arm64, pie build mode will be used.
// -v // -v
// print the names of packages as they are compiled. // print the names of packages as they are compiled.
// -work // -work
......
...@@ -62,11 +62,13 @@ and test commands: ...@@ -62,11 +62,13 @@ and test commands:
The default is the number of CPUs available. The default is the number of CPUs available.
-race -race
enable data race detection. enable data race detection.
Supported only on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64. Supported only on linux/amd64, freebsd/amd64, darwin/amd64, windows/amd64,
linux/ppc64le and linux/arm64 (only for 48-bit VMA).
-msan -msan
enable interoperation with memory sanitizer. enable interoperation with memory sanitizer.
Supported only on linux/amd64, linux/arm64 Supported only on linux/amd64, linux/arm64
and only with Clang/LLVM as the host C compiler. and only with Clang/LLVM as the host C compiler.
On linux/arm64, pie build mode will be used.
-v -v
print the names of packages as they are compiled. print the names of packages as they are compiled.
-work -work
......
...@@ -60,6 +60,11 @@ func instrumentInit() { ...@@ -60,6 +60,11 @@ func instrumentInit() {
mode := "race" mode := "race"
if cfg.BuildMSan { if cfg.BuildMSan {
mode = "msan" 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" {
cfg.BuildBuildmode = "pie"
}
} }
modeFlag := "-" + mode modeFlag := "-" + mode
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment