cmd/go: allow combining -race and -buildmode=PIE again
- Dominant language
- Go
- Stars
- 139k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
### Go version
Go 1.26-dev
### Output of `go env` in your module/workspace:
```shell
N/A
```
### What did you do?
cc @cherrymui
The following is not supported:
```bash
$ go build -race -buildmode=pie hello.go
-buildmode=pie not supported when -race is enabled on linux/amd64
```
### What did you see happen?
The go tool does not allow it.
### What did you expect to see?
It probably should be allowed.
For reference, it was disabled in https://go.dev/cl/41333 for #20038. Back then (in 2017), @dvyukov stated that the race detector did not support PIE. I believe this has changed:
- We've run internal tests (using raw `go tool compile` and `go tool link`) which indicate that this works now (on linux/amd64).
- Platforms that default to PIE, like Darwin, have allowed PIE+race since https://go.dev/cl/523475 (2023, #62318).
Contributor guide
Assessment
This issue has not been assessed yet.