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

Execution root symlink forest includes all files in a package instead of only ones needed #19581

Open
erikkerber opened this issue Sep 21, 2023 · 13 comments
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Local-Exec Issues and PRs for the Execution (Local) team type: bug

Comments

@erikkerber
Copy link

erikkerber commented Sep 21, 2023

Description of the bug:

When running a build, the symlink forest will include all files from a package beyond files actually needed, used, or referenced by a build.

This leads to various quality-of-life, and reproducibility issues.

An example of the output base from the open source rules_xcodeproj looks like this when a target in the root package is built:

CleanShot 2023-09-21 at 10 44 10@2x

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  • Clone rules_xcodeproj
  • bazel build tools:xcodeproj
  • cd into bazel-output-base/execroot/_main/
    • Notice the execroot has symlinked two packages used in that build
  • cd back to the workspace root
  • bazel build buildifier.check
    • Notice the execroot has symlnked all files in the root, including BUILD files and .git directories

Which operating system are you running Bazel on?

macOS 14.0

What is the output of bazel info release?

release 6.4.0rc1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

This has existed for a while as a nuisance (if you traverse bazel-out), it almost always tricks tools into thinking it's a Git directory, but became a more acute problem in the iOS community with Xcode 15 as the IDE performance is extremely degraded trying to parse what Git views as an extremely large Git diff in the output base.

bazelbuild.slack.com discussion

@brentleyjones brentleyjones changed the title Execution root symlink forest includes all file in a package instead of only ones needed Execution root symlink forest includes all files in a package instead of only ones needed Sep 21, 2023
@iancha1992 iancha1992 added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label Sep 21, 2023
@iancha1992 iancha1992 added team-Local-Exec Issues and PRs for the Execution (Local) team and removed team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. labels Sep 21, 2023
@joeleba joeleba self-assigned this Sep 26, 2023
@joeleba joeleba added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Sep 26, 2023
@erikkerber
Copy link
Author

This appears to reproduce in all scenarios in Bazel 7 (tested on rc3).

In other words, both bazel build tools:xcodeproj and bazel build buildifier.check in the repro steps above result in all files and directories in the repository being symlinked.

@joeleba
Copy link
Member

joeleba commented Nov 10, 2023

This is unfortunately a known limitation of skymeld (#14057), which is on by default in Bazel 7. In this mode, we create a symlink to each entry under the source root.

If this breaks you, please include --noexperimental_merged_skyframe_analysis_execution in your blazerc to disable skymeld.

If I understand correctly, the main nuisance here is with the .git file also being symlinked to from the execroot, right?

@brentleyjones
Copy link
Contributor

If I understand correctly, the main nuisance here is with the .git file also being symlinked to from the execroot, right?

Yes. If minimally that wasn't symlinked, we would be fine. One step more would to also not symlink anything in .bazelignore. Ideally only files that need to be symlinked are symlinked.

@brentleyjones
Copy link
Contributor

brentleyjones commented Nov 10, 2023

If this breaks you, please include --noexperimental_merged_skyframe_analysis_execution in your blazerc to disable skymeld.

Sadly I will have to include that by default for rules_xcodeproj if this ships this way. It breaks Xcode as is.

@joeleba joeleba added P1 I'll work on this now. (Assignee required) and removed P2 We'll consider working on this in future. (Assignee optional) labels Nov 10, 2023
@fmeum
Copy link
Collaborator

fmeum commented Nov 10, 2023

@joeleba Should we @bazel-io flag this for Bazel 7?

Interestingly Bazel itself depends on source files in .git at

bazel/BUILD

Lines 54 to 61 in 07a571f

filegroup(
name = "git",
srcs = glob(
[".git/**"],
allow_empty = True,
exclude = [".git/**/*[*"], # gitk creates temp files with []
),
)
. The minimal solution of not symlinking just .git may thus not be sufficiently configurable. Going by .bazelignore should cover this use case though.

@joeleba
Copy link
Member

joeleba commented Nov 10, 2023

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Nov 10, 2023
@Wyverald
Copy link
Member

what's the estimated effort to fix this?

@keertk
Copy link
Member

keertk commented Nov 10, 2023

@bazel-io fork 7.0.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Nov 10, 2023
copybara-service bot pushed a commit that referenced this issue Nov 13, 2023
Surfaced in #19581.

PiperOrigin-RevId: 581877718
Change-Id: I8d9e460ac809ab236d04252ba14a5836d2e2d86c
copybara-service bot pushed a commit that referenced this issue Nov 13, 2023
…gnore`.

Bazel in skymeld mode eagerly plants the symlinks from the execroot to every entries under the source tree. This leads to some pain points for certain groups of users (#19581).

This CL offers a workaround for that issue. The users can now list the paths that they don't want Bazel to symlink to in the `.bazelignore` file in their project.

PiperOrigin-RevId: 581919915
Change-Id: I329365b0655fc0bcb2db1eeea91ef74c775c72ae
bazel-io pushed a commit to bazel-io/bazel that referenced this issue Nov 13, 2023
…gnore`.

Bazel in skymeld mode eagerly plants the symlinks from the execroot to every entries under the source tree. This leads to some pain points for certain groups of users (bazelbuild#19581).

This CL offers a workaround for that issue. The users can now list the paths that they don't want Bazel to symlink to in the `.bazelignore` file in their project.

PiperOrigin-RevId: 581919915
Change-Id: I329365b0655fc0bcb2db1eeea91ef74c775c72ae
keertk pushed a commit that referenced this issue Nov 13, 2023
…20168)

Bazel in skymeld mode eagerly plants the symlinks from the execroot to
every entries under the source tree. This leads to some pain points for
certain groups of users
(#19581).

This CL offers a workaround for that issue. The users can now list the
paths that they don't want Bazel to symlink to in the `.bazelignore`
file in their project.

Commit
caf1702

PiperOrigin-RevId: 581919915
Change-Id: I329365b0655fc0bcb2db1eeea91ef74c775c72ae

Co-authored-by: Googler <leba@google.com>
@joeleba
Copy link
Member

joeleba commented Nov 13, 2023

The commit that tells bazel to skip the paths listed in .bazelignore was cherrypicked into the release. You should be able to use that as a workaround. I'll lower the priority of this bug.

@joeleba joeleba added P2 We'll consider working on this in future. (Assignee optional) and removed P1 I'll work on this now. (Assignee required) labels Nov 13, 2023
@brentleyjones
Copy link
Contributor

@joeleba Thanks! I assume that only applies to when using Skymeld? If we don't use Skymeld, .bazelignore won't fix the originally reported issue?

@joeleba
Copy link
Member

joeleba commented Nov 13, 2023

That's true at least for Skymeld: the symlink planting should repect .bazelignore. I wasn't aware that this was an issue without Skymeld. AFAIK the noskymeld case actually goes through all the packages and only plants symlinks for the necessary ones.

@brentleyjones
Copy link
Contributor

AFAIK the noskymeld case actually goes through all the packages and only plants symlinks for the necessary ones

Sure, but the issue is when a target in the root package is built, it will symlink the .git directory, even though nothing has a dependency on that directory.

@brentleyjones
Copy link
Contributor

Just confirmed that this is an issue for the noskymeld case. We had to disable Skymeld for a 7.2.0rc1 related bug and we immediately hit this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Local-Exec Issues and PRs for the Execution (Local) team type: bug
Projects
None yet
Development

No branches or pull requests

10 participants