summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2021-09-14 14:35:15 -0700
committer Colin Cross <ccross@android.com> 2021-09-17 22:54:50 +0000
commit073885cca8f9c52cc11629f9933ef97b6686bcfa (patch)
tree33a4a90eb66e0536fb037f3492cb6255d3c845a4
parent96d8f4f3cf969ba8ab61abfb813b47969fe73bcc (diff)
Fix art compiling against musl
Fix various issues when compling art against musl: Check for ANDROID_HOST_MUSL when defining strlcpy and sig*64. Remove error.h, its not used and doesn't exist in musl. Include time.h that was being included transitively in glibc but not in musl. Add the musl libc library name to the list. pthread_sigqueue takes a sigval, not a sigval_t. Bug: 190084016 Test: m USE_HOST_MUSL=true Change-Id: I2548ef0013234c42efded411c733450c19434855
-rw-r--r--libartbase/base/strlcpy.h2
-rw-r--r--openjdkjvmti/transform.cc1
-rw-r--r--runtime/exec_utils.h2
-rw-r--r--runtime/signal_set.h2
-rw-r--r--sigchainlib/sigchain.cc2
-rw-r--r--sigchainlib/sigchain_test.cc6
6 files changed, 10 insertions, 5 deletions
diff --git a/libartbase/base/strlcpy.h b/libartbase/base/strlcpy.h
index 98ea34b0a5..b5978c5ee8 100644
--- a/libartbase/base/strlcpy.h
+++ b/libartbase/base/strlcpy.h
@@ -26,7 +26,7 @@
// Bionic exposes this function, but the host glibc does not. Remove this shim when we compile
// against bionic on the host, also.
-#if !defined(__BIONIC__) && !defined(__APPLE__)
+#if !defined(__BIONIC__) && !defined(__APPLE__) && !defined(ANDROID_HOST_MUSL)
static inline size_t strlcpy(char* dst, const char* src, size_t size) {
// Extra-lazy implementation: this is only a host shim, and we don't have to call this often.
diff --git a/openjdkjvmti/transform.cc b/openjdkjvmti/transform.cc
index 011bd717b4..9c440ef367 100644
--- a/openjdkjvmti/transform.cc
+++ b/openjdkjvmti/transform.cc
@@ -29,7 +29,6 @@
* questions.
*/
-#include <error.h>
#include <stddef.h>
#include <sys/types.h>
diff --git a/runtime/exec_utils.h b/runtime/exec_utils.h
index e011c822ba..7ce0a9c20a 100644
--- a/runtime/exec_utils.h
+++ b/runtime/exec_utils.h
@@ -17,6 +17,8 @@
#ifndef ART_RUNTIME_EXEC_UTILS_H_
#define ART_RUNTIME_EXEC_UTILS_H_
+#include <time.h>
+
#include <string>
#include <vector>
diff --git a/runtime/signal_set.h b/runtime/signal_set.h
index 39e4c5f175..8e70a51cd1 100644
--- a/runtime/signal_set.h
+++ b/runtime/signal_set.h
@@ -21,7 +21,7 @@
#include <android-base/logging.h>
-#if defined(__GLIBC__)
+#if defined(__GLIBC__) || defined(ANDROID_HOST_MUSL)
#define sigset64_t sigset_t
#define sigemptyset64 sigemptyset
#define sigaddset64 sigaddset
diff --git a/sigchainlib/sigchain.cc b/sigchainlib/sigchain.cc
index 8aa47600bf..5bad8568f2 100644
--- a/sigchainlib/sigchain.cc
+++ b/sigchainlib/sigchain.cc
@@ -114,6 +114,8 @@ static void lookup_libc_symbol(T* output, T wrapper, const char* name) {
#error unsupported glibc version
#endif
constexpr const char* libc_name = "libc.so.6";
+#elif defined(ANDROID_HOST_MUSL)
+ constexpr const char* libc_name = "libc_musl.so";
#else
#error unsupported libc: not bionic or glibc?
#endif
diff --git a/sigchainlib/sigchain_test.cc b/sigchainlib/sigchain_test.cc
index 249fff1a5e..d879f5ac85 100644
--- a/sigchainlib/sigchain_test.cc
+++ b/sigchainlib/sigchain_test.cc
@@ -73,13 +73,13 @@ class SigchainTest : public ::testing::Test {
protected:
void RaiseHandled() {
- sigval_t value;
+ sigval value;
value.sival_ptr = &value;
pthread_sigqueue(pthread_self(), SIGSEGV, value);
}
void RaiseUnhandled() {
- sigval_t value;
+ sigval value;
value.sival_ptr = nullptr;
pthread_sigqueue(pthread_self(), SIGSEGV, value);
}
@@ -208,6 +208,8 @@ TEST_F(SigchainTest, EnsureFrontOfChain) {
constexpr char kLibcSoName[] = "libc.so";
#elif defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ == 6
constexpr char kLibcSoName[] = "libc.so.6";
+#elif defined(ANDROID_HOST_MUSL)
+ constexpr char kLibcSoName[] = "libc_musl.so";
#else
#error Unknown libc
#endif