From 68b6504506417b9c44f81eb7f5ffcb82fb4d82c4 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 31 Aug 2026 05:42:11 +0000 Subject: [PATCH] Enable share-generics in release bundle builds (#63432) Cargo joins `build.rustflags` across config sources, so the base `symbol-mangling-version=v0` and `tokio_unstable` flags still apply after the newly added config. With sccache disabled, `cargo build --release -p zed` on macOS: Before: zed binary 420677880 bytes After: zed binary 375109048 bytes (-10.8%, -45.6MB) After `strip -x` of both (https://github.com/zed-industries/zed/pull/63429): 313879024 -> 307727432 bytes (-2.0%, -6.2MB) The rest of the delta is the smaller symbol table. `drop_glue` instantiations: 101778 -> 65041. Release Notes: - N/A --- .cargo/bundle-config.toml | 5 +++++ script/bundle-linux | 4 ++-- script/bundle-mac | 4 ++-- script/bundle-windows.ps1 | 10 +++++----- 4 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 .cargo/bundle-config.toml diff --git a/.cargo/bundle-config.toml b/.cargo/bundle-config.toml new file mode 100644 index 0000000000..66c1f2ec08 --- /dev/null +++ b/.cargo/bundle-config.toml @@ -0,0 +1,5 @@ +[env] +RUSTC_BOOTSTRAP = "1" + +[build] +rustflags = ["-Z", "share-generics=y"] diff --git a/script/bundle-linux b/script/bundle-linux index 79de85b2a8..1664fbf5dc 100755 --- a/script/bundle-linux +++ b/script/bundle-linux @@ -83,7 +83,7 @@ if [[ "$(uname -m)" == "aarch64" ]]; then else export RUSTFLAGS="${RUSTFLAGS:-} -C link-args=-Wl,--disable-new-dtags,-rpath,\$ORIGIN/../lib" fi -cargo build --release --target "${target_triple}" --package zed --package cli +cargo --config .cargo/bundle-config.toml build --release --target "${target_triple}" --package zed --package cli # Build remote_server in separate invocation to prevent feature unification from other crates # from influencing dynamic libraries required by it. if [[ "$remote_server_triple" == "$musl_triple" ]]; then @@ -91,7 +91,7 @@ if [[ "$remote_server_triple" == "$musl_triple" ]]; then musl_cc_var="CC_$(echo "$remote_server_triple" | tr '-' '_')" export "$musl_cc_var"=musl-gcc fi -cargo build --release --target "${remote_server_triple}" --package remote_server +cargo --config .cargo/bundle-config.toml build --release --target "${remote_server_triple}" --package remote_server # Upload debug info to sentry.io if ! command -v sentry-cli >/dev/null 2>&1; then diff --git a/script/bundle-mac b/script/bundle-mac index eae4f861ba..477efb5a4f 100755 --- a/script/bundle-mac +++ b/script/bundle-mac @@ -87,10 +87,10 @@ script/generate-licenses rustup target add $target_triple echo "Compiling zed binaries" -cargo build ${build_flag} --package zed --package cli --target $target_triple +cargo --config .cargo/bundle-config.toml build ${build_flag} --package zed --package cli --target $target_triple # Build remote_server in separate invocation to prevent feature unification from other crates # from influencing dynamic libraries required by it. -cargo build ${build_flag} --package remote_server --target $target_triple +cargo --config .cargo/bundle-config.toml build ${build_flag} --package remote_server --target $target_triple echo "Creating application bundle" pushd crates/zed diff --git a/script/bundle-windows.ps1 b/script/bundle-windows.ps1 index 99b2858f8e..786f07922b 100644 --- a/script/bundle-windows.ps1 +++ b/script/bundle-windows.ps1 @@ -116,20 +116,20 @@ function GenerateLicenses { function BuildZedAndItsFriends { Write-Output "Building Zed and its friends, for channel: $channel" # Build zed.exe, cli.exe and auto_update_helper.exe - cargo build --release --package zed --package cli --package auto_update_helper --target $target + cargo --config .cargo/bundle-config.toml build --release --package zed --package cli --package auto_update_helper --target $target Copy-Item -Path ".\$CargoOutDir\zed.exe" -Destination "$innoDir\Zed.exe" -Force Copy-Item -Path ".\$CargoOutDir\cli.exe" -Destination "$innoDir\cli.exe" -Force Copy-Item -Path ".\$CargoOutDir\auto_update_helper.exe" -Destination "$innoDir\auto_update_helper.exe" -Force # Build explorer_command_injector.dll switch ($channel) { "stable" { - cargo build --release --features stable --no-default-features --package explorer_command_injector --target $target + cargo --config .cargo/bundle-config.toml build --release --features stable --no-default-features --package explorer_command_injector --target $target } "preview" { - cargo build --release --features preview --no-default-features --package explorer_command_injector --target $target + cargo --config .cargo/bundle-config.toml build --release --features preview --no-default-features --package explorer_command_injector --target $target } default { - cargo build --release --package explorer_command_injector --target $target + cargo --config .cargo/bundle-config.toml build --release --package explorer_command_injector --target $target } } Copy-Item -Path ".\$CargoOutDir\explorer_command_injector.dll" -Destination "$innoDir\zed_explorer_command_injector.dll" -Force @@ -137,7 +137,7 @@ function BuildZedAndItsFriends { function BuildRemoteServer { Write-Output "Building remote_server for $target" - cargo build --release --package remote_server --target $target + cargo --config .cargo/bundle-config.toml build --release --package remote_server --target $target # Create zipped remote server binary $remoteServerSrc = (Resolve-Path ".\$CargoOutDir\remote_server.exe").Path