Skip to content

Never include use extra-filename in build scripts#16855

Merged
weihanglo merged 2 commits intorust-lang:masterfrom
ranger-ross:fix-broken-build-scripts
Apr 8, 2026
Merged

Never include use extra-filename in build scripts#16855
weihanglo merged 2 commits intorust-lang:masterfrom
ranger-ross:fix-broken-build-scripts

Conversation

@ranger-ross
Copy link
Copy Markdown
Member

@ranger-ross ranger-ross commented Apr 8, 2026

What does this PR try to resolve?

See: #16854

This is that in #16812 we stopped adding the metadata hash to build script names and just call them build_script_build[EXE] since they are already contained within a directory with the hash.

However, I didn't take into consideration __CARGO_DEFAULT_LIB_METADATA, so if it is passed with a build script in the build graph it will get the wrong path (build_script_build-[HASH][EXE]) when it tries to execute and fail.

Looking at the comments about __CARGO_DEFAULT_LIB_METADATA I get the impression there is no usecase for using it with a build script.
So I modified the logic to never include the meta in the build script file names even when __CARGO_DEFAULT_LIB_METADATA.
Let me know if this is a bad assumption.

closes #16854

How to test and review this PR?

See the included test.

Also double checked on https://github.com/RalfJung/rustc-build-sysroot/ and this change fixes the issue for me

cc: @RalfJung

r? @epage

@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 Apr 8, 2026
}

if unit.target.is_custom_build() {
// Build scripts never never use metadata
Copy link
Copy Markdown
Member

@RalfJung RalfJung Apr 8, 2026

Choose a reason for hiding this comment

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

View changes since the review

Suggested change
// Build scripts never never use metadata
// Build scripts never use metadata

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks, typos can only save me from so much 😆

"#]]);
}

/// __CARGO_DEFAULT_LIB_METADATA is internal but used by rustc bootstrap and https://github.com/RalfJung/rustc-build-sysroot/
Copy link
Copy Markdown
Member

@RalfJung RalfJung Apr 8, 2026

Choose a reason for hiding this comment

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

View changes since the review

Suggested change
/// __CARGO_DEFAULT_LIB_METADATA is internal but used by rustc bootstrap and https://github.com/RalfJung/rustc-build-sysroot/
/// __CARGO_DEFAULT_LIB_METADATA is internal but used by rustc bootstrap and Miri.

@weihanglo
Copy link
Copy Markdown
Member

besides suggestions from Ralf, looks good

@ranger-ross ranger-ross force-pushed the fix-broken-build-scripts branch from 2a4d0fd to 3cc34d6 Compare April 8, 2026 12:15
Copy link
Copy Markdown
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

@weihanglo weihanglo enabled auto-merge April 8, 2026 12:23
@weihanglo weihanglo added this pull request to the merge queue Apr 8, 2026
Merged via the queue into rust-lang:master with commit 101549d Apr 8, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 8, 2026
@rustbot rustbot mentioned this pull request Apr 8, 2026
3 tasks
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Apr 8, 2026
Cargo submodule update

11 commits in a357df4c26fc14514e66aae2a269456b5545c7db..101549dddbd2b08e806f50154e3aa4cb3374cc21
2026-04-03 16:47:15 +0000 to 2026-04-08 12:51:20 +0000
- Never include use extra-filename in build scripts (rust-lang/cargo#16855)
- fix(toml): Force script edition warnings on quiet  (rust-lang/cargo#16848)
- GitHub fast path uses `http_async` (rust-lang/cargo#16847)
- feat(manifest): allow git dependency alongside alternate registry (rust-lang/cargo#16810)
- fix(auth): add auth scheme hint to token rejected error for alt registries (rust-lang/cargo#16794)
- Warn on invalid jobserver file descriptors (rust-lang/cargo#16843)
- docs(unstable): List the minimum required MSRV for 'public' field (rust-lang/cargo#16841)
- feat(lints): Emit unused_dependencies lint (rust-lang/cargo#16600)
- fix(tree): clarify error message when `-i` is used without a package name (rust-lang/cargo#16818)
- fix: Typo in target.<cfg>.linker (rust-lang/cargo#16839)
- Send Content-Type header with cargo publish requests (rust-lang/cargo#16832)

r? ghost
@rustbot rustbot added this to the 1.96.0 milestone Apr 8, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build scripts fail to run with new build dir layout when __CARGO_DEFAULT_LIB_METADATA is set

5 participants