From fe7d53cb9695d04802babe9850fc1c432ca9c40e Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 21 Jun 2024 17:32:32 -0600 Subject: [PATCH] Dynamicer builds (#13074) Fixes https://github.com/zed-industries/zed/issues/13073 Note that, contrary to the issue's text, we're still shipping a statically bundled sqlite3 after this PR. We use enough new features of sqlite, like `sqlite3_error_offset` and `STRICT`, that our minimum version (v3.38.0) is higher than is presumably accessible on Ubuntu. Release Notes: - N/A --------- Co-authored-by: Mikayla --- .github/workflows/ci.yml | 8 ++++---- Cargo.lock | 5 +++-- Cargo.toml | 5 +---- crates/client/Cargo.toml | 10 ++-------- crates/gpui/Cargo.toml | 1 + crates/rpc/Cargo.toml | 4 ++++ crates/sqlez/src/connection.rs | 18 ++++++++++++++++-- crates/sqlez_macros/src/sqlez_macros.rs | 5 +++++ script/linux | 6 ++++++ 9 files changed, 42 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de8051e361..62c7999f82 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -307,7 +307,7 @@ jobs: exit 1 fi - - name: Create and upload Linux .tar.gz bundle + - name: Create Linux .tar.gz bundle run: script/bundle-linux - name: Upload Linux bundle to workflow run if main branch or specific label @@ -315,7 +315,7 @@ jobs: if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }} with: name: zed-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.tar.gz - path: zed-*.tar.gz + path: target/release/zed-*.tar.gz - name: Upload app bundle to release uses: softprops/action-gh-release@v1 @@ -348,12 +348,12 @@ jobs: - name: Set up Clang run: | sudo apt-get update - sudo apt-get install -y llvm-10 clang-10 build-essential cmake pkg-config libasound2-dev libfontconfig-dev libwayland-dev libxkbcommon-x11-dev libssl-dev libzstd-dev libvulkan1 libgit2-dev + sudo apt-get install -y llvm-10 clang-10 build-essential cmake pkg-config libasound2-dev libfontconfig-dev libwayland-dev libxkbcommon-x11-dev libssl-dev libsqlite3-dev libzstd-dev libvulkan1 libgit2-dev echo "/usr/lib/llvm-10/bin" >> $GITHUB_PATH - uses: rui314/setup-mold@v1 with: - mold_version: 2.32.0 + mold-version: 2.32.0 - name: rustup run: | diff --git a/Cargo.lock b/Cargo.lock index 581df52c41..c0609d47b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2290,6 +2290,7 @@ dependencies = [ "futures 0.3.28", "gpui", "http 0.1.0", + "isahc", "lazy_static", "log", "once_cell", @@ -7103,9 +7104,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.2.3+3.2.1" +version = "300.3.0+3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cff92b6f71555b61bb9315f7c64da3ca43d87531622120fea0195fc761b4843" +checksum = "eba8804a1c5765b18c4b3f907e6897ebabeedebc9830e1a0046c4a4cf44663e1" dependencies = [ "cc", ] diff --git a/Cargo.toml b/Cargo.toml index 2c8245a1c4..6900df4dea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -312,10 +312,7 @@ image = "0.23" indexmap = { version = "1.6.2", features = ["serde"] } indoc = "1" # We explicitly disable http2 support in isahc. -isahc = { version = "1.7.2", default-features = false, features = [ - "static-curl", - "text-decoding", -] } +isahc = { version = "1.7.2", default-features = false, features = [ "text-decoding" ] } itertools = "0.11.0" lazy_static = "1.4.0" libc = "0.2" diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index ae44d7cd30..fcc59a2578 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -19,7 +19,6 @@ test-support = ["clock/test-support", "collections/test-support", "gpui/test-sup anyhow.workspace = true async-recursion = "0.3" async-tungstenite = { version = "0.16", features = ["async-std", "async-native-tls"] } -async-native-tls = { version = "0.5.0", features = ["vendored"] } chrono = { workspace = true, features = ["serde"] } clock.workspace = true collections.workspace = true @@ -68,10 +67,5 @@ windows.workspace = true [target.'cfg(target_os = "macos")'.dependencies] cocoa.workspace = true - -[target.'cfg(target_os = "linux")'.dependencies] -async-native-tls = {"version" = "0.5.0", features = ["vendored"]} -# This is an indirect dependency of async-tungstenite that is included -# here so we can vendor libssl with the feature flag. -[package.metadata.cargo-machete] -ignored = ["async-native-tls"] +isahc = { workspace = true, features = ["static-curl"] } +async-native-tls = { version = "0.5.0", features = ["vendored"] } diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index 8ca4d8e679..409fe5ce59 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -135,6 +135,7 @@ xim = { git = "https://github.com/npmania/xim-rs", rev = "27132caffc5b9bc9c432ca "x11rb-xcb", "x11rb-client", ] } +font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "5a5c4d4", features = ["source-fontconfig-dlopen"] } x11-clipboard = "0.9.2" [target.'cfg(windows)'.dependencies] diff --git a/crates/rpc/Cargo.toml b/crates/rpc/Cargo.toml index 8fadc97b61..3ba2cb2dd5 100644 --- a/crates/rpc/Cargo.toml +++ b/crates/rpc/Cargo.toml @@ -35,6 +35,10 @@ tracing = { version = "0.1.34", features = ["log"] } util.workspace = true zstd = "0.11" +[target.'cfg(target_os = "linux")'.dependencies] +zstd = { version = "0.11", features = [ "pkg-config" ] } + + [dev-dependencies] collections = { workspace = true, features = ["test-support"] } env_logger.workspace = true diff --git a/crates/sqlez/src/connection.rs b/crates/sqlez/src/connection.rs index 2d5d4c41f5..d1643782fa 100644 --- a/crates/sqlez/src/connection.rs +++ b/crates/sqlez/src/connection.rs @@ -128,9 +128,15 @@ impl Connection { &mut remaining_sql_ptr, ); + #[cfg(not(target_os = "linux"))] + let offset = sqlite3_error_offset(temp_connection.sqlite3); + + #[cfg(target_os = "linux")] + let offset = 0; + ( sqlite3_errcode(temp_connection.sqlite3), - sqlite3_error_offset(temp_connection.sqlite3), + offset, sqlite3_errmsg(temp_connection.sqlite3), Some(temp_connection), ) @@ -142,9 +148,16 @@ impl Connection { &mut raw_statement, &mut remaining_sql_ptr, ); + + #[cfg(not(target_os = "linux"))] + let offset = sqlite3_error_offset(self.sqlite3); + + #[cfg(target_os = "linux")] + let offset = 0; + ( sqlite3_errcode(self.sqlite3), - sqlite3_error_offset(self.sqlite3), + offset, sqlite3_errmsg(self.sqlite3), None, ) @@ -395,6 +408,7 @@ mod test { ); } + #[cfg(not(target_os = "linux"))] #[test] fn test_sql_has_syntax_errors() { let connection = Connection::open_memory(Some("test_sql_has_syntax_errors")); diff --git a/crates/sqlez_macros/src/sqlez_macros.rs b/crates/sqlez_macros/src/sqlez_macros.rs index 675576c997..42a404a45c 100644 --- a/crates/sqlez_macros/src/sqlez_macros.rs +++ b/crates/sqlez_macros/src/sqlez_macros.rs @@ -12,7 +12,12 @@ lazy_static::lazy_static! { pub fn sql(tokens: TokenStream) -> TokenStream { let (spans, sql) = make_sql(tokens); + #[cfg(not(target_os = "linux"))] let error = SQLITE.sql_has_syntax_error(sql.trim()); + + #[cfg(target_os = "linux")] + let error: Option<(String, usize)> = None; + let formatted_sql = sqlformat::format(&sql, &sqlformat::QueryParams::None, Default::default()); if let Some((error, error_offset)) = error { diff --git a/script/linux b/script/linux index 86dd9b253a..ee192e4429 100755 --- a/script/linux +++ b/script/linux @@ -30,6 +30,7 @@ if [[ -n $apt ]]; then jq gettext-base elfutils + libsqlite3-dev ) $maysudo "$apt" install -y "${deps[@]}" exit 0 @@ -56,6 +57,7 @@ if [[ -n $dnf ]]; then perl-File-Compare perl-File-Copy vulkan-loader + sqlite-devel ) # libxkbcommon-x11-devel is in the crb repo on RHEL and CentOS, not needed for Fedora @@ -84,6 +86,7 @@ if [[ -n $zyp ]]; then libzstd-devel libvulkan1 mold + sqlite3-devel ) $maysudo "$zyp" install -y "${deps[@]}" exit 0 @@ -105,6 +108,7 @@ if [[ -n $pacman ]]; then zstd pkgconf mold + sqlite ) $maysudo "$pacman" -S --needed --noconfirm "${deps[@]}" exit 0 @@ -124,6 +128,7 @@ if [[ -n $xbps ]]; then wayland-devel vulkan-loader mold + sqlite-devel ) $maysudo "$xbps" -Syu "${deps[@]}" exit 0 @@ -143,6 +148,7 @@ if [[ -n $emerge ]]; then x11-libs/libxcb x11-libs/libxkbcommon sys-devel/mold + dev-db/sqlite ) $maysudo "$emerge" -u "${deps[@]}" exit 0