]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/work: use pie link mode when using MSAN on arm64
authorfanzha02 <fannie.zhang@arm.com>
Thu, 8 Aug 2019 01:21:46 +0000 (01:21 +0000)
committerIan Lance Taylor <iant@golang.org>
Wed, 11 Sep 2019 14:29:18 +0000 (14:29 +0000)
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: Ian Lance Taylor <iant@golang.org>
src/cmd/go/alldocs.go
src/cmd/go/internal/work/build.go
src/cmd/go/internal/work/init.go

index ebbead5d3169a53fe97df56cfaa096c0a7d31abd..2caa8e78f4c60ed2beb822f508daf9501f1f2f27 100644 (file)
 //             The default is the number of CPUs available.
 //     -race
 //             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
 //             enable interoperation with memory sanitizer.
 //             Supported only on linux/amd64, linux/arm64
 //             and only with Clang/LLVM as the host C compiler.
+//             On linux/arm64, pie build mode will be used.
 //     -v
 //             print the names of packages as they are compiled.
 //     -work
index 9305b2d859c549356f1e0739aeb2d9e7e29bc4e3..9d6fa0c25bf65408125ae2294906840275683a65 100644 (file)
@@ -62,11 +62,13 @@ and test commands:
                The default is the number of CPUs available.
        -race
                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
                enable interoperation with memory sanitizer.
                Supported only on linux/amd64, linux/arm64
                and only with Clang/LLVM as the host C compiler.
+               On linux/arm64, pie build mode will be used.
        -v
                print the names of packages as they are compiled.
        -work
index c220d87123efd5540eedf96694c02461e9d08726..548e73515fe40d204e6d1f40ede2bcd5005b26b2 100644 (file)
@@ -60,6 +60,11 @@ 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" {
+                       cfg.BuildBuildmode = "pie"
+               }
        }
        modeFlag := "-" + mode