You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
To fix this issue the matter of cwd is now entirely excluded from compilation
command lines. Instead rustc is unconditionally invoked with a relative path
if the path is underneath the workspace root, and otherwise it's invoked as an
absolute path (in which case the cwd doesn't matter).
Another thing is that paths in error messages and warnings are derived from the given filename of the crate root. For example an error message would show foo/my_mod.rs if foo/lib.rs was passed as crate root and the error happens in my_mod.rs. If the cwd were to change between rustc invocations and thus, the filenames in warnings, cargo would cache the warnings with the old path, which is even more confusing.
Yea, it is very intentional that it runs in the workspace root. It is extremely rare that it matters, as files are usually emitted in specific paths. The profiling flags are unusual in that they dump files in the CWD. I'm not sure where it could be documented, as it is usually not important, and I doubt would be something that could be easily discoverable or searchable. But if you had some place in mind, feel free to elaborate what could help. (Perhaps https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/self-profile.html could clarify what "current working directory" is when used with cargo?)
Bug? Inconvenience? Who knows, but it confused me greatly.
Problem
I ran
cargo build --lib -- -Z self-profile
fromsrc/librustdoc
in a clone of https://github.com/rust-lang/rust/. I expected the output file to be insrc/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
(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 (bfca1cd 2020-11-24)I don't think this is a bug per-se, but it would be nice to document, maybe.
The text was updated successfully, but these errors were encountered: