diff options
| author | bors <bors@rust-lang.org> | 2025-04-01 10:40:06 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-04-01 10:40:06 +0000 |
| commit | 8c35f4a85e2c505d22c751ebdc292e851b1584cf (patch) | |
| tree | 97cb9f615e176a09ebac384569fa660a2180944a /src/doc | |
| parent | ed201574c5d6117fb4a491db545c96fa4289ea9c (diff) | |
| parent | f0efb9748ea02b7e6f15bef45881403ddcfba125 (diff) | |
| download | rust-8c35f4a85e2c505d22c751ebdc292e851b1584cf.tar.gz rust-8c35f4a85e2c505d22c751ebdc292e851b1584cf.zip | |
Auto merge of #137535 - Kobzol:split-metadata, r=petrochenkov
Introduce `-Zembed-metadata` to allow omitting full metadata from rlibs and dylibs This is a continuation of https://github.com/rust-lang/rust/pull/120855 (I was mentored by `@bjorn3` to move it forward). Most of the original code was written by bjorn3, I tried to clean it up a bit and add some documentation and tests. This PR introduces a new unstable compiler flag called `-Zembed-metadata=[no|yes]`, with the default being `yes` (see https://github.com/rust-lang/rust/issues/57076 for context). When set to `no`, rustc will only store a small metadata stub inside rlibs/dylibs instead of the full metadata, to keep their size smaller. It should be used in combination with `--emit=metadata`, so that the users of such a compiled library can still read the metadata from the corresponding `.rmeta` file. [This comment](https://github.com/rust-lang/rust/pull/120855#issuecomment-1937018169) shows an example of binary/artifact size wins that can be achieved using this approach. Contrary to https://github.com/rust-lang/rust/pull/120855, this PR only introduces the new flag, along with a couple of run-make tests and documentation, but does not yet use it in bootstrap to actually compile rustc. I plan to do that as a follow-up step (along with integration in Cargo, which should ideally just always pass this flag to reduce the size of target directories). Fixes https://github.com/rust-lang/rust/issues/23366 Closes https://github.com/rust-lang/rust/issues/29511 Fixes https://github.com/rust-lang/rust/issues/57076 Another attempt of https://github.com/rust-lang/rust/pull/93945 and https://github.com/rust-lang/rust/pull/120855. r? `@petrochenkov`
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/unstable-book/src/compiler-flags/embed-metadata.md | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/compiler-flags/embed-metadata.md b/src/doc/unstable-book/src/compiler-flags/embed-metadata.md new file mode 100644 index 00000000000..a2a790ee76a --- /dev/null +++ b/src/doc/unstable-book/src/compiler-flags/embed-metadata.md @@ -0,0 +1,3 @@ +## `embed-metadata` + +This option instructs `rustc` to include the full metadata in `rlib` and `dylib` crate types. The default value is `yes` (enabled). If disabled (`no`), only stub metadata will be stored in these files, to reduce their size on disk. When using `-Zembed-metadata=no`, you will probably want to use `--emit=metadata` to produce the full metadata into a separate `.rmeta` file. |
