Probe compiler support before passing -ffile-prefix-map
rules_go currently passes -ffile-prefix-map to the C/C++ compiler without checking whether the selected toolchain supports it:
https://github.com/bazel-contrib/rules_go/blob/caa2ca58cb8f1305a77eff41540441cdaf954e48/go/tools/builders/cgo2.go#L429-L441
This causes builds with older compiler toolchains (older than Clang 10 and GCC 8) to fail because the compiler does not support the flag.
Upstream Go handles this by probing compiler support and falling back to -fdebug-prefix-map when -ffile-prefix-map is unavailable: cmd/go implementation.
For parity with cmd/go, rules_go could use similar capability detection instead of assuming -ffile-prefix-map is supported.
If this approach makes sense, I'd be happy to put together a PR.
PR welcome!