docs(layout): Updated layout module docs to document new layout#16502
docs(layout): Updated layout module docs to document new layout#16502ranger-ross wants to merge 3 commits intorust-lang:masterfrom
Conversation
|
r? @weihanglo rustbot has assigned @weihanglo. Use |
src/cargo/core/compiler/layout.rs
Outdated
| //! | ||
| //! As of early 2026, Cargo is restructuring the layout and supports 2 layouts. | ||
| //! * the original layout organizing files by type | ||
| //! * the new "build unit" based layout | ||
| //! | ||
| //! For more info the layout transition see: [#15010](https://github.com/rust-lang/cargo/issues/15010) |
There was a problem hiding this comment.
How do we track removal of this on stabilization?
There was a problem hiding this comment.
it could be a bullet point to remove in the tracking issue to remove this in the stabilization PR?
There was a problem hiding this comment.
That is fine. Be sure to call that out in this PR description.
src/cargo/core/compiler/layout.rs
Outdated
| //! # Note that named profiles will soon be included as separate directories | ||
| //! # here. They have a restricted format, similar to Rust identifiers, so |
There was a problem hiding this comment.
What do you mean about named profiles will be separate directories?
There was a problem hiding this comment.
Oh, this was copied over. Probably should be removed from the other section in a separate commit
src/cargo/core/compiler/layout.rs
Outdated
| //! # This is the directory for the rustc artifacts of this unit except build | ||
| //! # scripts, examples, and test and bench executables. |
There was a problem hiding this comment.
These exceptions are removed, right?
There was a problem hiding this comment.
For build-scripts its still applicable, as they are compiled into $pkgname/$META/build-script.
Though, that could probably be merged into $pkgname/$META/deps. (also thinking about it that would allow us to rename build-script-execution to build-script for shorter paths on windows)
For tests and benches I believe you are correct.
There was a problem hiding this comment.
Oh looks like you beat me to that idea in this comment https://github.com/rust-lang/cargo/pull/16502/files#r2686490751 😄
There was a problem hiding this comment.
Like I mentioned at #16515 (review), I'm tempted to generalize the layout. My ideas are:
- change
build-script-executedtorunas it just contains information general to running an external process - change
depstooutand movebuild-script-executedtooutas well, sooutrepresents the writeable directory for a build unit to write output to.
There was a problem hiding this comment.
I like that idea!
My only thought is maybe we use output instead of out to avoid having 2 types of our-dir's which could be a bit confusing.
something like
build-dir/debug/build/<pkgname>/<hash>
fingerprint/
output/
run/
There was a problem hiding this comment.
My only thought is maybe we use output instead of out to avoid having 2 types of our-dir's which could be a bit confusing.
Which two types?
For build scripts, it is literally called OUT_DIR so calling it out makes sense.
Part of my intention with renaming deps to out is to make each type of build unit less special. This is the directory that the build unit has access to to write its output.
There was a problem hiding this comment.
Ahhh, I see. So your proposing move out from build-unit-execution and merging it with deps?
So for
- compile units
outcontains rlib/rmeta/bins/libs/ect - Build script (build) units
outcontains the build script bin - Build script (run) units
outis theOUT_DIR.runcontains the stdout/err output
Thinking about this a bit more, I think it makes a lot of sense :)
src/cargo/core/compiler/layout.rs
Outdated
| //! # If the unit is a build script compilation, the build script | ||
| //! # binary will be stored here. | ||
| //! build-script/ |
There was a problem hiding this comment.
Do we still need these to be different than deps?
There was a problem hiding this comment.
I don't think so, we can probably merge them together as mentioned in https://github.com/rust-lang/cargo/pull/16502/files#r2694115028
ca93c71 to
080e303
Compare
### What does this PR try to resolve? While documenting the `build-dir` layout changes in #16502 I noticed that we are still creating the `<build-dir>/<profile>/examples` directory when `-Zbuild-dir-new-layout` is passed even though its no longer used. This PR fixes it cc tracking issue: #15010 ### How to test and review this PR? Updating the existing examples test to catch this particular case r? @epage
### What does this PR try to resolve? In #16502 (comment) there was a discussion about merging the `build-script` and `deps` dirs in the `build-dir`. Currently: ``` build-dir/<profile>/build/<pkgname>/<hash>/ deps/ # rustc output build-script/ # build script binary build-script-execution/ # the output of running a build script ``` Note: For build-scripts `deps` is empty. This PR: 1. moves the build script binaries from `build-script` to `deps` to simplify the layout 2. renames `build-script-execution` to `build-script` to simplify the dir naming and shorten the path length for windows ``` build-dir/<profile>/build/<pkgname>/<hash>/ deps/ # rustc output including build-script bins build-script/ # the output of running a build script ``` cc tracking issue: #15010 ### How to test and review this PR? see the test changes r? @epage
### What does this PR try to resolve? This spawned out of #16502 (comment) when I noticed artifact dependencies are not using the new build-dir layout. This PR moves them from `<build-dir>/<profile>/deps/artifact/$pkgname-$META` (old layout) to `<build-dir>/<profile>/build/$pkgname/$META/deps/artifact/<kind>` when `-Zbuild-dir-new-layout` is enabled. cc tracking issue: #15010 ### How to test and review this PR? Added new test specifically for artifact deps r? @epage
### What does this PR try to resolve? This PR makes more changes to the new `build-dir` layout as discussed in #16502 (comment). The goal here is to have more general (and thus reusable) directories in the build unit structure. #### Layout changes 1. Rename `{build-unit-dir}/deps` to `{build-unit-dir}/out` 2. Moved build-script `OUT_DIR` from `{build-unit-dir}/build-script/out` to `{build-unit-dir}/out` 3. Renamed `{build-unit-dir}/build-script` to `{build-unit-dir}/run` * This makes the dir more general to any build unit that can execute an external process. (but currently only build-scripts use it) The resulting structure looks like ``` build-dir/debug/build/<pkgname>/<HASH> fingerprint/ out/ run/ .lock ``` Part of #15010 ### How to test and review this PR? See the test updates included in each commit
080e303 to
f0ea77f
Compare
This comment has been minimized.
This comment has been minimized.
| //! run/ | ||
| //! # Timestamp of last execution. | ||
| //! invoked.timestamp | ||
| //! # Stdout output from the process. | ||
| //! output | ||
| //! # Stderr output from the process. | ||
| //! stderr |
There was a problem hiding this comment.
I'd be in favor to also rename output to stdout to match stderr.
Thoughts?
There was a problem hiding this comment.
If it fits within this to do so, I think that makes sense.
There was a problem hiding this comment.
I raised #16644 for this.
Will update this PR once that is merged :)
src/cargo/core/compiler/layout.rs
Outdated
| //! The new build unit based layout has separate structures for `artifact-dir` and `build-dir`. | ||
| //! By default both of these point to `target` in the workspace root. | ||
| //! |
There was a problem hiding this comment.
Isn't the artifact dir layout independent of all of the layouts?
Pulling out the artifact-dir layout from build-dir layout within the old layout seems like something we should do as a separate commit or even separate PR. This would then just focus on the changes for build-dir.
There was a problem hiding this comment.
Yes, after re-reading this, it is misleading as artifact-dir is not build unit based.
Pulling out the artifact-dir layout from build-dir layout within the old layout seems like something we should do as a separate commit or even separate PR. This would then just focus on the changes for build-dir.
Sure I'll de-scope this PR to just document the new build-dir layout
There was a problem hiding this comment.
I was assuming the artifact-dir part would remain.
I expect from this the following commits
- Cleanup of the profile text (docs(layout): Updated layout module docs to document new layout #16502 (comment))
- Separate artifact-dir from build-dir
- Adding of the new layout, more highlighting the unstable feature name (which will show up in searches for removing) rather than the year (thats a historical question left to git history and PRs)
src/cargo/core/compiler/layout.rs
Outdated
| //! # Output from rustdoc | ||
| //! doc/ |
There was a problem hiding this comment.
This isn't part of the build-dir layout, right?
There was a problem hiding this comment.
err, yeah sorry. Added by mistake. Will remove
…yout (#16644) ### What does this PR try to resolve? Another `build-dir` layout change that was spawned out of discussion in this comment thread #16502 (comment) This PR changes `<build-dir>/<profile>/build/<pkgname>/[HASH]/run/output` to `<build-dir>/<profile>/build/<pkgname>/[HASH]/run/stdout` for the new `build-dir` layout. The motivation here is to change is to: 1. Better communicate what this file is used for. (it only contains `stdout` of a build script run) * Reduce the overloading of "output" as a term. 2. Match the corresponding `stderr` file cc: #15010 ### How to test and review this PR? See the test changes r? @epage
f0ea77f to
0f0be3c
Compare
This comment has been minimized.
This comment has been minimized.
0f0be3c to
65d9ec3
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
65d9ec3 to
0e0fb09
Compare
0e0fb09 to
20862b4
Compare
20862b4 to
53e09a7
Compare
What does this PR try to resolve?
This PR updates the layout module docs to reflect the update layout structure changes made as part of #15010
How to test and review this PR?
no response
Follow up needed