Cargo runs rustc from the workspace root
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
Bug? Inconvenience? Who knows, but it confused me greatly.
Problem
I ran cargo build --lib -- -Z self-profile from src/librustdoc in a clone of https://github.com/rust-lang/rust/. I expected the output file to be in src/librustdoc/rustdoc-24097.mm_profdata, since that's where it would be if I ran rustc directly. Instead they showed up in the workspace root: rustdoc-24097.mm_profdata.
Steps
- git clone https://github.com/rust-lang/rust/
- cd rust/src/librustdoc
- git checkout 500b0f3c1ba651f31abc551ccbcf222f48e355a2
- cargo build --lib -- -Z self-profile
(but I think this is true in any workspace)
Possible Solution(s)
Run rustc from the src/librustdoc folder instead, which will put the file in the expected place.
Notes
Output of cargo version: cargo 1.50.0-nightly (bfca1cd22 2020-11-24)
I don't think this is a bug per-se, but it would be nice to document, maybe.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior from src/librustdoc with cargo build --lib -- -Z self-profile, and compare the generated file location with a direct rustc invocation. Review the Cargo documentation for workspace build paths and self-profile output. Done means the workspace-root behavior is clearly documented, including the expected output location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, tooling
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100