Skip to content

Commit

Permalink
Add path stripping to Java, spawn action keys
Browse files Browse the repository at this point in the history
This fixes a small incremental build issue with `--experimental_output_paths`:

Bazel uses action keys in its local action cache. Before running an action, it looks at:

- the action's input paths and digests
- the action's output paths and digests
- the action key (which identifies the action's semantics)

to determine if Bazel already ran that action with the same inputs and outputs already on the filesystem.

Without this fix, toggling path stripping won't invalidate the action cache. That means if you have a build that works normally but fails with path stripping, you can incorrectly get success on both builds:

```
$ bazel clean
$ bazel build //:MyJavaBinary --strategy Javac=worker,standalone
  <succeeds as a normal build>
$ bazel build //:MyJavaBinary --strategy Javac=worker,standalone --experimental_output_paths=strip
  <should fail because path stripping doesn't yet support local execution. But still succeeds!>
```

In contrast:

```
$ bazel clean
$ bazel build //:MyJavaBinary --strategy Javac=worker,standalone --experimental_output_paths=strip
  <fails as expected>
```

This second run fails as expected because the local action cache doesn't short-circuit the build.

You can test this phenomenon further by building with `--nouse_action_cache`.

For #6526.

Closes #17208.

Change-Id: Id146c6b9bd6b6be6953f2c8024839bca4c09a793
PiperOrigin-RevId: 503132362
  • Loading branch information
gregestren authored and hvadehra committed Feb 14, 2023
1 parent c45d26b commit 1de34f1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ protected void computeKey(
}
env.addTo(fp);
fp.addStringMap(getExecutionInfo());
fp.addBoolean(stripOutputPaths);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ protected void computeKey(
}
env.addTo(fp);
fp.addStringMap(executionInfo);
fp.addBoolean(stripOutputPaths());
}

/**
Expand Down

0 comments on commit 1de34f1

Please sign in to comment.