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

If using cgo, file paths in build errors contain a path to a random temporary directory #4160

Open
rickystewart opened this issue Oct 28, 2024 · 1 comment

Comments

@rickystewart
Copy link
Contributor

What version of rules_go are you using?

v0.50.1

What version of gazelle are you using?

0.39.1

What version of Bazel are you using?

7.2.1

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

Mac ARM64

Any other potentially useful information about your toolchain?

No

What did you do?

Perform a build with an error in .go code in a cgo-enabled package.

What did you expect to see?

The build error should contain filenames that are meaningful and relative to the workspace root.

What did you see instead?

/var/folders/xl/r959dlf13y968d0d30q1wbr40000gp/T/rules_go_work-2776474039/cgo/github.com/cockroachdb/cockroach/pkg/cli/start.go:283:2: foo declared and not used
/var/folders/xl/r959dlf13y968d0d30q1wbr40000gp/T/rules_go_work-2776474039/cgo/github.com/cockroachdb/cockroach/pkg/cli/start.go:283:9: undefined: bar

Internally, rules_go creates a temporary directory for these cgo files. The long random path (/var/folders/xl/...) here seems to be a path to this temporary directory. In this case, the "actual" filename that I care about is pkg/cli/start.go. Everything up to that point is unecessary.

In cockroach, we use this patch to circumvent this issue: cockroachdb@89aeb35 This essentially wipes the random temporary directory in the go tool compile output. I'm not sure whether you would want a PR with this change or if you would like to apply similar concepts to your own commit.

@fmeum
Copy link
Member

fmeum commented Oct 28, 2024

Yes, please send that patch as a PR. We might have to add some kind of an escape hatch that shows full paths for debugging purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants