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

Flip disallow empty glob #15327

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Flip disallow empty glob #15327

wants to merge 3 commits into from

Conversation

limdor
Copy link
Contributor

@limdor limdor commented Apr 24, 2022

This PR is to flip the default value of incompatible_disallow_empty_glob. This flag is tracked in #8195 and it is available since Bazel 0.29 from August 2019.
Once this is merged, users still can allow empty globs without being explicit setting --incompatible_disallow_empty_glob=false.

The motivation of the flip is bazel-contrib/SIG-rules-authors#37 and the fact of not keeping an incompatible flag for 4 years without flipping it.

What needs to be done before flipping this:

@limdor limdor marked this pull request as draft April 24, 2022 12:54
@limdor limdor force-pushed the patch-4 branch 3 times, most recently from cbba6ed to 8f44b3a Compare April 24, 2022 16:50
@sgowroji sgowroji added the awaiting-user-response Awaiting a response from the author label Apr 25, 2022
@sgowroji
Copy link
Member

Hello @limdor, Can you please check the above buildkite presubmit failures and resubmit again. Thanks!

@limdor
Copy link
Contributor Author

limdor commented Apr 25, 2022

@sgowroji it is not straightforward and hard to flip and fix everything at once. I created a pr that all checks are passing that move some of the changes there.
#15330
This one here is not ready to review. I've marked it as draft but feel free to put any labels to indicate that. Creating the PR was the only way I knew to run the presubmit checks.

@limdor
Copy link
Contributor Author

limdor commented Apr 25, 2022

I created another PR that prepare some other parts #15339

@limdor
Copy link
Contributor Author

limdor commented Sep 28, 2022

@sgowroji this is ready and the checks are passing. This could be taken as is or first the mentions PRs in the description could be merged.

@limdor limdor marked this pull request as ready for review September 28, 2022 14:30
@gtech-bazel-bot gtech-bazel-bot bot added the awaiting-review PR is awaiting review from an assigned reviewer label Sep 28, 2022
@sgowroji sgowroji removed the awaiting-user-response Awaiting a response from the author label Sep 28, 2022
@sgowroji sgowroji added the team-Android Issues for Android team label Sep 28, 2022
@limdor limdor force-pushed the patch-4 branch 2 times, most recently from 154dfa9 to 7b26587 Compare October 20, 2022 21:39
@sgowroji sgowroji added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label Jan 10, 2024
@Wyverald
Copy link
Member

Hey @limdor, we attempted internal merge but there were some test failures whose fixes were not immediately clear to me. I'm unfortunately quite swamped right now, so if you could find some time to sync this PR and fix the test failures, that'd be great! Otherwise, I'll probably get to this some time later.

@limdor
Copy link
Contributor Author

limdor commented Jan 16, 2024

@Wyverald then I will start rebasing this PR and seeing what is the CI saying about it

@limdor
Copy link
Contributor Author

limdor commented Jan 16, 2024

@Wyverald several tests seem to have an issue with rules_cc. They complain that https://github.com/bazelbuild/rules_cc/blob/main/cc/private/rules_impl/BUILD#L7 does not glob anything. I don't get why,

For another I added a separate commit to fix it 5d2cea6

Same BUILD file is used with data-1 and without data-1.
In the first bazel build data-1 is not there and the glob is empty.
In the second one, data-1 is there and it is not empty.
@fmeum
Copy link
Collaborator

fmeum commented Jan 17, 2024

@limdor That's because Bazel's Java tests don't see all of rules_cc, only the files listed here: https://cs.opensource.google/bazel/bazel/+/master:src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java;l=278?q=rules_impl&sq=&ss=bazel%2Fbazel

You could try adding at least one .bzl file to that list.

@Wyverald
Copy link
Member

Nice, all checks are passing. I'll retry the import. Thanks!

@limdor
Copy link
Contributor Author

limdor commented Jan 17, 2024

Thanks for the comment @fmeum. With that information was easy to fix.

@Wyverald
Copy link
Member

Status update: I spent some time trying to import this into Google, but it's surprisingly hard to flip the flag for Bazel only and not Blaze. (In slightly more detail: we have a .blazerc file in Google, which I have explicitly set to allow empty globs. But we have a plethora of integration test setups that all invoke Blaze in some sort of bespoke manner that does not include reading the .blazerc file. I quickly realized that it is not worth my time at all to make sure each of these invocations specify --noincompatible_disallow_empty_glob.)

So I'm probably going to do some hybrid thing, where I partially migrate Google off allow_empty_glob, at least the parts that are used by the Blaze integration tests. The rest we can do some other day.

@limdor
Copy link
Contributor Author

limdor commented Mar 5, 2024

@Wyverald do you have any updates on this?

@Wyverald
Copy link
Member

Wyverald commented Mar 5, 2024

sorry, no. I was whisked away by 7.1.0 work. Will have to come back to this after 7.1.0 is out (hopefully next week).

@brentleyjones
Copy link
Contributor

Really looking forward to this being flipped.

keith added a commit to llvm/llvm-project that referenced this pull request Mar 20, 2024
This bazel flag, that should be flipped in an upcoming release
bazelbuild/bazel#15327, fails if globs have no
matches. This helps find libraries where you are accidentally not
including files because of typos. This change removes the various globs
that were not matching anything, and uncovered some targets that were
doing nothing because their source files were deleted. There are a few
cases where globs were intentionally optional in the case of loops that
expanded to different potential options, so those now use
`allow_empty = True`. This allows downstream consumers to also flip this
flags for their own builds, where previously this would fail in LLVM
instead.

