Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1116,9 +1116,13 @@ def construct_arguments(

# For determinism to help with build distribution and such
if remap_path_prefix != None:
# `--remap-path-prefix` flags are applied in reverse order. We need to
# specify the outermost directory (output_base) first, so that it's
# remapped last. Otherwise we can end up with a partial rewrite where
# "/path/to/output_base/execroot" becomes "./execroot" rather than ".".
rustc_flags.add("--remap-path-prefix=${{output_base}}={}".format(remap_path_prefix))
rustc_flags.add("--remap-path-prefix=${{pwd}}={}".format(remap_path_prefix))
rustc_flags.add("--remap-path-prefix=${{exec_root}}={}".format(remap_path_prefix))
rustc_flags.add("--remap-path-prefix=${{output_base}}={}".format(remap_path_prefix))

emit_without_paths = []
for kind in emit:
Expand Down
9 changes: 5 additions & 4 deletions test/unit/remap_path_prefix/remap_path_prefix_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ load("//rust:defs.bzl", "rust_binary", "rust_library")
load(
"//test/unit:common.bzl",
"assert_action_mnemonic",
"assert_argv_contains",
"assert_list_contains_adjacent_elements",
)

Expand All @@ -17,9 +16,11 @@ def _remap_path_prefix_test_impl(ctx):
action = target.actions[0]
assert_action_mnemonic(env, action, "Rustc")

assert_argv_contains(env, action, "--remap-path-prefix=${pwd}=.")
assert_argv_contains(env, action, "--remap-path-prefix=${exec_root}=.")
assert_argv_contains(env, action, "--remap-path-prefix=${output_base}=.")
assert_list_contains_adjacent_elements(env, action.argv, [
"--remap-path-prefix=${output_base}=.",
"--remap-path-prefix=${pwd}=.",
"--remap-path-prefix=${exec_root}=.",
])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Maybe add an assert message that the ordering is sensitive?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? assert_list_contains_adjacent_elements doesn't have any argument to pass a message.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I thought it did, I know some do. Either way, the desire was to ensure folks who encounter this test to be failing don't just update the test to match the current behavior. A note would be nice


return analysistest.end(env)

Expand Down
Loading