Skip to content

Build rustc and codegen backends with -Zembed-metadata=no - #151061

Open
bjorn3 wants to merge 1 commit into
rust-lang:mainfrom
bjorn3:rustc_no_embed_metadata
Open

Build rustc and codegen backends with -Zembed-metadata=no#151061
bjorn3 wants to merge 1 commit into
rust-lang:mainfrom
bjorn3:rustc_no_embed_metadata

Conversation

@bjorn3

@bjorn3 bjorn3 commented Jan 13, 2026

Copy link
Copy Markdown
Member

View all comments

While this won't change much for rustc and rustc-dev, it should make codegen backends a bit smaller by omitting their crate metadata. In addition it should reduce disk usage while compiling.

Follow up to #145343

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 13, 2026
@rustbot

rustbot commented Jan 13, 2026

Copy link
Copy Markdown
Collaborator

r? @jieyouxu

rustbot has assigned @jieyouxu.
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

@bjorn3

bjorn3 commented Jan 13, 2026

Copy link
Copy Markdown
Member Author

cc @Kobzol

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jan 13, 2026
Build rustc and codegen backends with -Zno-embed-metadata
Comment thread src/bootstrap/src/core/builder/cargo.rs Outdated
@rust-bors

rust-bors Bot commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: d9668cf (d9668cf85dd8b3cac5d57f7b5b8b1508112db899, parent: b2a322beb29110e22a1782e2ce5ed2a0719b81ed)

@bjorn3

bjorn3 commented Jan 13, 2026

Copy link
Copy Markdown
Member Author

And the baseline to compare the disk space against for try builds:

@bors try

rust-bors Bot pushed a commit that referenced this pull request Jan 13, 2026
Build rustc and codegen backends with -Zno-embed-metadata
@rust-bors

This comment has been minimized.

@Kobzol

Kobzol commented Jan 13, 2026

Copy link
Copy Markdown
Member

r? @Kobzol

@rustbot rustbot assigned Kobzol and unassigned jieyouxu Jan 13, 2026
@rust-bors

rust-bors Bot commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: db6fee5 (db6fee556e8bf32d307f378d2acbb52ba25b5a8b, parent: db1484bdee1cb065b322a5bd512b39c49dadc9e5)

@bjorn3
bjorn3 force-pushed the rustc_no_embed_metadata branch from 6e25c8e to b6605c3 Compare January 13, 2026 19:29
@bjorn3

bjorn3 commented Jan 13, 2026

Copy link
Copy Markdown
Member Author

For the try build it saves 2GB or 4% of the total space the build takes (46GB -> 44GB). Hoped it would be a bit more, but still not bad I think. And maybe it gives a higher relative saving when not collecting PGO profiles?

@rustbot ready

@Kobzol

Kobzol commented Jan 13, 2026

Copy link
Copy Markdown
Member

Let's do a full try build to see the codegen backend savings (we can compare them with the parent commit, should be enough), and also run perf., just in case.

@bors try jobs=dist-x86_64-linux @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 13, 2026
rust-bors Bot pushed a commit that referenced this pull request Jan 13, 2026
Build rustc and codegen backends with -Zno-embed-metadata


try-job: dist-x86_64-linux
@bjorn3

bjorn3 commented Jan 13, 2026

Copy link
Copy Markdown
Member Author

For cg_clif the .rmeta section of the codegen backend dylib when built from the cg_clif repo is almost 1MB out of the 15MB the full dylib uses. The savings from this PR should be near identical, though the full size of the dylib may be different due to different codegen options.

@rust-bors

