Skip to content

docs(layout): Updated layout module docs to document new layout#16502

Open
ranger-ross wants to merge 3 commits intorust-lang:masterfrom
ranger-ross:layout-docs
Open

docs(layout): Updated layout module docs to document new layout#16502
ranger-ross wants to merge 3 commits intorust-lang:masterfrom
ranger-ross:layout-docs

Conversation

@ranger-ross
Copy link
Member

@ranger-ross ranger-ross commented Jan 13, 2026

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

  • Add a note in the tracking issue to updating these docs in the stabilization PR

@rustbot rustbot added A-layout Area: target output directory layout, naming, and organization S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 13, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2026

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Comment on lines 5 to 10
//!
//! 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we track removal of this on stabilization?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could be a bullet point to remove in the tracking issue to remove this in the stabilization PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is fine. Be sure to call that out in this PR description.

Comment on lines 121 to 122
//! # Note that named profiles will soon be included as separate directories
//! # here. They have a restricted format, similar to Rust identifiers, so
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean about named profiles will be separate directories?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this was copied over. Probably should be removed from the other section in a separate commit

Comment on lines 181 to 182
//! # This is the directory for the rustc artifacts of this unit except build
//! # scripts, examples, and test and bench executables.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These exceptions are removed, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh looks like you beat me to that idea in this comment https://github.com/rust-lang/cargo/pull/16502/files#r2686490751 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I mentioned at #16515 (review), I'm tempted to generalize the layout. My ideas are:

  • change build-script-executed to run as it just contains information general to running an external process
  • change deps to out and move build-script-executed to out as well, so out represents the writeable directory for a build unit to write output to.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, I see. So your proposing move out from build-unit-execution and merging it with deps?

So for

  • compile units out contains rlib/rmeta/bins/libs/ect
  • Build script (build) units out contains the build script bin
  • Build script (run) units out is the OUT_DIR. run contains the stdout/err output

Thinking about this a bit more, I think it makes a lot of sense :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Comment on lines 203 to 205
//! # If the unit is a build script compilation, the build script
//! # binary will be stored here.
//! build-script/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need these to be different than deps?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, we can probably merge them together as mentioned in https://github.com/rust-lang/cargo/pull/16502/files#r2694115028

github-merge-queue bot pushed a commit that referenced this pull request Jan 15, 2026
### 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
github-merge-queue bot pushed a commit that referenced this pull request Jan 15, 2026
### 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
github-merge-queue bot pushed a commit that referenced this pull request Jan 17, 2026
### 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
github-merge-queue bot pushed a commit that referenced this pull request Feb 11, 2026
### 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
@rustbot

This comment has been minimized.

@ranger-ross
Copy link
Member Author

Okay I am finally coming back to this PR now that #16515, #16519, and #16542 are merged.

I've updated the documentation to reflect the changes added in those PRs.

Comment on lines 206 to 212
//! run/
//! # Timestamp of last execution.
//! invoked.timestamp
//! # Stdout output from the process.
//! output
//! # Stderr output from the process.
//! stderr
Copy link
Member Author

@ranger-ross ranger-ross Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be in favor to also rename output to stdout to match stderr.

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it fits within this to do so, I think that makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I raised #16644 for this.

Will update this PR once that is merged :)

Comment on lines 111 to 113
//! 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.
//!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was assuming the artifact-dir part would remain.

I expect from this the following commits

  1. Cleanup of the profile text (docs(layout): Updated layout module docs to document new layout #16502 (comment))
  2. Separate artifact-dir from build-dir
  3. 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)

Comment on lines 217 to 218
//! # Output from rustdoc
//! doc/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't part of the build-dir layout, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err, yeah sorry. Added by mistake. Will remove

github-merge-queue bot pushed a commit that referenced this pull request Feb 14, 2026
…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
@rustbot

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Feb 15, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-layout Area: target output directory layout, naming, and organization S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants