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
diff --git a/libartbase/base/strlcpy.h b/libartbase/base/strlcpy.h
index 98ea34b..b5978c5 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 011bd71..9c440ef 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 e011c82..7ce0a9c 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 39e4c5f..8e70a51 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 8aa4760..5bad856 100644
--- a/sigchainlib/sigchain.cc
+++ b/sigchainlib/sigchain.cc
@@ -114,6 +114,8 @@
#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 249fff1..d879f5a 100644
--- a/sigchainlib/sigchain_test.cc
+++ b/sigchainlib/sigchain_test.cc
@@ -73,13 +73,13 @@
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 @@
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