rust-bors Bot commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 2cbe7f7 (2cbe7f7eda161d598e47752d03fc34a1539dad7c, parent: 9b81629631b382fd49ee3a20ac47797b1467e52d)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (2cbe7f7): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (secondary -1.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.6% [2.5%, 2.7%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.1% [-6.1%, -2.2%] 3
All ❌✅ (primary) - - 0

Cycles

Results (secondary 2.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.7% [2.1%, 3.1%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 476.337s -> 475.884s (-0.10%)
Artifact size: 383.08 MiB -> 383.14 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 13, 2026
@Kobzol

Kobzol commented Jan 14, 2026

Copy link
Copy Markdown
Member

Before:

2026-01-13T17:34:05.4564183Z -rw-r--r-- 1 root root  2.5M Jan 13 16:45 rustc-codegen-cranelift-nightly-x86_64-unknown-linux-gnu.tar.xz
2026-01-13T17:34:05.4565056Z -rw-r--r-- 1 root root  1.1M Jan 13 17:19 rustc-codegen-gcc-nightly-x86_64-unknown-linux-gnu.tar.xz

After:

2026-01-13T22:55:02.7071176Z -rw-r--r-- 1 root root  2.3M Jan 13 22:07 rustc-codegen-cranelift-nightly-x86_64-unknown-linux-gnu.tar.xz
2026-01-13T22:55:02.7072077Z -rw-r--r-- 1 root root  827K Jan 13 22:40 rustc-codegen-gcc-nightly-x86_64-unknown-linux-gnu.tar.xz

And no other components seem to have changed their size. Yeah, pretty nice, a solid ~10%!

Comment thread src/bootstrap/src/core/build_steps/compile.rs
Comment thread src/bootstrap/src/core/builder/cargo.rs Outdated
@Kobzol

Kobzol commented Aug 15, 2026

Copy link
Copy Markdown
Member

Could you please rebase this onto #161102, and apply it to everything in Builder::cargo?

@bjorn3
bjorn3 force-pushed the rustc_no_embed_metadata branch from 5e75882 to 005f20e Compare August 16, 2026 12:09
@rustbot

This comment has been minimized.

@Kobzol

Kobzol commented Aug 16, 2026

Copy link
Copy Markdown
Member

You can r=me if CI passes.

@rust-log-analyzer

This comment has been minimized.

@Kobzol

Kobzol commented Aug 16, 2026

Copy link
Copy Markdown
Member

Hmm, there are some steps that run with in-tree Cargo even without self.local_rebuild. I guess that it will be better to wait for the beta bump, which should happen soon, and then use -Zembed-metadata=no unconditionally.

@bjorn3

bjorn3 commented Aug 16, 2026

Copy link
Copy Markdown
Member Author

@rustbot blocked

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 16, 2026
@rust-bors

This comment has been minimized.

While this won't change much for rustc and rustc-dev, it should make
codegen backends a bit smaller by omitting their crate metadata. In
addition it should reduce disk usage while compiling.
@bjorn3
bjorn3 force-pushed the rustc_no_embed_metadata branch from 005f20e to bbc9e66 Compare August 21, 2026 09:49
@rustbot

rustbot commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main 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.

@bjorn3

bjorn3 commented Aug 21, 2026

Copy link
Copy Markdown
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Aug 21, 2026
@Kobzol

Kobzol commented Aug 21, 2026

Copy link
Copy Markdown
Member

@bors try jobs=x86_64-gnu,x86_64-msvc*,aarch64-apple*

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 21, 2026
Build rustc and codegen backends with -Zembed-metadata=no


try-job: x86_64-gnu
try-job: x86_64-msvc*
try-job: aarch64-apple*
@rust-bors

rust-bors Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: d2c6d50 (d2c6d50e3778d6d894ccb1d84a50782edfb1039e)
Base parent: 16a623a (16a623ad672a92409b5c04beb303583c6cf72a7e)

@Kobzol

Kobzol commented Aug 21, 2026

Copy link
Copy Markdown
Member

Ok, looks good! Let's try.

@bors r+ rollup=iffy

@rust-bors

rust-bors Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

📌 Commit bbc9e66 has been approved by Kobzol

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 21, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 21, 2026
…Kobzol

Build rustc and codegen backends with -Zembed-metadata=no

While this won't change much for rustc and rustc-dev, it should make codegen backends a bit smaller by omitting their crate metadata. In addition it should reduce disk usage while compiling.

Follow up to rust-lang#145343
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 21, 2026
…Kobzol

Build rustc and codegen backends with -Zembed-metadata=no

While this won't change much for rustc and rustc-dev, it should make codegen backends a bit smaller by omitting their crate metadata. In addition it should reduce disk usage while compiling.

Follow up to rust-lang#145343
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 21, 2026
…Kobzol

Build rustc and codegen backends with -Zembed-metadata=no

While this won't change much for rustc and rustc-dev, it should make codegen backends a bit smaller by omitting their crate metadata. In addition it should reduce disk usage while compiling.

Follow up to rust-lang#145343
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants