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.

Fix incorrect LLD used when bundling (#65183)

Kirill Bulatov204362325cb2
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index c9aea2386dc..330025b34dd 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -386,6 +386,7 @@ jobs:
ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
CC: clang-18
CXX: clang++-18
+ LLD: /usr/bin/ld.lld-18
steps:
- name: steps::checkout_repo
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
@@ -431,6 +432,7 @@ jobs:
ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
CC: clang-18
CXX: clang++-18
+ LLD: /usr/bin/ld.lld-18
steps:
- name: steps::checkout_repo
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
diff --git a/.github/workflows/release_nightly.yml b/.github/workflows/release_nightly.yml
index c8f47291fcf..1719f78d65f 100644
--- a/.github/workflows/release_nightly.yml
+++ b/.github/workflows/release_nightly.yml
@@ -105,6 +105,7 @@ jobs:
ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
CC: clang-18
CXX: clang++-18
+ LLD: /usr/bin/ld.lld-18
steps:
- name: steps::checkout_repo
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
@@ -154,6 +155,7 @@ jobs:
ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
CC: clang-18
CXX: clang++-18
+ LLD: /usr/bin/ld.lld-18
steps:
- name: steps::checkout_repo
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
diff --git a/.github/workflows/run_bundling.yml b/.github/workflows/run_bundling.yml
index a697d96f2c1..5f409261617 100644
--- a/.github/workflows/run_bundling.yml
+++ b/.github/workflows/run_bundling.yml
@@ -23,6 +23,7 @@ jobs:
ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
CC: clang-18
CXX: clang++-18
+ LLD: /usr/bin/ld.lld-18
steps:
- name: steps::checkout_repo
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
@@ -67,6 +68,7 @@ jobs:
ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
CC: clang-18
CXX: clang++-18
+ LLD: /usr/bin/ld.lld-18
steps:
- name: steps::checkout_repo
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
diff --git a/script/bundle-linux b/script/bundle-linux
index 0d6f5fbfbfa..64ec3a8ffa7 100755
--- a/script/bundle-linux
+++ b/script/bundle-linux
@@ -114,15 +114,19 @@ if "$rustup_installed"; then
fi
export CC=${CC:-$(which clang)}
-lld=$("$CC" -print-prog-name=ld.lld)
+lld=${LLD:-$("$CC" -print-prog-name=ld.lld)}
+if [[ "$lld" != /* || ! -x "$lld" ]]; then
+ echo "Bundling requires an absolute executable linker path; set LLD (e.g. LLD=/usr/bin/ld.lld-18)." >&2
+ exit 1
+fi
lld_version=$("$lld" --version)
if [[ ! "$lld_version" =~ LLD\ ([0-9]+)\. ]] || (( BASH_REMATCH[1] < 12 )); then
- echo "Bundling requires LLD 12 or newer for safe ICF; select a matching compiler with CC (e.g. CC=clang-18)." >&2
+ echo "Bundling requires LLD 12 or newer for safe ICF; set LLD to a supported linker (e.g. LLD=/usr/bin/ld.lld-18)." >&2
exit 1
fi
# Build binary in release mode
-cargo --config .cargo/bundle-config.toml rustc --release --target "${target_triple}" --package zed --bin zed -- -C linker="$CC" -C llvm-args=-addrsig -C link-arg=-fuse-ld=lld -C link-arg=-Wl,--icf=safe
+cargo --config .cargo/bundle-config.toml rustc --release --target "${target_triple}" --package zed --bin zed -- -C linker="$CC" -C llvm-args=-addrsig -C link-arg=-fuse-ld=lld -C link-arg=--ld-path="$lld" -C link-arg=-Wl,--icf=safe
cargo --config .cargo/bundle-config.toml build --release --target "${target_triple}" --package cli
# Build remote_server in separate invocation to prevent feature unification from other crates
# from influencing dynamic libraries required by it.
diff --git a/tooling/xtask/src/tasks/workflows/run_bundling.rs b/tooling/xtask/src/tasks/workflows/run_bundling.rs
index 07b5aadb08f..3268bce6bdc 100644
--- a/tooling/xtask/src/tasks/workflows/run_bundling.rs
+++ b/tooling/xtask/src/tasks/workflows/run_bundling.rs
@@ -185,6 +185,7 @@ pub(crate) fn bundle_linux(
.envs(bundle_envs(platform))
.add_env(Env::new("CC", "clang-18"))
.add_env(Env::new("CXX", "clang++-18"))
+ .add_env(Env::new("LLD", "/usr/bin/ld.lld-18"))
.add_step(steps::checkout_repo())
.add_step(steps::cache_rust_dependencies_namespace())
.when_some(release_channel, |job, release_channel| {