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

Non-go deps built twice with gotags #3430

Closed
ripatel-fd opened this issue Jan 24, 2023 · 5 comments
Closed

Non-go deps built twice with gotags #3430

ripatel-fd opened this issue Jan 24, 2023 · 5 comments

Comments

@ripatel-fd
Copy link

What version of rules_go are you using?

v0.38.0

What version of Bazel are you using?

6.0.0

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

Yes

What operating system and processor architecture are you using?

amd64 RHEL 8

Any other potentially useful information about your toolchain?

GCC 8.5.0

What did you do?

Run https://github.com/terorie/rules_go_bug

What did you expect to see?

Dep tree as follows go_test -> go_library -> cc_library.

The go_test has one string in gotags set.

When I bazel build the go_test and go_library, I expect cc_library to be only built once.

What did you see instead?

cc_library is built twice.

Related

@ripatel-fd ripatel-fd changed the title Non-go deps are built twice when used with Non-go deps built twice with gotags Jan 24, 2023
@ripatel-fd
Copy link
Author

cc @fmeum @illicitonion I hope this bug report helps. I would be happy to fix it myself but I lack understanding of how transitions work in rules_go

@fmeum
Copy link
Member

fmeum commented Jan 24, 2023

I don't think this is a regression. With v0.33.0, which doesn't contain b0b7d85, running bazel build --nobuild //... && bazel cquery //clib:clib (twice, not sure why that's necessary), you can see that the C library is built twice.

The fix is to use a recent version of rules_go, Bazel 6, and the flag --experimental_output_directory_naming_scheme=diff_against_baseline. I am working on getting this enabled by default in Bazel 6.1.

@ripatel-fd
Copy link
Author

ripatel-fd commented Jan 24, 2023

Thanks a lot 🙏 So is this a problem with Bazel, not rules_go?

@fmeum
Copy link
Member

fmeum commented Jan 24, 2023

Well, let's call it a missing optimization. But yes, short of ditching transitions entirely or using quite complex and fragile tricks, there is nothing rules_go can do about this by itself.

@fmeum
Copy link
Member

fmeum commented Nov 8, 2023

Will be fixed by default in Bazel 7 and can be fixed by setting --experimental_output_directory_naming_scheme=diff_against_dynamic_baseline in Bazel 6.4.0.

@fmeum fmeum closed this as completed Nov 8, 2023
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