golang / golang/go

cmd/go: allow combining -race and -buildmode=PIE again

Open
#75,868 2 comments 0 reactions 1 assignee Claimed by @cherrymui View on GitHub
compiler/runtime GoCommand NeedsInvestigation ToolProposal
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.