Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Reduce release binary sizes (#65168)

Kirill Bulatov976ab33fb4b2
diff --git a/.cargo/bundle-config.toml b/.cargo/bundle-config.toml
index 0fc6a68ff96..f00d66614f0 100644
--- a/.cargo/bundle-config.toml
+++ b/.cargo/bundle-config.toml
@@ -1,3 +1,29 @@
+[profile.release]
+opt-level = "z"
+
+[profile.release.package]
+"*" = { opt-level = 3 }
+cli = { opt-level = 3 }
+editor = { opt-level = 3 }
+gpui = { opt-level = 3 }
+gpui_apple = { opt-level = 3 }
+gpui_linux = { opt-level = 3 }
+gpui_macos = { opt-level = 3 }
+gpui_platform = { opt-level = 3 }
+gpui_shared_string = { opt-level = 3 }
+gpui_util = { opt-level = 3 }
+gpui_wgpu = { opt-level = 3 }
+gpui_windows = { opt-level = 3 }
+language = { opt-level = 3 }
+multi_buffer = { opt-level = 3 }
+project = { opt-level = 3 }
+remote_server = { opt-level = 3 }
+rope = { opt-level = 3 }
+scheduler = { opt-level = 3 }
+sum_tree = { opt-level = 3 }
+text = { opt-level = 3 }
+zed = { codegen-units = 1 }
+
[target.'cfg(target_os = "linux")']
rustflags = ["-C", "link-args=-Wl,--disable-new-dtags,-rpath,$ORIGIN/../lib"]
diff --git a/script/bundle-mac b/script/bundle-mac
index 44f36aa1b69..e00632cc50f 100755
--- a/script/bundle-mac
+++ b/script/bundle-mac
@@ -91,7 +91,12 @@ script/generate-licenses
rustup target add $target_triple
echo "Compiling zed binaries"
-cargo --config .cargo/bundle-config.toml build ${build_flag} ${zed_features} --package zed --package cli --target $target_triple
+if [[ "$target_dir" = "release" ]]; then
+ cargo --config .cargo/bundle-config.toml rustc ${build_flag} ${zed_features} --package zed --bin zed --target $target_triple -- -C 'link-arg=-Wl,-unexported_symbol,__R*'
+ cargo --config .cargo/bundle-config.toml build ${build_flag} --package cli --target $target_triple
+else
+ cargo --config .cargo/bundle-config.toml build ${build_flag} ${zed_features} --package zed --package cli --target $target_triple
+fi
# Build remote_server in separate invocation to prevent feature unification from other crates
# from influencing dynamic libraries required by it.
cargo --config .cargo/bundle-config.toml build ${build_flag} ${remote_server_features} --package remote_server --target $target_triple