livekit: Correctly handle runtime deps: libva and libva-drm (#50527)

Jakub Konka created

Release Notes:

- N/A

Change summary

Cargo.lock            | 15 ++++++++-------
Cargo.toml            |  4 ++--
crates/zed/Cargo.toml |  3 +++
crates/zed/build.rs   | 19 +++++++++++++++++++
nix/build.nix         |  1 +
script/linux          |  4 ++++
6 files changed, 37 insertions(+), 9 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -9699,7 +9699,7 @@ dependencies = [
 [[package]]
 name = "libwebrtc"
 version = "0.3.26"
-source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=fccf29d1d0d0a139b2e50746b0b9a1bac828fa04#fccf29d1d0d0a139b2e50746b0b9a1bac828fa04"
+source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=37835f840d0070d45ac8b31cce6a6ae7aca3f459#37835f840d0070d45ac8b31cce6a6ae7aca3f459"
 dependencies = [
  "cxx",
  "glib",
@@ -9797,7 +9797,7 @@ checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092"
 [[package]]
 name = "livekit"
 version = "0.7.32"
-source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=fccf29d1d0d0a139b2e50746b0b9a1bac828fa04#fccf29d1d0d0a139b2e50746b0b9a1bac828fa04"
+source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=37835f840d0070d45ac8b31cce6a6ae7aca3f459#37835f840d0070d45ac8b31cce6a6ae7aca3f459"
 dependencies = [
  "base64 0.22.1",
  "bmrng",
@@ -9823,7 +9823,7 @@ dependencies = [
 [[package]]
 name = "livekit-api"
 version = "0.4.14"
-source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=fccf29d1d0d0a139b2e50746b0b9a1bac828fa04#fccf29d1d0d0a139b2e50746b0b9a1bac828fa04"
+source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=37835f840d0070d45ac8b31cce6a6ae7aca3f459#37835f840d0070d45ac8b31cce6a6ae7aca3f459"
 dependencies = [
  "base64 0.21.7",
  "futures-util",
@@ -9850,7 +9850,7 @@ dependencies = [
 [[package]]
 name = "livekit-protocol"
 version = "0.7.1"
-source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=fccf29d1d0d0a139b2e50746b0b9a1bac828fa04#fccf29d1d0d0a139b2e50746b0b9a1bac828fa04"
+source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=37835f840d0070d45ac8b31cce6a6ae7aca3f459#37835f840d0070d45ac8b31cce6a6ae7aca3f459"
 dependencies = [
  "futures-util",
  "livekit-runtime",
@@ -9866,7 +9866,7 @@ dependencies = [
 [[package]]
 name = "livekit-runtime"
 version = "0.4.0"
-source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=fccf29d1d0d0a139b2e50746b0b9a1bac828fa04#fccf29d1d0d0a139b2e50746b0b9a1bac828fa04"
+source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=37835f840d0070d45ac8b31cce6a6ae7aca3f459#37835f840d0070d45ac8b31cce6a6ae7aca3f459"
 dependencies = [
  "tokio",
  "tokio-stream",
@@ -19841,7 +19841,7 @@ dependencies = [
 [[package]]
 name = "webrtc-sys"
 version = "0.3.23"
-source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=fccf29d1d0d0a139b2e50746b0b9a1bac828fa04#fccf29d1d0d0a139b2e50746b0b9a1bac828fa04"
+source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=37835f840d0070d45ac8b31cce6a6ae7aca3f459#37835f840d0070d45ac8b31cce6a6ae7aca3f459"
 dependencies = [
  "cc",
  "cxx",
@@ -19855,7 +19855,7 @@ dependencies = [
 [[package]]
 name = "webrtc-sys-build"
 version = "0.3.13"
-source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=fccf29d1d0d0a139b2e50746b0b9a1bac828fa04#fccf29d1d0d0a139b2e50746b0b9a1bac828fa04"
+source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=37835f840d0070d45ac8b31cce6a6ae7aca3f459#37835f840d0070d45ac8b31cce6a6ae7aca3f459"
 dependencies = [
  "anyhow",
  "fs2",
@@ -21791,6 +21791,7 @@ dependencies = [
  "parking_lot",
  "paths",
  "picker",
+ "pkg-config",
  "pretty_assertions",
  "profiling",
  "project",

Cargo.toml 🔗

@@ -835,8 +835,8 @@ notify = { git = "https://github.com/zed-industries/notify.git", rev = "ce58c24c
 notify-types = { git = "https://github.com/zed-industries/notify.git", rev = "ce58c24cad542c28e04ced02e20325a4ec28a31d" }
 windows-capture = { git = "https://github.com/zed-industries/windows-capture.git", rev = "f0d6c1b6691db75461b732f6d5ff56eed002eeb9" }
 calloop = { git = "https://github.com/zed-industries/calloop" }
-livekit = { git = "https://github.com/zed-industries/livekit-rust-sdks", rev = "fccf29d1d0d0a139b2e50746b0b9a1bac828fa04" }
-libwebrtc = { git = "https://github.com/zed-industries/livekit-rust-sdks", rev = "fccf29d1d0d0a139b2e50746b0b9a1bac828fa04" }
+livekit = { git = "https://github.com/zed-industries/livekit-rust-sdks", rev = "37835f840d0070d45ac8b31cce6a6ae7aca3f459" }
+libwebrtc = { git = "https://github.com/zed-industries/livekit-rust-sdks", rev = "37835f840d0070d45ac8b31cce6a6ae7aca3f459" }
 
 [profile.dev]
 split-debuginfo = "unpacked"

crates/zed/Cargo.toml 🔗

@@ -241,6 +241,9 @@ gpui = { workspace = true, features = [
 ] }
 ashpd.workspace = true
 
+[target.'cfg(target_os = "linux")'.build-dependencies]
+pkg-config = "0.3.22"
+
 [dev-dependencies]
 call = { workspace = true, features = ["test-support"] }
 dap = { workspace = true, features = ["test-support"] }

crates/zed/build.rs 🔗

@@ -2,6 +2,25 @@
 use std::process::Command;
 
 fn main() {
+    #[cfg(target_os = "linux")]
+    {
+        // Add rpaths for libraries that webrtc-sys dlopens at runtime.
+        // This is mostly required for hosts with non-standard SO installation
+        // locations such as NixOS.
+        let dlopened_libs = ["libva", "libva-drm"];
+
+        let mut rpath_dirs = std::collections::BTreeSet::new();
+        for lib in &dlopened_libs {
+            if let Some(libdir) = pkg_config::get_variable(lib, "libdir").ok() {
+                rpath_dirs.insert(libdir);
+            }
+        }
+
+        for dir in &rpath_dirs {
+            println!("cargo:rustc-link-arg=-Wl,-rpath,{dir}");
+        }
+    }
+
     if cfg!(target_os = "macos") {
         println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.15.7");
 

nix/build.nix 🔗

@@ -233,6 +233,7 @@ let
           lib.makeLibraryPath [
             gpu-lib
             wayland
+            libva
           ]
         }";
 

script/linux 🔗

@@ -155,6 +155,7 @@ if [[ -n $zyp ]]; then
     cmake
     fontconfig-devel
     gcc
+    libva-devel
     gcc-c++
     glib2-devel
     git
@@ -191,6 +192,7 @@ if [[ -n $pacman ]]; then
     alsa-lib
     fontconfig
     glib2
+    libva
     wayland
     libgit2
     libxcb
@@ -222,6 +224,7 @@ if [[ -n $xbps ]]; then
     alsa-lib-devel
     fontconfig-devel
     glib-devel
+    libva-devel
     libxcb-devel
     libxkbcommon-devel
     libzstd-devel
@@ -249,6 +252,7 @@ if [[ -n $emerge ]]; then
     dev-util/cmake
     media-libs/alsa-lib
     media-libs/fontconfig
+    media-libs/libva
     media-libs/vulkan-loader
     x11-libs/libxcb
     x11-libs/libxkbcommon