rust-lang / rust-lang/cargo

Cargo runs rustc from the workspace root

Open
#8,947 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-documenting-cargo-itself C-bug S-needs-design
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

  1. git clone https://github.com/rust-lang/rust/
  2. cd rust/src/librustdoc
  3. git checkout 500b0f3c1ba651f31abc551ccbcf222f48e355a2
  4. 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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.