bazel-contrib / bazel-contrib/rules_go
gc_goopts seems buggy or has unexpected behavior
- Dominant language
- Go
- Stars
- 1.5k
- Forks
- 760
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 12
Description
### What version of rules_go are you using?
0.42
### What version of gazelle are you using?
0.33
### What version of Bazel are you using?
6.2.1
### Does this issue reproduce with the latest releases of all the above?
I haven't checked, but presumably yes.
### What operating system and processor architecture are you using?
macOS arm64
### Any other potentially useful information about your toolchain?
None
### What did you do?
Try to run `bazel build ... "--@io_bazel_rules_go//go/config:gc_goopts=all=-N -l"`
### What did you expect to see?
Successful build with `-N` and `-l` set for `-gcflags`
### What did you see instead?
A bunch of errors that look like this:
```
# log/slog/internal
open all=-N -l: no such file or directory
# reflect/internal/example2
open all=-N -l: no such file or directory
# runtime/race
open all=-N -l: no such file or directory
# maps
open all=-N -l: no such file or directory
```
I also tried with a few variations on the quoting (`--@io_bazel_rules_go//go/config:gc_goopts="all=-N -l"`, `--@io_bazel_rules_go//go/config:gc_goopts='"all=-N -l"'`), and none of them seem to work.
It seems like these arguments aren't getting propagated down to `-gcflags` correctly and are instead getting interpreted by the compiler as filenames. I can't speak to why that happens.
If you're passing only a single argument to `gc_goopts` (like `--@io_bazel_rules_go//go/config:gc_goopts=-S`), it seems to work fine.
(I understand that `--@io_bazel_rules_go//go/config:debug` is an appropriate workaround for `-N -l` specifically, however, it seems like the basic approach using `gc_goopts` should still work either way.)
Contributor guide
Research direction
Start by reproducing the Bazel command using the gc_goopts entry point and compare how a single option such as -S reaches -gcflags with the multi-option value all=-N -l. Trace the argument propagation and verify completion when both compiler options are passed correctly and the build succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100