-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Always collect FileProvider's filesToBuild as data runfiles #15052
Conversation
5385e74
to
c7d937d
Compare
c7d937d
to
f9dbbe8
Compare
src/test/java/com/google/devtools/build/lib/starlark/StarlarkIntegrationTest.java
Outdated
Show resolved
Hide resolved
This looks reasonable. Mind that we're rewriting all the rules where this applies to Starlark. I'll run internal unit tests, to see if this breaks anything, but I don't expect it to. |
There are some breakages on internal unit tests, but it seems just the tests have to be updated. |
f9dbbe8
to
40552e4
Compare
Thanks! |
40552e4
to
98e13a1
Compare
@comius Did you get a chance to look into the internal unit tests blocking this? |
I've put this on my backlog, I will need to do a bit more research and that will take more time. What happens is that And |
@comius Is there anything I can do to help get this into 5.3.0? The issue fixed by the PR is, based on my personal experience, one of the top gotchas for users writing their first custom rules (including myself and many of my coworkers at some point). It also frequently comes up on the Bazel Slack (most recently at https://bazelbuild.slack.com/archives/CA31HN1T3/p1657044541910759?thread_ts=1657044541.910759&cid=CA31HN1T3). Getting it fixed in Bazel 5 would also help rule authors ditch Would it help if I guarded the change behind a flag that you could flip back inside Google? Or, alternatively, can the failing tests be open-sourced? I could then try to fix the runfile pollution issues in the cc rules. |
98e13a1
to
ca229a4
Compare
@comius Friendly ping. This is still coming up on Bazel Slack over and over again as a major inconsistency. Do you think we can get this into Bazel 6? It looks like Starlark |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did the changes needed internally - and I'm waiting for feedback from reviewers.
src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
Outdated
Show resolved
Hide resolved
ca229a4
to
f8bbf1d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a lot of failures running this change through the depot, I still need to analyse them thought.
It makes sense to put this behind an incompatible flag - because others might have similar problems (and if I don't fix all the failures internally we can still release this in Bazel).
One bug that I already located in the run and you can probably fix from stack trace:
Caused by: java.lang.IllegalArgumentException: Order mismatch: preorder != postorder
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:441)
at com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder.addTransitive(NestedSetBuilder.java:138)
at com.google.devtools.build.lib.analysis.Runfiles$Builder.addTransitiveArtifacts(Runfiles.java:777)
at com.google.devtools.build.lib.analysis.Runfiles$Builder.addTargetIncludingFileTargets(Runfiles.java:988)
at com.google.devtools.build.lib.analysis.Runfiles$Builder.addTarget(Runfiles.java:964)
at com.google.devtools.build.lib.analysis.Runfiles$Builder.addTargets(Runfiles.java:957)
at com.google.devtools.build.lib.analysis.Runfiles$Builder.addDataDeps(Runfiles.java:938)
at com.google.devtools.build.lib.analysis.Runfiles$Builder.addRunfiles(Runfiles.java:910)
at com.google.devtools.build.lib.view.sh.ShBinary.create(ShBinary.java:71)
at com.google.devtools.build.lib.view.sh.ShBinary.create(ShBinary.java:30)
at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createRule(ConfiguredTargetFactory.java:371)
I'm actually quite confused by the stack trace: I expected both |
You can rewrap NestedSet to a stable order which will prevent the exception. Example is Runfiles.addTransitiveArtifactsWrappedInStableOrder |
f8bbf1d
to
9ca4dc7
Compare
Guidelines for Starlark rules suggest that `data`-like attributes on rules should always merge the default outputs of rule targets into the transitive runfiles. See: https://docs.bazel.build/versions/main/skylark/rules.html#runfiles-features-to-avoid As a result, Starlark rules generally don't (and shouldn't) explicitly include their default outputs into their runfiles. Before this commit, native rules did not merge these outputs in the same way as idiomatic Starlark rules, which led to unexpectedly absent runfiles. RELNOTES: Native rules now add `DefaultInfo.files` of data dependencies to their runfiles, which matches the recommended behavior for Starlark rules (https://bazel.build/extending/rules#runfiles_features_to_avoid). This new behavior can be controlled via `--incompatible_always_include_files_in_data`.
469914b
to
841c19b
Compare
841c19b
to
27e3ee9
Compare
@comius @meteorcloudy Sorry, forgot to update the tests. Should be fixed now. |
@fmeum Can you follow https://bazel.build/contribute/breaking-changes to file a tracking issue for this incompatible change? Once this is merged, I'll add the correct labels and it'll be tested in the incompatible flag pipeline |
@meteorcloudy I created #16654. |
@bazel-io flag |
@meteorcloudy This has been merged, could you add it to the pipeline? |
@bazel-io fork 6.0.0 |
Guidelines for Starlark rules suggest that `data`-like attributes on rules should always merge the default outputs of rule targets into the transitive runfiles. See: https://docs.bazel.build/versions/main/skylark/rules.html#runfiles-features-to-avoid As a result, Starlark rules generally don't (and shouldn't) explicitly include their default outputs into their runfiles. Before this commit, native rules did not merge these outputs in the same way as idiomatic Starlark rules, which led to unexpectedly absent runfiles. Fixes bazelbuild#15043 Closes bazelbuild#15052. PiperOrigin-RevId: 486663801 Change-Id: I4a30b8b8a4dfc84bf4de27fd7894dd48e795c081
@fmeum This flag is already tested in https://buildkite.com/bazel/bazelisk-plus-incompatible-flags/builds/1325, currently failing with "Unrecognized option" error, we'll get some real result tomorrow ;) |
Guidelines for Starlark rules suggest that `data`-like attributes on rules should always merge the default outputs of rule targets into the transitive runfiles. See: https://docs.bazel.build/versions/main/skylark/rules.html#runfiles-features-to-avoid As a result, Starlark rules generally don't (and shouldn't) explicitly include their default outputs into their runfiles. Before this commit, native rules did not merge these outputs in the same way as idiomatic Starlark rules, which led to unexpectedly absent runfiles. Fixes bazelbuild#15043 Closes bazelbuild#15052. PiperOrigin-RevId: 486663801 Change-Id: I4a30b8b8a4dfc84bf4de27fd7894dd48e795c081
Guidelines for Starlark rules suggest that `data`-like attributes on rules should always merge the default outputs of rule targets into the transitive runfiles. See: https://docs.bazel.build/versions/main/skylark/rules.html#runfiles-features-to-avoid As a result, Starlark rules generally don't (and shouldn't) explicitly include their default outputs into their runfiles. Before this commit, native rules did not merge these outputs in the same way as idiomatic Starlark rules, which led to unexpectedly absent runfiles. Fixes bazelbuild#15043 Closes bazelbuild#15052. PiperOrigin-RevId: 486663801 Change-Id: I4a30b8b8a4dfc84bf4de27fd7894dd48e795c081
Guidelines for Starlark rules suggest that `data`-like attributes on rules should always merge the default outputs of rule targets into the transitive runfiles. See: https://docs.bazel.build/versions/main/skylark/rules.html#runfiles-features-to-avoid As a result, Starlark rules generally don't (and shouldn't) explicitly include their default outputs into their runfiles. Before this commit, native rules did not merge these outputs in the same way as idiomatic Starlark rules, which led to unexpectedly absent runfiles. Fixes bazelbuild#15043 Closes bazelbuild#15052. PiperOrigin-RevId: 486663801 Change-Id: I4a30b8b8a4dfc84bf4de27fd7894dd48e795c081
Guidelines for Starlark rules suggest that `data`-like attributes on rules should always merge the default outputs of rule targets into the transitive runfiles. See: https://docs.bazel.build/versions/main/skylark/rules.html#runfiles-features-to-avoid As a result, Starlark rules generally don't (and shouldn't) explicitly include their default outputs into their runfiles. Before this commit, native rules did not merge these outputs in the same way as idiomatic Starlark rules, which led to unexpectedly absent runfiles. Fixes #15043 Closes #15052. PiperOrigin-RevId: 486663801 Change-Id: I4a30b8b8a4dfc84bf4de27fd7894dd48e795c081
Guidelines for Starlark rules suggest that
data
-like attributes onrules should always merge the default outputs of rule targets into the
transitive runfiles. See:
https://docs.bazel.build/versions/main/skylark/rules.html#runfiles-features-to-avoid
As a result, Starlark rules generally don't (and shouldn't) explicitly
include their default outputs into their runfiles. Before this commit,
native rules did not merge these outputs in the same way as idiomatic
Starlark rules, which led to unexpectedly absent runfiles.
Fixes #15043