@@ -16,7 +16,20 @@ set(CMAKE_C_FLAGS_RELEASE "-O3 -flto=thin -ffast-math -ffunction-sections -fda
1616# -Wl,-z,max-page-size=16384: align ELF LOAD segments to 16 KB for Android 15+
1717# devices with 16 KB page sizes. Without this, the .so will fail to load on
1818# such devices. NDK r28+ supports this flag.
19- set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "-Wl,--gc-sections -Wl,-z,max-page-size=16384 -s" )
19+ #
20+ # IMPORTANT: do NOT pass `-s` (or `-Wl,-s`) here. Stripping the native library
21+ # removes the symbol table, which means Android tombstones — and crash-report
22+ # tools like Crash Log Viewer that read them — print only `pc=<hex>` with no
23+ # function name. That makes the SDLThread / audio-thread SIGSEGVs we have been
24+ # chasing essentially unfixable from a tombstone alone, because we cannot tell
25+ # whether the null indirect call originated in our `OboeBridge::onAudioReady`,
26+ # in Oboe itself, in libvulkan, or in the renderer. Keeping symbols costs only
27+ # a few hundred KB in the on-device .so (and zero APK download size when LZ4
28+ # assembly compression is on, since the .so is also compressed), and it is the
29+ # single highest-leverage change we can make for diagnosing real-device crashes.
30+ # `-Wl,--gc-sections` still removes unreferenced sections; only the symbol
31+ # *names* are retained.
32+ set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "-Wl,--gc-sections -Wl,-z,max-page-size=16384" )
2033
2134# Disable Oboe's flowgraph module — we don't use any audio processing/conversion
2235# features (our bridge outputs silence for latency measurement only).
@@ -64,10 +77,15 @@ set(OBOE_LIB oboe)
6477find_library (vulkan-lib vulkan REQUIRED )
6578find_library (log -lib log REQUIRED )
6679find_library (android -lib android REQUIRED )
80+ # `dl` is needed for dladdr() in crash_handler.cpp (symbol resolution from PCs).
81+ # It is normally auto-linked on Android, but make the dependency explicit so we
82+ # don't accidentally lose dladdr if the toolchain default ever changes.
83+ find_library (dl-lib dl REQUIRED )
6784
6885add_library (osu_native SHARED
6986 oboe_bridge.cpp
7087 vulkan_bridge.cpp
88+ crash_handler.cpp
7189)
7290
7391
@@ -76,4 +94,5 @@ target_link_libraries(osu_native
7694 ${vulkan-lib}
7795 ${log-lib}
7896 ${android -lib}
97+ ${dl-lib}
7998)
0 commit comments