Speed up build by avoiding build config duplication #753
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Compile substantially all of workerd in the bazel 'target' configuration
instead of 'exec', which allows us to avoid compiling major components
twice.
This should offer a large performance improvement, especially when
rebuilding after a V8 update or building all targets and drive down the
worst-case CI build time significantly.
Bazel supports an exec configuration for building code that needs to run
on the host machine during the build, e.g. tools used to generate source
files or type definitions. When not cross-compiling exec and target will
be the same, but bazel does not offer a flag to use just one configuration
when the configurations are identical (bazelbuild/bazel#14848),
making manual changes necessary.
Bazel appears to offer no way to detect if exec and host are the same, so
this feature is implemented through an opt-in command line flag enabled in
.bazelrc, which makes it possible to easily disable the change when
cross-compilation support is needed.
Some of the V8 changes are extensive; fortunately they largely affect bazel code and not the list of source files, which is expected to change infrequently. I will try to upstream at least the torque-related changes.
Note: This does not affect the upstream build, no upstream PR is needed.