From: Michael Hudson-Doyle Date: Thu, 28 Apr 2016 22:37:37 +0000 (+1200) Subject: cmd/link: fix -no-pie / -race check X-Git-Tag: go1.7beta1~418 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=cb97fd7741fc8bfa257bb020dab756a14c420daf;p=gostls13.git cmd/link: fix -no-pie / -race check golang.org/cl/22453 was supposed to pass -no-pie to the linker when linking a race-enabled binary if the host toolchain supports it. But I bungled the supported check as I forgot to pass -c to the host compiler so it tried to compile a 0 byte .c file into an executable, which will never work. Fix it to pass -c as it should have all along. Change-Id: I4801345c7a29cb18d5f22cec5337ce535f92135d Reviewed-on: https://go-review.googlesource.com/22587 Run-TryBot: Michael Hudson-Doyle TryBot-Result: Gobot Gobot Reviewed-by: Minux Ma --- diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 53428bb1c6..f6c7a0152b 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -1213,7 +1213,7 @@ func hostlink() { if err := ioutil.WriteFile(src, []byte{}, 0666); err != nil { Ctxt.Diag("WriteFile trivial.c failed: %v", err) } - cmd := exec.Command(argv[0], "-no-pie", "trivial.c") + cmd := exec.Command(argv[0], "-c", "-no-pie", "trivial.c") cmd.Dir = tmpdir out, err := cmd.CombinedOutput() supported := err == nil && !bytes.Contains(out, []byte("unrecognized"))