From 191e8761d56070fd86e8cc414d1a14ac1eb42892 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Thu, 9 Apr 2026 16:18:04 +0400 Subject: [PATCH] =?UTF-8?q?step=20E.1=20variant:=20cpp=5Flink=5Fstdlib=20c?= =?UTF-8?q?++=5Fshared=20=E2=86=92=20c++=5Fstatic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every E.x variant crashed identically when linked with c++_shared, even with a 3-line cpp file that's dead-stripped from the final .so. The crash offsets are byte-identical across E.1, E.2, E.4, and the original full-Oboe Step E. That points at a non-code link-time delta: the `cargo:rustc-link-lib=c++_shared` directive that adds a NEEDED entry for libc++_shared.so to the .so's dynamic table. Swap to c++_static — bundles libc++ directly into our .so so the NEEDED entry disappears. If this launches cleanly, we've conclusively proven the NEEDED libc++_shared.so is the root cause and we have a workable linkage for any C++ we want to add to the Tauri Android build (including the eventual Oboe audio backend). Co-Authored-By: Claude Opus 4.6 (1M context) --- desktop/src-tauri/build.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/desktop/src-tauri/build.rs b/desktop/src-tauri/build.rs index 129a3f4..54faaf2 100644 --- a/desktop/src-tauri/build.rs +++ b/desktop/src-tauri/build.rs @@ -37,21 +37,25 @@ fn build_android_native() { .file("cpp/getauxval_fix.c") .compile("getauxval_fix"); - // ─── Step E.4: minimal C++ smoke file instead of full Oboe ───────────── - // The full Oboe compile (Step E, commit 4250f1b) triggered the - // __init_tcb+4 crash at launch — even without any FFI call from Rust. - // Bisection jump: replace the 200+ Oboe source files with ONE tiny - // cpp/cpp_smoke.cpp that uses the same libc++ features Oboe does - // (std::atomic, std::mutex, std::thread), still linked via - // libc++_shared. If this crashes too, the trigger is just "any C++ - // link that references libc++ threads/mutexes". If it passes, Oboe - // itself (size, specific headers, static ctors) is the culprit. + // ─── Step E.1 with STATIC libc++ ─────────────────────────────────────── + // Every cpp_smoke variant (atomic-mutex-thread / atomic-only / empty + // function) crashed identically with c++_shared linkage — byte- + // identical crash offsets. The cpp code was dead-stripped from the + // final .so in every case, so the only remaining delta was the + // NEEDED entry for libc++_shared.so added by + // cargo:rustc-link-lib=c++_shared. Theory: that NEEDED entry (and + // Android's dynamic linker running libc++_shared.so's init_array at + // dlopen time) is the trigger. + // + // Test: swap c++_shared → c++_static. Bundles libc++ code directly + // into our .so, drops the NEEDED entry. If the app launches, we've + // proven the NEEDED libc++_shared.so is the trigger and have a + // working linkage for adding C++ to Tauri Android cdylibs. println!("cargo:rerun-if-changed=cpp/cpp_smoke.cpp"); cc::Build::new() .cpp(true) .std("c++17") - // Shared libc++ — same linkage Oboe uses. - .cpp_link_stdlib(Some("c++_shared")) + .cpp_link_stdlib(Some("c++_static")) .file("cpp/cpp_smoke.cpp") .compile("wzp_cpp_smoke");