Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go: support passing arbitrary compiler flags #17439

Closed
Tracked by #17447
tdyas opened this issue Nov 2, 2022 · 0 comments · Fixed by #17683
Closed
Tracked by #17447

go: support passing arbitrary compiler flags #17439

tdyas opened this issue Nov 2, 2022 · 0 comments · Fixed by #17683
Labels
backend: Go Go backend-related issues

Comments

@tdyas
Copy link
Contributor

tdyas commented Nov 2, 2022

go build accepts a -gcflags argument to pass flags to the underlying Go compiler invocations (i.e., go tool compile). Pants should support a mechanism to do that as well.

Model as fields on go_binary and go_package (for tests) to add compiler options with defaults provided via option(s).

@tdyas tdyas added the backend: Go Go backend-related issues label Nov 2, 2022
tdyas added a commit that referenced this issue Dec 1, 2022
…ags (#17683)

Add `compiler_flags` field for adding arbitrary extra compiler flags when compiling Go files.

Design:
- When `compiler_flags` is specified on a `go_mod` target, the flags are added for all compilation involving that Go module (including third-party dependencies).
- When `compiler_flags` is specified on a `go_binary` target, the flags are added for all compilation involved in building that Go binary (including third-party dependencies). These flags are added in addition to any flags specified via setting `compiler_flags` on the applicable `go_mod` target.
- When `compiler_flags` is specified on a `go_package` target, the flags are added only for the compilation of that specific package. These flags are added in addition to any flags specified via setting `compiler_flags` on the applicable `go_mod` and/or `go_binary` targets.

Fixes #17439
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: Go Go backend-related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant