rust-lang / rust-lang/rust

Cross-compiled asm output has invalid mixed-slash paths

Open
#138,012 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-cross A-debuginfo C-bug O-windows T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

From a non-Windows computer, generate asm while cross compiling to Windows. The resulting file contains paths with a mixture of forwards and backwards slashes.

$ cargo new path-repro
$ cargo rustc --target i586-pc-windows-msvc -- --emit asm

(Note: even if the latter fails with a missing link.exe, the assembly is still generated and it still reproduces this bug.)

The resulting assembly file target/i586-pc-windows-msvc/debug/deps/path_repro.s contains path references like:

        .cv_file        1 "/rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\\library\\std\\src\\rt.rs" "13B62144D5451EAE559C4FD478A015CF18D734D1D8B9602FF13CE7C70FFA4F05" 3

These paths are invalid on the host (Mac) system.

I noticed in the same output that the input Rust files have Mac-style paths:

        .cv_file        9 "/Users/evmar/projects/path-repro/src/main.rs" "C8E0583694BB1E0188DBE28FE0D65AC1130723C55F968B6262B906C147F72549" 3

So I think I expect the all paths to be fully forward slashed.

This matters for tools that want to parse and these paths, and in particular cargo asm:
https://github.com/pacak/cargo-show-asm/issues/382

Meta

rustc --version --verbose:

rustc 1.85.0 (4d91de4e4 2025-02-17)
binary: rustc
commit-hash: 4d91de4e48198da2e33413efdcd9cd2cc0c46688
commit-date: 2025-02-17
host: aarch64-apple-darwin
release: 1.85.0
LLVM version: 19.1.7

Also tried in

$ rustc +nightly --version --verbose                              
rustc 1.87.0-nightly (e16a049ad 2025-03-03)
binary: rustc
commit-hash: e16a049adbf94d610787430b6efdf31d896dc5b6
commit-date: 2025-03-03
host: aarch64-apple-darwin
release: 1.87.0-nightly
LLVM version: 20.1.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with cargo new path-repro and cargo rustc --target i586-pc-windows-msvc -- --emit asm, then inspect target/i586-pc-windows-msvc/debug/deps/path_repro.s, especially its .cv_file entries. Trace where the cross-compiled standard-library paths are produced and compare them with the host-source paths. Done means generated assembly uses consistently valid forward-slash paths so tools such as cargo asm can parse them.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.