Have rust_test put its compilation outputs in a subdirectory #1438
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.
This is supposed to fix the long standing Windows flakiness as described in #1427 (comment)
Initially I thought it's an issue with
rustdoc_test
, however the actual issue is thatrust_binary
and itsrust_test
have the same crate name and generate the same intermediary.o
files. For sandboxed builds this is not an issue, as the actions are isolated, however, we have a race condition in non-sandboxed builds (Windows):Let's consider the following build:
The
bin_with_transitive_proc_macro
compile action will create the following intermediate file:bazel-out/k8-fastbuild/bin/test/unit/rustdoc/bin_with_transitive_proc_macro.bin_with_transitive_proc_macro.573369dc-cgu.2.rcgu.o
, as will thebin_with_transitive_proc_macro_test
action. These two files differ slightly (as the second action is for a test), namely thebin_with_transitive_proc_macro
output has the following symbols:while the
bin_with_transitive_proc_macro_test
.o
output looks like this:Now, when the two actions run in parallel, it can happen that
bin_with_transitive_proc_macro
creates the output, andbin_with_transitive_proc_macro_test
overwrites it. Then, at linking time forbin_with_transitive_proc_macro
,rustc
will complain:This is because
bin_with_transitive_proc_macro
is not a test and as such is not linked againstlibtest
.This PR fixes the issue by directing the compilation outputs of
rust_test
to be under atest-{hash}
directory.