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 /compiler/rustc_interface/src | |
| 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 'compiler/rustc_interface/src')
| -rw-r--r-- | compiler/rustc_interface/src/tests.rs | 1 | 
1 files changed, 1 insertions, 0 deletions
| diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index b44be1710ed..4592e014438 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -787,6 +787,7 @@ fn test_unstable_options_tracking_hash() { tracked!(direct_access_external_data, Some(true)); tracked!(dual_proc_macros, true); tracked!(dwarf_version, Some(5)); + tracked!(embed_metadata, false); tracked!(embed_source, true); tracked!(emit_thin_lto, false); tracked!(emscripten_wasm_eh, true); | 
