android: Make libbacktrace optional again

For the same reason why we used to have USE_LIBBACKTRACE with the old
Android makefiles, allow to build Mesa without linking to it.

In recent VNDK versions, libbacktrace isn't available.

When building without linking libbacktrace, for some reason some symbols
related to C++ exception handling are exposed. Allow them in the symbols
check script.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Helen Koike <helen.koike@collabora.com>
Reviewed-by: Sergi Blanch Torné <sergi.blanch.torne@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20019>
This commit is contained in:
Tomeu Vizoso 2022-11-15 09:48:02 +01:00 committed by Helen Koike
parent 0e286d0dbc
commit b1bd6aa21a
5 changed files with 85 additions and 4 deletions

View File

@ -13,6 +13,34 @@ PLATFORM_SYMBOLS = [
'__cxa_guard_abort',
'__cxa_guard_acquire',
'__cxa_guard_release',
'__cxa_allocate_dependent_exception',
'__cxa_allocate_exception',
'__cxa_begin_catch',
'__cxa_call_unexpected',
'__cxa_current_exception_type',
'__cxa_current_primary_exception',
'__cxa_decrement_exception_refcount',
'__cxa_deleted_virtual',
'__cxa_demangle',
'__cxa_end_catch',
'__cxa_free_dependent_exception',
'__cxa_free_exception',
'__cxa_get_exception_ptr',
'__cxa_get_globals',
'__cxa_get_globals_fast',
'__cxa_increment_exception_refcount',
'__cxa_new_handler',
'__cxa_pure_virtual',
'__cxa_rethrow',
'__cxa_rethrow_primary_exception',
'__cxa_terminate_handler',
'__cxa_throw',
'__cxa_uncaught_exception',
'__cxa_uncaught_exceptions',
'__cxa_unexpected_handler',
'__dynamic_cast',
'__emutls_get_address',
'__gxx_personality_v0',
'__end__',
'__odr_asan._glapi_Context',
'__odr_asan._glapi_Dispatch',

View File

@ -823,6 +823,19 @@ if with_android_stub and not with_platform_android
error('`-D android-stub=true` makes no sense without `-D platforms=android`')
endif
if get_option('android-libbacktrace') == 'auto'
with_libbacktrace = with_platform_android
else
with_libbacktrace = get_option('android-libbacktrace') == 'true'
if with_libbacktrace and not with_platform_android
error('`-D android-libbacktrace=true` makes no sense without `-D platforms=android`')
endif
endif
if with_libbacktrace
cpp_args += '-DWITH_LIBBACKTRACE'
endif
if with_platform_android
dep_android_mapper4 = null_dep
if not with_android_stub
@ -830,8 +843,10 @@ if with_platform_android
dependency('cutils'),
dependency('hardware'),
dependency('sync'),
dependency('backtrace')
]
if with_libbacktrace
dep_android += dependency('backtrace')
endif
if get_option('platform-sdk-version') >= 26
dep_android += dependency('nativewindow')
endif

View File

@ -43,7 +43,13 @@ option(
value : false,
description : 'Build against android-stub',
)
option(
'android-libbacktrace',
type : 'combo',
value : 'auto',
choices : ['auto', 'true', 'false'],
description : 'Use Android\'s libbacktrace',
)
option(
'dri3',
type : 'feature',

View File

@ -1,7 +1,12 @@
if with_android_stub
stub_libs = []
lib_names = ['cutils', 'hardware', 'log', 'nativewindow', 'sync']
foreach lib : ['backtrace', 'cutils', 'hardware', 'log', 'nativewindow', 'sync']
if with_libbacktrace
lib_names += ['backtrace']
endif
foreach lib : lib_names
stub_libs += shared_library(
lib,
files(lib + '_stub.cpp'),

View File

@ -21,11 +21,14 @@
* IN THE SOFTWARE.
*/
#include "u_debug_stack.h"
#if WITH_LIBBACKTRACE
#include <backtrace/Backtrace.h>
#include "util/simple_mtx.h"
#include "util/u_debug.h"
#include "u_debug_stack.h"
#include "util/hash_table.h"
#include "util/u_thread.h"
@ -120,3 +123,27 @@ debug_backtrace_print(FILE *f,
backtrace[i].off);
}
}
#else
void
debug_backtrace_capture(debug_stack_frame *backtrace,
unsigned start_frame,
unsigned nr_frames)
{
}
void
debug_backtrace_dump(const debug_stack_frame *backtrace,
unsigned nr_frames)
{
}
void
debug_backtrace_print(FILE *f,
const debug_stack_frame *backtrace,
unsigned nr_frames)
{
}
#endif // WITH_LIBBACKTRACE