-
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
Flip --experimental_sibling_repository_layout
to true
#23576
Comments
--experimental_sibling_repository_layout
--experimental_sibling_repository_layout
to true
While I would really like to see this flipped, I think that we are not yet ready to do so:
(?:bazel|blaze)-out/(?:(?<repo>[^/]+(?=/[^/]+-[^/]+/)(?!/coverage-metadata/))/)?[^/]+/[^/]+/(?<path>.+)")
|
@fmeum yes, I'm aware of all these downsides, especially the impending migration to bzlmod. Addressing these concerns in detail:
@meteorcloudy mind weighing in? |
What I wonder about in general: How important is reclaiming the |
Would #23518 completely address (1), or is there something else still missing? |
Not in its current form as it doesn't work for labels that produce multiple files. We may also need a way to get the relevant path for the current package without an explicit dependency on something (as required by location expansion). There are a few related issues files on the Bazel repo that ideally would be addressed holistically. |
@fmeum Thanks for the comprehensive analysis, it wasn't clear to me that all the breakages it would cause (most worried about breaking the runfiles library).
I think this is a very important question to answer. @lberki IIRC, there is currently no large project being blocked on this? At this point, I feel the cost of this change might significantly outweigh the benefits. If we do want to do it, we should probably come up with a better migration plan for all mentioned breakages, I'm not sure if we have enough time before Bazel 8 cut. |
A benefit could be that it simplifies the |
And is there any benefit from flipping |
It can drastically cut down the number of symlinks in the sandbox, which is a performance win. |
After discussing it with @meteorcloudy, I now think it's best to give up on this flag. I do realize this is reminiscent of the discussion we had on #20500, where we came to the conclusion that it's best to flip the flag, but then, we thought that making the downstream projects pipeline green is good enough, which is in theory the case, but we can't ignore all the incompatibilities this change would cause that we don't know about :( In addition, the new layout has shortcomings as @fmeum discussed above (there are good reasons why those shortcomings exist but they are shortcomings nevertheless) and those can only be solved by changing the layout, which would amount to an almost complete rewrite of the flag. Further, whereas the fact that one cannot have a directory called So for this flag, I propose that we give up on it, make it a no-op, then, if we do find a good reason to try again, we do so with a better layout (probably However, if we accept that this flag is best abandoned, it also calls into question the reason for I won't commit to this plan right now to give some room for protests, but given that the cost of flipping the flag is high (if done right) and that it's not perfect, it's hard to imagine an argument... |
In case the new layout is already widely used (I do suspect so), I wonder if we can keep both layouts and reduce symlinks by doing:
or
This will hopefully reduce the number of runfiles but keep things compatible. |
I don't think that consistency between execroot and runfiles tree matters much to users. In fact, I actually consider seeming consistency to be dangerous: runfiles paths would only look like exec paths for source files, but would still deviate for generated files. With The non-external runfiles layout is also much nicer to work with in isolation as Even with |
@fmeum I could be convinced either way (I'm not sure if the old or new locations are hard-wired more frequently), but I thought you specifically warned against flipping one flag but not the other at #23574 (comment) ? I think the non-external layout is by far nicer to work with (just like for repositories), the question is just how much cost the flag flip incurs vs. how much nicer it is. |
I just wanted to call out additional breakage points. But these are already weak points (e.g. a generated Java runtime won't be found in runfiles with Just based on my experience, I would consider hardcoding of the new runfiles layout to be far more prevalent than of the old layout. Many folks have the flag flipped already to speed up their large builds. It's mostly newcomers that pay the performance cost at this point, so I'm definitely in favor of flipping it. |
Ack, I thought that you think it's an especially bad breakage. I don't have data as to which approach would be less breaking, so I propose that we take a look at the Bazel downstream pipeline and make a decision based on the number of breakages there. @meteorcloudy WDYT? |
My reading is that if we did this flag flip some paths would become shorter, not longer. Just mentioning this as a consideration; on windows we have significant difficulties with tools unable to process files inside paths that are too long. Sad that these tools exist, but true. For us, these issues impact us more in the main workspace rather than external repos, but we certainly should try not to make paths longer. |
Totally understand that every character on Windows is very precious. But I think that mostly apply to the MSVC compiler and you can find workaround for most cases? As @fmeum pointed out in previous discussions, the new sibling layout has a few drawbacks that are hard to deal with, not mention the migration cost. So I don't think this is a strong argument to push --experimental_sibling_repository_layout through. |
One example that this flag is still useful is the "android-emulator-next" project (link), where we switched from cmake to bazel and rely on this flag to free up the Generally speaking, this is the only benefit of the flag but an important one for projects where an If this flag has to die, I would suggest providing some other means to access the |
@lberki How easy would it be to provide an option to rename the "external" directory to something like "bazel-external" or "_bazel_external"? |
@meteorcloudy annoying, but doable. The main problem with that is that it would necessarily have to be the decision made in the main repository, but one that would affect every other: say, if the main repository set Sure, they should not hard-wire the string |
One major reason why sibling repository breaks rules and builds is that, people rely on the documented directory layout when writing rules (e.g. extract a certain path fragment, assemble a path to a file, etc), and sibling repository changed that with per-repo bazel-bin, etc. The changes needed to make them work again with sibling repository is sometimes non-trivial (e.g. da9ef5b). Simply changing the directory name will in a lot of cases not breaking that assumption unless they hardcode Actually, you can even add a flag to set the name of that directory as user needs it - no conflicts ever again. @lberki any thoughts? |
@yuzhy8701 this is regrettable because this is the exact reason why I was originally so keen on flipping this flag: I couldn't have imagined that no one has a project that requires using the I don't think it's good idea to provide two mechanisms to piece together Bazel workspaces from multiple repositories because there is just too much room for adverse interaction between them and too much extra user interface. FWIW, a large part of the problem with sibling repository layout is that people do hardcode the So I'm afraid I don't have a very good alternative to you; in fact, @meteorcloudy @fmeum maybe you have a genius idea? |
No genius idea, but if we want to eventually support projects with an |
My model of the state of the world is that there aren't many reasons to harcode these things, people just do. I admit, though, that this is not based on any sort of data, it's only a suspicion. |
How about starting a discussion where we collect these cases? C++ rules are definitely a case where we need to offer a convenient alternative, but there could be more. |
I like this idea. It seems flexible. With this flag, the experimental_sibling_repository_layout flag could be left unflipped and removed. Is there ever a reason to support sibling layout if the 'external' name can be changed to avoid conflict? |
@peakschris see #23576 (comment) -- this is doable, but then every repository in the build would need to know what value the top-level project sets this string to. And if that's acceptable, we could just as well flip the flag as it is. |
Or the root project just have to patch their dependencies for this renaming? I think for a project wants to work around this limitation, that's a fair price they need to pay? @yuzhy8701 Do you think this is acceptable? |
@meteorcloudy Fair point.
That was my original point - if a project hardcodes |
@lberki OK, sounds like what we should do is
|
SG - and also,
|
The renaming flag seems like a good approach. To elaborate on this one piece:
We currently have 'external' hardcoded in two places: a) In a run_binary (from aspect) rule, in both args and env sections. A variable substitution would be needed |
@meteorcloudy if that's doable -- that string is embedded pretty deeply into Bazel and I'd not be surprised if some people even depended on the fact that the directory where external repositories are located in the output base ( I'll give it a stab as time allows to see how intrusive it would be and if it's even possible. I hope I can make it a regular command line option and not a startup one. |
Since #24126, non-main repos can now contain a top-level Have projects that currently use the flag tried to bring in their |
That approach has worked since ages immemorial, it's just that it's surprising and finicky. |
Motivation
To make the location of a file in the execroot the same regardless of whether it's in an external repository or the main one.
Description
Before the change, the source in the external repositories are located in the execroot at
$EXECROOT/<main repo>/external/<external repo>/<repo-relative path>
. This change turns that location into$EXECROOT/<external repo>/<repo-relative-path>
.Similarly, before the change, output files are located at
$EXECROOT/<main repo>/bazel-out/<config>/bin/external/<external repo>/<repo-relative path>
and this flag flip will turn that into$EXECROOT/<main repo>/bazel-out/<external repo>/<config>/bin/<repo-relative path>
.Incompatible Flag
--experimental_sibling_repository_layout
Migration Guide
This should mostly be a no-op change since everyone should refer to files using
file.path
in Starlark,$(location <label)
in genrules and getting their names from the BEP when outside of Bazel.If there are hard-coded paths in any of these places, they will need to be updated: preferably, to use one of these sanctioned approaches to learn the path or else hard-coding the new one, if that is not possible for some reason.
In which Bazel LTS version will this incompatible change be enabled?
Bazel 8
Additional Context
No response
TODO List
No response
The text was updated successfully, but these errors were encountered: