bazelbuild / bazelbuild/bazel

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

Open
#19,581 13 comments 6 reactions 1 assignee Claimed by @joeleba View on GitHub
P2 team-Local-Exec type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### 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](https://github.com/bazelbuild/bazel/assets/75236/976a9097-07e9-4661-b1fd-2dd8f34c197f)

### 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](https://github.com/MobileNativeFoundation/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](https://bazelbuild.slack.com/archives/C0429BN0F8V/p1695156641392379)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.