Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--remap-path-prefix does not remap all path prefixes #83635

Closed
ChrisDenton opened this issue Mar 29, 2021 · 10 comments
Closed

--remap-path-prefix does not remap all path prefixes #83635

ChrisDenton opened this issue Mar 29, 2021 · 10 comments
Labels
C-bug Category: This is a bug.

Comments

@ChrisDenton
Copy link
Contributor

ChrisDenton commented Mar 29, 2021

I'm using the x86_64-pc-windows-msvc toolchain and target.

My system environment variables:

CARGO_HOME = C:\Users\Chris\AppData\Local\Programs\Cargo
RUSTUP_HOME = C:\Users\Chris\AppData\Local\Programs\Rust
CARGO_TARGET_DIR = Z:\target

Without setting --remap-path-prefix the final binary has source paths from CARGO_HOME and RUSTUP_HOME. It also has a .pdb file (Windows debug file) in CARGO_TARGET_DIR.

When setting --remap-path-prefix I had to be careful with path separators as the replacement is documented as being "purely textual" (which is honestly a bit scary considering Rust will freely mix path separators on Windows, though hopefully it's not an issue in this case).

Ok so I set RUSTFLAGS:

$env:RUSTFLAGS = "--remap-path-prefix=C:\Users\Chris\AppData\Local\Programs\Cargo\=src --remap-path-prefix=C:\Users\Chris\AppData\Local\Programs\Rust\=rsrc --remap-path-prefix=Z:\target\=target"

Then, after cleaning the target directory, I built ripgrep (as a presumably representative project). I used the command:

git clone https://github.com/BurntSushi/ripgrep
cd ripgrep
cargo +nightly build --release

As expected, this replaced the CARGO_HOME prefix in the final binary. However it did not replace all the RUSTUP_HOME path prefixes. Specifically with this prefix:

C:\Users\Chris\AppData\Local\Programs\Rust\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\

It also didn't remap the path to the .pdb file. This is somewhat expected as changing that requires setting a linker argument.

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)
binary: rustc
commit-hash: 07e0e2ec268c140e607e1ac7f49f145612d0f597
commit-date: 2021-03-24
host: x86_64-pc-windows-msvc
release: 1.53.0-nightly
LLVM version: 12.0.0

Notes

  • Changing --remap-path-prefix to a single common base directory didn't help.
  • Stable (1.51) has the same issue.
@chemsaf3
Copy link

will this also help with similar cargo issue rust-lang/cargo#9311 ?

@ChrisDenton
Copy link
Contributor Author

ChrisDenton commented Mar 29, 2021

@chemsaf3 Could you try setting --remap-path-prefix and see if it works for you? You can do so by setting the RUSTFLAGS environment variable to something like this:

--remap-path-prefix=D:\REDACTED\.cargo\registry=registry

Then do:

cargo clean
cargo build --release

@chemsaf3
Copy link

i tried that and in my case it did not work

@ehuss
Copy link
Contributor

ehuss commented Mar 29, 2021

Do you maybe have the rust-src component installed? There's a known issue with it (#73167).

@ChrisDenton
Copy link
Contributor Author

Ah, that would be it then. I somehow missed that when searching for issues. I'll close this in favour of that issue.

@chemsaf3
Copy link

Do you maybe have the rust-src component installed? There's a known issue with it (#73167).

i do not have rust-src installed via rustup when i list components

@chemsaf3
Copy link

chemsaf3 commented Apr 3, 2021

@ehuss can you reopen please? i dont have rust-src installed and have this issue

@ehuss
Copy link
Contributor

ehuss commented Apr 3, 2021

@chemsaf3 I recommend opening a new issue. Please try to include very exact steps on how to reproduce.

@chemsaf3
Copy link

chemsaf3 commented Apr 3, 2021

@ehuss @ChrisDenton already provide exact steps

@ChrisDenton
Copy link
Contributor Author

ChrisDenton commented Apr 3, 2021

@chemsaf3 I'm unable to reproduce this issue without the rust-src component installed. It would help if you could create your own issue with the exact steps you've taken so I can try to reproduce that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants