cmd/go: default to "exe" build mode for windows -race

This patch changes the default build mode from "pie" to "exe" when
building programs on windows with "-race" in effect. The Go command
already issues an error if users explicitly ask for -buildmode=pie in
combination with -race on windows, but wasn't revising the default
"pie" build mode if a specific buildmode was not requested.

Updates #53539.
Updates #35006.

Change-Id: I2f81a41a1d15a0b4f5ae943146175c5a1202cbe0
Reviewed-on: https://go-review.googlesource.com/c/go/+/416174
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
This commit is contained in:
Than McIntosh 2022-07-06 07:45:19 -04:00
parent 1243ec9c17
commit eaf2125654

View file

@ -211,7 +211,11 @@ func buildModeInit() {
codegenArg = "-shared"
ldBuildmode = "pie"
case "windows":
ldBuildmode = "pie"
if cfg.BuildRace {
ldBuildmode = "exe"
} else {
ldBuildmode = "pie"
}
case "ios":
codegenArg = "-shared"
ldBuildmode = "pie"