You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It used to be that on macOS/amd64 I would not get a PIE binary, but as of 3 weeks ago that is not the case anymore: f7b4f02
This means that you always get a PIE binary when targeting macOS, even with the -race flag, yet if you explicitly specify that you want a PIE binary, it prints out an error. This is very confusing and should be fixed.
I suggest doing something like:
index cd99a33a21..a017b20e6b 100644
--- a/src/cmd/go/internal/work/init.go+++ b/src/cmd/go/internal/work/init.go@@ -264,8 +264,8 @@ func buildModeInit() {
pkgsFilter = oneMainPkg
}
case "pie":
- if cfg.BuildRace {- base.Fatalf("-buildmode=pie not supported when -race is enabled")+ if cfg.BuildRace && cfg.Goos != "darwin" {+ base.Fatalf("-buildmode=pie not supported when -race is enabled (except on macOS)")
}
if gccgo {
codegenArg = "-fPIE"
(note that the patch above is for Go 1.20 so it may be slightly different for the latest version)
The text was updated successfully, but these errors were encountered:
seankhliao
changed the title
affected/package: go build (allow -buildmode=pie with -race on macOS)
cmd/go: allow -buildmode=pie with -race on macOS
Aug 28, 2023
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
go build -buildmode=pie -race something.go
What did you expect to see?
The command to work without issues.
What did you see instead?
-buildmode=pie not supported when -race is enabled
Some more context:
On darwin/arm64 -buildmode=pie is fact required and is used by default. This means that even if I do
go build -race something.go
I still get a PIE binary. (see the code here: https://github.com/golang/go/blob/master/src/internal/platform/supported.go#L236)It used to be that on macOS/amd64 I would not get a PIE binary, but as of 3 weeks ago that is not the case anymore: f7b4f02
This means that you always get a PIE binary when targeting macOS, even with the -race flag, yet if you explicitly specify that you want a PIE binary, it prints out an error. This is very confusing and should be fixed.
I suggest doing something like:
(note that the patch above is for Go 1.20 so it may be slightly different for the latest version)
The text was updated successfully, but these errors were encountered: