Skip to content

Commit 23f7398

Browse files
zhangfannieianlancetaylor
authored andcommitted
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent f6c691e commit 23f7398

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/cmd/go/alldocs.go

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/go/internal/work/build.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ and test commands:
6262
The default is the number of CPUs available.
6363
-race
6464
enable data race detection.
65-
Supported only on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64.
65+
Supported only on linux/amd64, freebsd/amd64, darwin/amd64, windows/amd64,
66+
linux/ppc64le and linux/arm64 (only for 48-bit VMA).
6667
-msan
6768
enable interoperation with memory sanitizer.
6869
Supported only on linux/amd64, linux/arm64
6970
and only with Clang/LLVM as the host C compiler.
71+
On linux/arm64, pie build mode will be used.
7072
-v
7173
print the names of packages as they are compiled.
7274
-work

src/cmd/go/internal/work/init.go

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ func instrumentInit() {
6060
mode := "race"
6161
if cfg.BuildMSan {
6262
mode = "msan"
63+
// MSAN does not support non-PIE binaries on ARM64.
64+
// See issue #33712 for details.
65+
if cfg.Goos == "linux" && cfg.Goarch == "arm64" && cfg.BuildBuildmode == "default" {
66+
cfg.BuildBuildmode = "pie"
67+
}
6368
}
6469
modeFlag := "-" + mode
6570

0 commit comments

Comments
 (0)