From 33861082dc49d0c13dafee5bac712dcfa7ffaa56 Mon Sep 17 00:00:00 2001 From: Jeff Zhang Date: Sun, 1 Nov 2026 20:11:39 +0800 Subject: [PATCH] build: link inproc-av dependencies after the static engine archive (#105) GNU ld with --as-needed (Ubuntu default) drops shared libraries listed before libx11_engine.a, so --features inproc-av failed to link with undefined gbm_*, xcb_dri3_* and xcb_damage_* on Ubuntu (found on aarch64; Arch is unaffected). Co-authored-by: ferstar --- build.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index 1896b7c..d339b77 100644 --- a/build.rs +++ b/build.rs @@ -40,15 +40,20 @@ fn main() { println!("cargo:rerun-if-changed={f}"); } x11_build.include("vendor/ffnvcodec"); - // libva/libva-drm are dlopen'ed at runtime (like NVENC's libcuda); these are - // link-time-only deps of the DRI3/VAAPI engines and must stay out of default builds. + } + x11_build.compile("x11_engine"); + // libva/libva-drm are dlopen'ed at runtime (like NVENC's libcuda); these are + // link-time-only deps of the DRI3/VAAPI engines and must stay out of default builds. + if std::env::var_os("CARGO_FEATURE_INPROC_AV").is_some() { + // Emit them after the static C archive: GNU ld --as-needed would otherwise + // discard the shared libraries before libx11_engine.a references their symbols. println!("cargo:rustc-link-lib=gbm"); println!("cargo:rustc-link-lib=X11-xcb"); println!("cargo:rustc-link-lib=xcb"); println!("cargo:rustc-link-lib=xcb-dri3"); println!("cargo:rustc-link-lib=xcb-damage"); } - x11_build.compile("x11_engine"); + println!("cargo:rustc-link-lib=X11"); println!("cargo:rustc-link-lib=Xext");