step E.1 variant: cpp_link_stdlib c++_shared → c++_static
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user