From 55a875b57733ae982a3f4c0a9256ff85374787b4 Mon Sep 17 00:00:00 2001 From: Doonv <58695417+doonv@users.noreply.github.com> Date: Tue, 7 Apr 2026 01:16:49 +0300 Subject: [PATCH] Add `-Zno-embed-metadata` Cargo flag to `config_fast_builds.toml` (#23694) # Objective Reduce the size of the `target` directory with Bevy builds. ## Solution I found this [blog](https://kobzol.github.io/rust/rustc/2025/06/02/reduce-cargo-target-dir-size-with-z-no-embed-metadata.html) about `-Zno-embed-metadata`, Cargo flag that reduces the size of the `target` directory by avoiding duplicate metadata or something. ## Testing I compiled the `main` branch with and without this branch and the size of the `target` directory went from 11.61G without the flag to 11.15G with the flag. Not a huge difference, but still a 4% decrease. --- .cargo/config_fast_builds.toml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.cargo/config_fast_builds.toml b/.cargo/config_fast_builds.toml index f352ffd4a5..34e7428b7b 100644 --- a/.cargo/config_fast_builds.toml +++ b/.cargo/config_fast_builds.toml @@ -64,6 +64,16 @@ # checking, and more. We currently set `threads=0`, which defaults to the amount of cores in your CPU. # # For more information, see the blog post at . +# +# ## `no-embed-metadata` +# +# This options avoids unnecessary metadata duplication and can reduce the size of the `target` directory by +# around 5% on dev builds, potentially more on release builds. +# +# Note: Unlike other flags in this file, `no-embed-metadata` is a Cargo flag, not a rustc flag, and is at the +# bottom of this file. +# +# For more information, see the blog post at . [target.x86_64-unknown-linux-gnu] rustflags = [ @@ -142,3 +152,7 @@ rustflags = [ # In most cases the gains are negligible, but if you are on macOS and have slow compile times you should see significant gains. # [profile.dev] # debug = 1 + +# Nightly +# [unstable] +# no-embed-metadata = true