Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

fix(build): stop bundled sqlite symbols from preempting system libsqlite3

Yahya Zekry5124971de356
diff --git a/src-tauri/build.rs b/src-tauri/build.rs
index 72f8fb21..c5b693b1 100644
--- a/src-tauri/build.rs
+++ b/src-tauri/build.rs
@@ -1,4 +1,21 @@
fn main() {
+ // The bundled SQLite (libsqlite3-sys "bundled") defines sqlite3_* symbols
+ // in this executable. When a linked shared library (webkit2gtk and its
+ // deps reference sqlite3_open_v2, sqlite3_prepare_v2, ...) has an
+ // undefined reference to one of them, ld auto-exports the definition so
+ // the shared lib binds to it at runtime. Those exports then preempt
+ // sqlite3 usage process-wide: libsqlite3.so.0's own sqlite3_initialize
+ // is among the preempted calls, so the system library's global config is
+ // never initialized while some of its internal calls execute in the
+ // bundled copy. Any plugin using the system libsqlite3 (e.g. the
+ // Telegram plugin's SqliteSession) then segfaults on its first
+ // sqlite3_mutex_enter, which tail-jumps through the never-populated
+ // mutex-methods table. --exclude-libs keeps static-archive symbols
+ // local: shared libs bind to the real libsqlite3.so.0 and the bundled
+ // copy stays private to the executable.
+ if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("linux") {
+ println!("cargo:rustc-link-arg=-Wl,--exclude-libs,ALL");
+ }
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("macos") {
println!("cargo:rustc-link-arg=-ObjC");
println!("cargo:rustc-link-arg=-Wl,-rpath,/usr/lib/swift");