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

Ability to trimpath a different path in addition to default is not functioning #4161

Open
jhance opened this issue Oct 29, 2024 · 2 comments

Comments

@jhance
Copy link

jhance commented Oct 29, 2024

What version of rules_go are you using?

0.46

What version of Bazel are you using?

6.1.0

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

I am very confident because of the problem I point out at the end of this issue

What operating system and processor architecture are you using?

Linux/x86_64

What did you do?

I am compiling a go_library that contains source files that are both in-tree as normal and some that are genrule outputs. However, I am having trouble getting the paths trimmed in the resulting archive. I am using go tool nm to list the symbols and grepping for gofile. Normally, it trims the paths for the normal files and the paths for the genruled files contain the bindir, which is not desirable as it depends on transition state.

I tried passing something like gc_goopts = ["-trimpath=$(BINDIR)=>."].

What did you expect to see?

I expected to see that the genfiles had their paths trimmed. This was true.

What did you see instead?

However, the normal files did not have their paths trimmed anymore (meaning I fixed half of the files and broke the other half). In addition the bindir substitution was wrong, it replaced BINDIR with .:. instead of ..

The result is that this archive cannot be shared between plugins and a main binary because of a version mismatch.

This colon is presumably from https://github.com/bazel-contrib/rules_go/blob/master/go/tools/builders/compilepkg.go#L512. Clearly its not being processed as a delimiter. According to https://github.com/golang/go/blob/master/src/cmd/internal/objabi/line.go#L70 the delimiter is actually a semicolon. Sadly, I tried editing rules_go to use a semicolon and it still doesn't work (the default trimpath isn't being applied still)

@jhance
Copy link
Author

jhance commented Oct 29, 2024

In addition upon reviewing the output of actually trying to use $(BINDIR) as the trimpath I realized that although it removes the k8-fastbuild case it doesn't work when theres actually a transition because $(BINDIR) is not the correct transition directory for the input... and now I am even more lost as to how to possibly fix this. Maybe can run a glob at compilepkg time to pick up all possible transition dirs that need to be filtered out?

@fmeum
Copy link
Member

fmeum commented Oct 31, 2024

Could you send a PR to fix the delimiter?

Why do you need to trim the bindir? You wrote that it's undesirable because it encodes "transition state", but what's the concrete problem this is causing you?

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