The downside to this change is that if files are added in these
relatively standard locations, manual work will have to be done to add
this patterns back. If folks prefer we could instead add
`allow_empty = True` to every glob.
keith added a commit to llvm/llvm-project that referenced this pull request Mar 22, 2024
This bazel flag, that should be flipped in an upcoming release
bazelbuild/bazel#15327, fails if globs have no
matches. This helps find libraries where you are accidentally not
including files because of typos. This change removes the various globs
that were not matching anything, and uncovered some targets that were
doing nothing because their source files were deleted. There are a few
cases where globs were intentionally optional in the case of loops that
expanded to different potential options, so those now use
`allow_empty = True`. This allows downstream consumers to also flip this
flags for their own builds, where previously this would fail in LLVM
instead.

The downside to this change is that if files are added in these
relatively standard locations, manual work will have to be done to add
this patterns back. If folks prefer we could instead add
`allow_empty = True` to every glob.
keith added a commit to llvm/llvm-project that referenced this pull request Mar 22, 2024
This bazel flag, that should be flipped in an upcoming release
bazelbuild/bazel#15327, fails if globs have no
matches. This helps find libraries where you are accidentally not
including files because of typos. This change removes the various globs
that were not matching anything, and uncovered some targets that were
doing nothing because their source files were deleted. There are a few
cases where globs were intentionally optional in the case of loops that
expanded to different potential options, so those now use
`allow_empty = True`. This allows downstream consumers to also flip this
flags for their own builds, where previously this would fail in LLVM
instead.

The downside to this change is that if files are added in these
relatively standard locations, manual work will have to be done to add
this patterns back. If folks prefer we could instead add
`allow_empty = True` to every glob.
keith added a commit to llvm/llvm-project that referenced this pull request Mar 22, 2024
This bazel flag, that should be flipped in an upcoming release
bazelbuild/bazel#15327, fails if globs have no
matches. This helps find libraries where you are accidentally not
including files because of typos. This change removes the various globs
that were not matching anything, and uncovered some targets that were
doing nothing because their source files were deleted. There are a few
cases where globs were intentionally optional in the case of loops that
expanded to different potential options, so those now use `allow_empty =
True`. This allows downstream consumers to also flip this flags for
their own builds, where previously this would fail in LLVM instead.

The downside to this change is that if files are added in these
relatively standard locations, manual work will have to be done to add
this patterns back. If folks prefer we could instead add `allow_empty =
True` to every glob.
chencha3 pushed a commit to chencha3/llvm-project that referenced this pull request Mar 23, 2024
This bazel flag, that should be flipped in an upcoming release
bazelbuild/bazel#15327, fails if globs have no
matches. This helps find libraries where you are accidentally not
including files because of typos. This change removes the various globs
that were not matching anything, and uncovered some targets that were
doing nothing because their source files were deleted. There are a few
cases where globs were intentionally optional in the case of loops that
expanded to different potential options, so those now use `allow_empty =
True`. This allows downstream consumers to also flip this flags for
their own builds, where previously this would fail in LLVM instead.

The downside to this change is that if files are added in these
relatively standard locations, manual work will have to be done to add
this patterns back. If folks prefer we could instead add `allow_empty =
True` to every glob.
@limdor
Copy link
Contributor Author

limdor commented Apr 21, 2024

@Wyverald do you have some update on this topic?

@Wyverald
Copy link
Member

Not yet. Turns out I'm quite busy for 7.2.0, too 😅 but I promise I'll do this in time for 8.0!

@alexeagle
Copy link
Contributor

@Wyverald I'm curious if your solution for this could be in the shape "ensure that all Blaze users are using the Blaze-team-provided <system>/.blazerc file" so that this is the last time we have such a painful flag flip. In the future it should always be "Bazel can have the reasonable default because Blaze easily chooses not to switch at that time"

@Wyverald
Copy link
Member

@Wyverald I'm curious if your solution for this could be in the shape "ensure that all Blaze users are using the Blaze-team-provided <system>/.blazerc file" so that this is the last time we have such a painful flag flip. In the future it should always be "Bazel can have the reasonable default because Blaze easily chooses not to switch at that time"

It's less about the human users of Blaze, but more about the integration tests we have. It's probably not even accurate to call them "integration tests" as they don't actually invoke Blaze as a whole; they pull out parts of Skyframe, inject different random things, (crucially) uses source files pulled directly from Google's monorepo for certain @bazel_tools-y things. And because they're not really integration tests, they don't read any blazerc files (they don't even exercise the code paths that parse RC files).

@limdor
Copy link
Contributor Author

limdor commented Apr 22, 2024

Hahahaha I know what you are talking about, this is the type of issues I was hitting with the public repository and now you have the same with the internal only ones

@alexeagle
Copy link
Contributor

Yeah the "public API" has leaked to the point that there's nowhere you can enforce that "usage of library code under this package assures that you also pick up the google3-wide configuration".
Of course this is terrible news for Bazel as it means we'll continue to have dozens of critical flags with the wrong default value.

I have another proposal. You could (ab)use the copybara transform to simply have the flag default value differ between Piper and GitHub. This gives you a similar semantic "google opts for a different global setting" but since it lives in the source file where the flag is applied it's guaranteed to be seen by all the callsites you're hitting.

ngiloq6 added a commit to ngiloq6/bazel-skylib that referenced this pull request Aug 17, 2024
In order to flip the flag, all downstream projects should be adapted. However, it is hard to fix them all if there are constant regressions. Adding it to the CI will ensure that once the project can build with incompatible_disallow_empty_glob it can keep building like that.
See: bazelbuild/bazel#15327
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants