Skip to content

Commit

Permalink
refactor: use Path::push to construct remap-path-prefix
Browse files Browse the repository at this point in the history
It creates paths with correct separators for different systems.
  • Loading branch information
weihanglo committed Dec 9, 2024
1 parent 2560340 commit 4159cfa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,9 +1310,16 @@ fn trim_paths_args(
/// This remap logic aligns with rustc:
/// <https://github.com/rust-lang/rust/blob/c2ef3516/src/bootstrap/src/lib.rs#L1113-L1116>
fn sysroot_remap(build_runner: &BuildRunner<'_, '_>, unit: &Unit) -> OsString {
let sysroot = &build_runner.bcx.target_data.info(unit.kind).sysroot;
let mut remap = OsString::from("--remap-path-prefix=");
remap.push(sysroot);
remap.push({
// See also `detect_sysroot_src_path()`.
let mut sysroot = build_runner.bcx.target_data.info(unit.kind).sysroot.clone();
sysroot.push("lib");
sysroot.push("rustlib");
sysroot.push("src");
sysroot.push("rust");
sysroot
});
remap.push("/lib/rustlib/src/rust"); // See also `detect_sysroot_src_path()`.
remap.push("=");
remap.push("/rustc/");
Expand Down

0 comments on commit 4159cfa

Please sign in to comment.