step E.1 variant: cpp_link_stdlib c++_shared → c++_static
Some checks failed
Mirror to GitHub / mirror (push) Failing after 36s
Build Release Binaries / build-amd64 (push) Failing after 3m42s

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:
Siavash Sameni
2026-04-09 16:18:04 +04:00
parent 0d74366592
commit 191e8761d5

View File

@@ -37,21 +37,25 @@ fn build_android_native() {
.file("cpp/getauxval_fix.c") .file("cpp/getauxval_fix.c")
.compile("getauxval_fix"); .compile("getauxval_fix");
// ─── Step E.4: minimal C++ smoke file instead of full Oboe ───────────── // ─── Step E.1 with STATIC libc++ ───────────────────────────────────────
// The full Oboe compile (Step E, commit 4250f1b) triggered the // Every cpp_smoke variant (atomic-mutex-thread / atomic-only / empty
// __init_tcb+4 crash at launch — even without any FFI call from Rust. // function) crashed identically with c++_shared linkage — byte-
// Bisection jump: replace the 200+ Oboe source files with ONE tiny // identical crash offsets. The cpp code was dead-stripped from the
// cpp/cpp_smoke.cpp that uses the same libc++ features Oboe does // final .so in every case, so the only remaining delta was the
// (std::atomic, std::mutex, std::thread), still linked via // NEEDED entry for libc++_shared.so added by
// libc++_shared. If this crashes too, the trigger is just "any C++ // cargo:rustc-link-lib=c++_shared. Theory: that NEEDED entry (and
// link that references libc++ threads/mutexes". If it passes, Oboe // Android's dynamic linker running libc++_shared.so's init_array at
// itself (size, specific headers, static ctors) is the culprit. // 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"); println!("cargo:rerun-if-changed=cpp/cpp_smoke.cpp");
cc::Build::new() cc::Build::new()
.cpp(true) .cpp(true)
.std("c++17") .std("c++17")
// Shared libc++ — same linkage Oboe uses. .cpp_link_stdlib(Some("c++_static"))
.cpp_link_stdlib(Some("c++_shared"))
.file("cpp/cpp_smoke.cpp") .file("cpp/cpp_smoke.cpp")
.compile("wzp_cpp_smoke"); .compile("wzp_cpp_smoke");