From 25b36d900acb0d3d923bd0b99a6d8443b4616c73 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 21 Sep 2020 14:27:24 -0700 Subject: [PATCH] mesa: Make the android_stub be a set of non-installed shared libraries. Previously, we included the stubs in our driver binaries, so they didn't call the actual system libraries for these functions. This was enough to build-test the Android code in CI without even the NDK. To make NDK-built Mesa drivers useful, we need to link against these system libraries that aren't present in the NDK. Split the symbols to separate non-installed shared libraries and link against those, so that when you drop the resulting .so in your /vendor/lib64/hw/, it just works out. Reviewed-by: Kristian H. Kristensen Part-of: --- src/android_stub/README.md | 5 +++ src/android_stub/android_stub.cpp | 54 ----------------------------- src/android_stub/backtrace_stub.cpp | 14 ++++++++ src/android_stub/cutils_stub.cpp | 10 ++++++ src/android_stub/hardware_stub.cpp | 10 ++++++ src/android_stub/log_stub.cpp | 15 ++++++++ src/android_stub/meson.build | 18 ++++++---- src/android_stub/sync_stub.cpp | 20 +++++++++++ 8 files changed, 85 insertions(+), 61 deletions(-) create mode 100644 src/android_stub/README.md delete mode 100644 src/android_stub/android_stub.cpp create mode 100644 src/android_stub/backtrace_stub.cpp create mode 100644 src/android_stub/cutils_stub.cpp create mode 100644 src/android_stub/hardware_stub.cpp create mode 100644 src/android_stub/log_stub.cpp create mode 100644 src/android_stub/sync_stub.cpp diff --git a/src/android_stub/README.md b/src/android_stub/README.md new file mode 100644 index 00000000000..9c85e75c7a3 --- /dev/null +++ b/src/android_stub/README.md @@ -0,0 +1,5 @@ +The Android NDK doesn't come with enough of the platform libraries we +need to build Mesa drivers out of tree, so android_stub has stub +versions of those library that aren't installed which we link against, +relying on the real libraries to be present when the Mesa driver is +deployed. diff --git a/src/android_stub/android_stub.cpp b/src/android_stub/android_stub.cpp deleted file mode 100644 index f31e3cc0c37..00000000000 --- a/src/android_stub/android_stub.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include -#include - -extern "C" { - -int property_get(const char* key, char* value, const char* default_value) -{ - return 0; -} - -/* timeout in msecs */ -int sync_wait(int fd, int timeout) -{ - return 0; -} - -/* From hardware/hardware.h */ - -int hw_get_module(const char *id, const struct hw_module_t **module) -{ - return 0; -} - -/* From android/log.h */ - -int __android_log_print(int prio, const char* tag, const char* fmt, ...) -{ - return 0; -} - -int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap) -{ - return 0; -} - -} - -/* From backtrace/Backtrace.h */ - -Backtrace* -Backtrace::Create(pid_t pid, pid_t tid, BacktraceMap* map) -{ - return NULL; -} - -std::string -backtrace_map_t::Name() const -{ - return ""; -} - diff --git a/src/android_stub/backtrace_stub.cpp b/src/android_stub/backtrace_stub.cpp new file mode 100644 index 00000000000..1b7f7efd644 --- /dev/null +++ b/src/android_stub/backtrace_stub.cpp @@ -0,0 +1,14 @@ +#include + +Backtrace* +Backtrace::Create(pid_t pid, pid_t tid, BacktraceMap* map) +{ + return NULL; +} + +std::string +backtrace_map_t::Name() const +{ + return ""; +} + diff --git a/src/android_stub/cutils_stub.cpp b/src/android_stub/cutils_stub.cpp new file mode 100644 index 00000000000..b660ec9d6d7 --- /dev/null +++ b/src/android_stub/cutils_stub.cpp @@ -0,0 +1,10 @@ +#include + +extern "C" { + +int property_get(const char* key, char* value, const char* default_value) +{ + return 0; +} + +} diff --git a/src/android_stub/hardware_stub.cpp b/src/android_stub/hardware_stub.cpp new file mode 100644 index 00000000000..4cb973fd2ac --- /dev/null +++ b/src/android_stub/hardware_stub.cpp @@ -0,0 +1,10 @@ +#include + +extern "C" { + +int hw_get_module(const char *id, const struct hw_module_t **module) +{ + return 0; +} + +} diff --git a/src/android_stub/log_stub.cpp b/src/android_stub/log_stub.cpp new file mode 100644 index 00000000000..29ba87b3748 --- /dev/null +++ b/src/android_stub/log_stub.cpp @@ -0,0 +1,15 @@ +#include + +extern "C" { + +int __android_log_print(int prio, const char* tag, const char* fmt, ...) +{ + return 0; +} + +int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap) +{ + return 0; +} + +} diff --git a/src/android_stub/meson.build b/src/android_stub/meson.build index ad9abf50e03..a4dc349d28f 100644 --- a/src/android_stub/meson.build +++ b/src/android_stub/meson.build @@ -1,12 +1,16 @@ if with_android_stub - _libmesa_android_stub = static_library( - 'mesa_android_stub', - files('android_stub.cpp'), - include_directories : inc_include, - gnu_symbol_visibility : 'hidden', - ) + stub_libs = [] + + foreach lib : ['backtrace', 'cutils', 'hardware', 'log', 'sync'] + stub_libs += shared_library( + lib, + files(lib + '_stub.cpp'), + include_directories : inc_include, + install : false, + ) + endforeach dep_android = declare_dependency( - link_with : _libmesa_android_stub, + link_with : stub_libs, ) endif diff --git a/src/android_stub/sync_stub.cpp b/src/android_stub/sync_stub.cpp new file mode 100644 index 00000000000..963d928a47f --- /dev/null +++ b/src/android_stub/sync_stub.cpp @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include + +extern "C" { + +/* timeout in msecs */ +int sync_wait(int fd, int timeout) +{ + return 0; +} + +int sync_merge(const char *name, int fd, int fd2) +{ + return 0; +} + +}