From 152fe2b87d76e0257d92b8b32a49b67fa3e3eb2d Mon Sep 17 00:00:00 2001 From: yenru0 Date: Tue, 22 Sep 2026 19:52:41 +0900 Subject: [PATCH] bundle: Ship pdfium runtime library for native PDF viewing --- .cargo/config.toml | 6 +++++- script/bundle-linux | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 8ed5893b99..f38df16617 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -18,7 +18,11 @@ rustflags = [ # We need lld to link libwebrtc.a successfully on aarch64-linux [target.aarch64-unknown-linux-gnu] -rustflags = ["-C", "link-arg=-fuse-ld=lld"] +rustflags = ["-C", "link-arg=-fuse-ld=lld", "-C", "link-arg=-Wl,-rpath,$ORIGIN/../lib"] + +# Lets dlopen("libpdfium.so") resolve the copy bundled in /lib. +[target.x86_64-unknown-linux-gnu] +rustflags = ["-C", "link-arg=-Wl,-rpath,$ORIGIN/../lib"] [env] MACOSX_DEPLOYMENT_TARGET = "10.15.7" diff --git a/script/bundle-linux b/script/bundle-linux index 23df9f1bd0..0fa36870d5 100755 --- a/script/bundle-linux +++ b/script/bundle-linux @@ -171,6 +171,28 @@ mkdir -p "${zed_dir}/lib" rm -rf "${zed_dir}/lib/*" cp $(find_libs) "${zed_dir}/lib" +# PDFium is dlopen'd at runtime by the bundled pdf_viewer for native PDF viewing; +# find_libs cannot see it because the binaries are not linked against it. +case "$(uname -m)" in + x86_64) pdfium_arch="x64" ;; + aarch64) pdfium_arch="arm64" ;; + *) echo "Unsupported architecture for pdfium: $(uname -m)" >&2 && exit 1 ;; +esac +pdfium_tag="chromium/8066" +case "${pdfium_arch}" in + x64) pdfium_sha256="0b43f405477cf2cfc4dbff06905093c3309756c6bca1fb9da99234a2ca97fed2" ;; + arm64) pdfium_sha256="0e6f90dccbc6b81fd5d7106abaf164c4222178f024c204d00d526b60fd2ad535" ;; +esac +pdfium_tgz="${target_dir}/pdfium-linux-${pdfium_arch}.tgz" +if ! echo "${pdfium_sha256} ${pdfium_tgz}" | sha256sum --check --status 2>/dev/null; then + curl -fsSLo "${pdfium_tgz}" "https://github.com/bblanchon/pdfium-binaries/releases/download/${pdfium_tag}/pdfium-linux-${pdfium_arch}.tgz" + echo "${pdfium_sha256} ${pdfium_tgz}" | sha256sum --check - +fi +pdfium_tmp=$(mktemp -d) +tar -xzf "${pdfium_tgz}" -C "${pdfium_tmp}" "lib/libpdfium.so" +cp "${pdfium_tmp}/lib/libpdfium.so" "${zed_dir}/lib/libpdfium.so" +rm -rf "${pdfium_tmp}" + # Icons mkdir -p "${zed_dir}/share/icons/hicolor/512x512/apps" cp "crates/zed/resources/app-icon$suffix.png" "${zed_dir}/share/icons/hicolor/512x512/apps/zed.png"