Conversation
`-Zembed-metadata` is kept as a nightly fallback
Contributor
|
Some questions I have that don't seem to be addressed in the stabilization report
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stabilization report:
-Zembed-metadata-Zembed-metadatarust#163436-Zembed-metadata#15495-Zembed-metadata=[no|yes]rust#139165What is stabilized
This stabilize the cargo side of
-Zembed-metadata,which changes the default behavior without providing any new user facing config:
-Cembed-metadata=noto rustc unconditionallywhen building
rlibanddylibcrate types.The rlib/dylib crate types will contain only a small stub of metadata.
The full metadata will be stored in a separate
.rmetafile.dylibspecificallyCargo will also pass
--emit=metadata,so that the
.rmetafile is always generated.(
rlibalready got that since compilation pipelining support years ago)rlib,Cargo will need to pass extra
--externflag to the corresponding.rmetafileto get the rustc metadata.
This affects
bin,staticlib,cdylib,proc-macrocrate types (exceptrlibanddylib).Other user-observable changes
--externflags doubles.Real world projects like cargo, the lagest cmdline length grows from 34k bytes to 43k bytes in a short target dir path (~26%).
according to Kobzol's blog post and the Inside Rust post
rliband becomes way less useful when distributed standalone,unless the companion
.rmetais copied and explicitly passed with an extra--extern foo=<path>.rmetafor external build tool.What is not stabilized / included
-Zembed-metadata=yes|noflag.We keep this nightly only for a few more release in case people need time to adjust their workflow.
.rmetanext to the uplifted rlib/dylib.Feedback
-Zembed-metadata=nosince 2026-01-13(Dogfood
-Zno-embed-metadatain the standard library rust#145343, 1.94).-Zembed-metadata=nosince 2026-08-22(Build rustc and codegen backends with -Zembed-metadata=no rust#151061, 1.100)
(rmeta file is not uplifted when -Zembed-metadata=no is used #17359)
Each broke with
only metadata stub foundand was fixed by also passing the
.rmeta, or by opting out:stdbuild into a custom sysroot.They chosten to passing rustc
-Zembed-metadata=yeswhen building sysroot.(Upgrade Rust toolchain to nightly-2026-08-21 model-checking/kani#4768, also see https://github.com/model-checking/kani/blob/f314aefb8ed0369c838c474924fc1937afea40b2/tools/build-kani/src/sysroot.rs#L151-L156).
.rmeta(Handle embed-metadata=no as active on recent nightly evcxr/evcxr#501).
.rmetato--extern..rmeta:rules_rustmissed the std.rmetafiles in its sysroot glob(Stdlib
.rmetafiles not included in sysroot glob, causing "only metadata stub found" errors with recent Rust nightlies bazelbuild/rules_rust#3859).Can be fixed with an argfile in the wrapper and the new build-dir-layout is more a culprit than this.
Landing plan
-Zembed-metadatarust#163436 lands:rustc accepts both
-Cand-Zuntil Cargo catches up with-CDetect whether rustc supports
-Cembed-metadataCan follow how
--check-cfgwas stabilized (Stabilize-Zcheck-cfgas always enabled #13571).This is required because Cargo CI builds on all stable/beta/nightly toolchain.
-Zembed-metadata-Zembed-metadataUnresolved questions
Is this a breaking change?
Proposed: May not be.
An uplifted rlib/dylib was still there in the same place,
and its object code is still there as well.
External linkers or loading dylib can still loading them if needed.
The things got removed are rustc metadata inside it.
The metadata was never a thing user can rely on or distribute easily.
Reasons being:
which are already internal/private.
They anyway need
cargo --message-format=jsonto find their locations.cargo --message-format=jsonalready prints uplifted rlib's internal path.split-debuginfowhich also changed the final artifact, and that time it affected executables not just rlib (Default macOS targets tounpackeddebuginfo #9298)However, this is really a compatibility note for those already copying/distributing rlib around, even they have already use
--message-format=json. We should have a outstanding note in release notes' compatibility note section.A stable opt-out flag
Proposed: No.
It is unclear why people need this except not breaking their existing CI pipeline.
The code search shows that most nightly reports were fixes by passing
.rmeta.If stable users need it for reasonable use cases, we can always add an stable option later later.
Command-line length
Command-line argument length does grow,
but in 1.100.0 Cargo will the the new build-dir layout,
which is going to force people to use more response files.
At the time this is stabilized,
users and rustc wrapper tools (e.g., sccache) should already be prepared to be compatible with longer command-line argument length.
Some data:
--externImplementation history
-Zembed-metadata-Largs in the newbuild-dirlayout-Zno-embed-metadatato-Zembed-metadata=no-Zembed-metadatafrom configFollow-ups after stabilization
-Zembed-metadataafter a few releases, if nobody needs it.-Cembed-metadataAcknowledgement
See rust-lang/rust#163436
🤖 LLM disclosure: collecting code search results on GitHub; generating "Implementation history" table; commandline argument length benchmark# Stabilization report:
-Zembed-metadata-Zembed-metadatarust#163436-Zembed-metadata#15495-Zembed-metadata=[no|yes]rust#139165What is stabilized
This stabilize the cargo side of
-Zembed-metadata,which changes the default behavior without providing any new user facing config:
-Cembed-metadata=noto rustc unconditionallywhen building
rlibanddylibcrate types.The rlib/dylib crate types will contain only a small stub of metadata.
The full metadata will be stored in a separate
.rmetafile.dylibspecificallyCargo will also pass
--emit=metadata,so that the
.rmetafile is always generated.(
rlibalready got that since compilation pipelining support years ago)rlib,Cargo will need to pass extra
--externflag to the corresponding.rmetafileto get the rustc metadata.
This affects
bin,staticlib,cdylib,proc-macrocrate types (exceptrlibanddylib).Other user-observable changes
--externflags doubles.Real world projects like cargo, the lagest cmdline length grows from 34k bytes to 43k bytes in a short target dir path (~26%).
according to Kobzol's blog post and the Inside Rust post
rliband becomes way less useful when distributed standalone,unless the companion
.rmetais copied and explicitly passed with an extra--extern foo=<path>.rmetafor external build tool.What is not stabilized / included
-Zembed-metadata=yes|noflag.We keep this nightly only for a few more release in case people need time to adjust their workflow.
.rmetanext to the uplifted rlib/dylib.Feedback
-Zembed-metadata=nosince 2026-01-13(Dogfood
-Zno-embed-metadatain the standard library rust#145343, 1.94).-Zembed-metadata=nosince 2026-08-22(Build rustc and codegen backends with -Zembed-metadata=no rust#151061, 1.100)
(rmeta file is not uplifted when -Zembed-metadata=no is used #17359)
Each broke with
only metadata stub foundand was fixed by also passing the
.rmeta, or by opting out:stdbuild into a custom sysroot.They chosten to passing rustc
-Zembed-metadata=yeswhen building sysroot.(Upgrade Rust toolchain to nightly-2026-08-21 model-checking/kani#4768, also see https://github.com/model-checking/kani/blob/f314aefb8ed0369c838c474924fc1937afea40b2/tools/build-kani/src/sysroot.rs#L151-L156).
.rmeta(Handle embed-metadata=no as active on recent nightly evcxr/evcxr#501).
.rmetato--extern..rmeta:rules_rustmissed the std.rmetafiles in its sysroot glob(Stdlib
.rmetafiles not included in sysroot glob, causing "only metadata stub found" errors with recent Rust nightlies bazelbuild/rules_rust#3859).Can be fixed with an argfile in the wrapper and the new build-dir-layout is more a culprit than this.
Landing plan
-Zembed-metadatarust#163436 lands:rustc accepts both
-Cand-Zuntil Cargo catches up with-CDetect whether rustc supports
-Cembed-metadataCan follow how
--check-cfgwas stabilized (Stabilize-Zcheck-cfgas always enabled #13571).This is required because Cargo CI builds on all stable/beta/nightly toolchain.
-Zembed-metadata-Zembed-metadataUnresolved questions
Uplift
.rmetaor not?Proposed: No.
An uplifted rlib was never enough on its own unless crate has no deps at all. Otherwise you alwasy need to copy transitive deps through parsing
cargo --message-format=json, and if you have done that already, it is easy to also copy final rmeta (and potentially final rlib if cargo stops uplifting it in the future).Arguments for uplifting:
rlibis a final artifact (put intarget/<profile>/directory as a user-visible artifact). If we don't upliftrmeta.rlibwith only metadata stub is useless. See those feedback above.A stable opt-out flag
Proposed: No.
It is unclear why people need this except not breaking their existing CI pipeline.
The code search shows that most nightly reports were fixes by passing
.rmeta.If stable users need it for reasonable use cases, we can always add an stable option later later.
Command-line length
Command-line argument length does grow,
but in 1.100.0 Cargo will the the new build-dir layout,
which is going to force people to use more response files.
At the time this is stabilized,
users and rustc wrapper tools (e.g., sccache) should already be prepared to be compatible with longer command-line argument length.
Some data:
--externImplementation history
-Zembed-metadata-Largs in the newbuild-dirlayout-Zno-embed-metadatato-Zembed-metadata=no-Zembed-metadatafrom configFollow-ups after stabilization
-Zembed-metadataafter a few releases, if nobody needs it.Acknowledgement
See rust-lang/rust#163436
🤖 LLM disclosure: collecting code search results on GitHub; generating "Implementation history" table; commandline argument length benchmark