From efd9112095b216b5fd20523147650b0f4147e62f Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 15 Mar 2016 05:02:20 +0000 Subject: libcxx,libcxxabi: Fix build on musl Signed-off-by: Khem Raj --- ...__-to-differentiate-glibc-like-libc-on-li.patch | 39 +++++++++++++++ ...01-replace-strtoll_l-with-strtoll-on-musl.patch | 55 +++++++++++++++++++++ .../0001-use-constexpr-when-using-glibc.patch | 56 ++++++++++++++++++++++ recipes-devtools/clang/libcxx_git.bb | 4 ++ recipes-devtools/clang/libcxxabi_git.bb | 2 + 5 files changed, 156 insertions(+) create mode 100644 recipes-devtools/clang/files/0001-Use-__GLIBC__-to-differentiate-glibc-like-libc-on-li.patch create mode 100644 recipes-devtools/clang/files/0001-replace-strtoll_l-with-strtoll-on-musl.patch create mode 100644 recipes-devtools/clang/files/0001-use-constexpr-when-using-glibc.patch diff --git a/recipes-devtools/clang/files/0001-Use-__GLIBC__-to-differentiate-glibc-like-libc-on-li.patch b/recipes-devtools/clang/files/0001-Use-__GLIBC__-to-differentiate-glibc-like-libc-on-li.patch new file mode 100644 index 0000000..dc06ddd --- /dev/null +++ b/recipes-devtools/clang/files/0001-Use-__GLIBC__-to-differentiate-glibc-like-libc-on-li.patch @@ -0,0 +1,39 @@ +From f85abde580d2ba399bfc7538a28f7b6f96912bc6 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 15 Mar 2016 03:10:42 +0000 +Subject: [PATCH] Use __GLIBC__ to differentiate glibc-like libc on linux + +glibc/uclibc define __GLIBC_PREREQ but musl does not therefore we need +to check if its on glibc system before using it + +Signed-off-by: Khem Raj +--- + include/__config | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/include/__config b/include/__config +index db5a832..0859b5f 100644 +--- a/include/__config ++++ b/include/__config +@@ -392,15 +392,15 @@ typedef __char32_t char32_t; + #elif defined(__ANDROID__) + #define _LIBCPP_HAS_QUICK_EXIT + #elif defined(__linux__) +-#if !defined(_LIBCPP_HAS_MUSL_LIBC) ++#if defined(__GLIBC__) + # include +-#if __GLIBC_PREREQ(2, 15) ++#if __GLIBC_PREREQ(2, 15) + #define _LIBCPP_HAS_QUICK_EXIT + #endif + #if __GLIBC_PREREQ(2, 17) + #define _LIBCPP_HAS_C11_FEATURES + #endif +-#else // defined(_LIBCPP_HAS_MUSL_LIBC) ++#else // defined(__GLIBC__) + #define _LIBCPP_HAS_QUICK_EXIT + #define _LIBCPP_HAS_C11_FEATURES + #endif +-- +1.9.1 + diff --git a/recipes-devtools/clang/files/0001-replace-strtoll_l-with-strtoll-on-musl.patch b/recipes-devtools/clang/files/0001-replace-strtoll_l-with-strtoll-on-musl.patch new file mode 100644 index 0000000..6e8404d --- /dev/null +++ b/recipes-devtools/clang/files/0001-replace-strtoll_l-with-strtoll-on-musl.patch @@ -0,0 +1,55 @@ +From 103e1e99622318a6183c4576d372cc8126c6778d Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 15 Mar 2016 04:20:10 +0000 +Subject: [PATCH] replace strtoll_l with strtoll on musl + +Fixes errors like +libcxx/include/locale:874:26: error: use of undeclared identifier 'strtoll_l' + +Signed-off-by: Khem Raj +--- + include/locale | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/include/locale b/include/locale +index 84cb5a5..9072722 100644 +--- a/include/locale ++++ b/include/locale +@@ -10,7 +10,6 @@ + + #ifndef _LIBCPP_LOCALE + #define _LIBCPP_LOCALE +- + /* + locale synopsis + +@@ -871,7 +870,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end, + typename remove_reference::type __save_errno = errno; + errno = 0; + char *__p2; +- long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); ++ long long __ll = strtoll(__a, &__p2, __base); + typename remove_reference::type __current_errno = errno; + if (__current_errno == 0) + errno = __save_errno; +@@ -911,7 +910,7 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end, + typename remove_reference::type __save_errno = errno; + errno = 0; + char *__p2; +- unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); ++ unsigned long long __ll = strtoull(__a, &__p2, __base); + typename remove_reference::type __current_errno = errno; + if (__current_errno == 0) + errno = __save_errno; +@@ -941,7 +940,7 @@ __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err) + typename remove_reference::type __save_errno = errno; + errno = 0; + char *__p2; +- long double __ld = strtold_l(__a, &__p2, _LIBCPP_GET_C_LOCALE); ++ long double __ld = strtold(__a, &__p2); + typename remove_reference::type __current_errno = errno; + if (__current_errno == 0) + errno = __save_errno; +-- +1.9.1 + diff --git a/recipes-devtools/clang/files/0001-use-constexpr-when-using-glibc.patch b/recipes-devtools/clang/files/0001-use-constexpr-when-using-glibc.patch new file mode 100644 index 0000000..f66de8f --- /dev/null +++ b/recipes-devtools/clang/files/0001-use-constexpr-when-using-glibc.patch @@ -0,0 +1,56 @@ +From 21ddd574f6e9b321614d39a7765f1ad98aa09f54 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 15 Mar 2016 04:56:27 +0000 +Subject: [PATCH] use constexpr when using glibc + +POSIX does not permit using PTHREAD_COND_INITIALIZER except for static +initialization, and certainly does not permit using it as a value + +also POSIX does not specify the type of the object (it's opaque) so if +there are any types for which their code would be invalid C++, then their +code is invalid + +Signed-off-by: Khem Raj +--- + include/__mutex_base | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/include/__mutex_base b/include/__mutex_base +index b019b47..10ad9f2 100644 +--- a/include/__mutex_base ++++ b/include/__mutex_base +@@ -33,7 +33,10 @@ class _LIBCPP_TYPE_VIS mutex + public: + _LIBCPP_INLINE_VISIBILITY + #ifndef _LIBCPP_HAS_NO_CONSTEXPR +- constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {} ++#ifdef __GLIBC__ ++ constexpr ++#endif ++ mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {} + #else + mutex() _NOEXCEPT {__m_ = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;} + #endif +@@ -63,7 +66,6 @@ extern const try_to_lock_t try_to_lock; + extern const adopt_lock_t adopt_lock; + + #else +- + constexpr defer_lock_t defer_lock = defer_lock_t(); + constexpr try_to_lock_t try_to_lock = try_to_lock_t(); + constexpr adopt_lock_t adopt_lock = adopt_lock_t(); +@@ -272,7 +274,10 @@ class _LIBCPP_TYPE_VIS condition_variable + public: + _LIBCPP_INLINE_VISIBILITY + #ifndef _LIBCPP_HAS_NO_CONSTEXPR +- constexpr condition_variable() : __cv_(PTHREAD_COND_INITIALIZER) {} ++#ifdef __GLIBC__ ++ constexpr ++#endif ++ condition_variable() : __cv_(PTHREAD_COND_INITIALIZER) {} + #else + condition_variable() {__cv_ = (pthread_cond_t)PTHREAD_COND_INITIALIZER;} + #endif +-- +1.9.1 + diff --git a/recipes-devtools/clang/libcxx_git.bb b/recipes-devtools/clang/libcxx_git.bb index e4c124e..ba6ecc2 100644 --- a/recipes-devtools/clang/libcxx_git.bb +++ b/recipes-devtools/clang/libcxx_git.bb @@ -23,6 +23,10 @@ SRC_URI = "\ ${LLVM_GIT}/libcxx.git;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH};name=libcxx;destsuffix=git/projects/libcxx \ ${LLVM_GIT}/libcxxabi.git;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH};name=libcxxabi;destsuffix=git/projects/libcxxabi \ " +SRC_URI += "file://0001-Use-__GLIBC__-to-differentiate-glibc-like-libc-on-li.patch \ + file://0001-use-constexpr-when-using-glibc.patch \ +" +SRC_URI_append_libc-musl = " file://0001-replace-strtoll_l-with-strtoll-on-musl.patch " SRCREV_FORMAT = "llvm_libcxx_libcxxabi" diff --git a/recipes-devtools/clang/libcxxabi_git.bb b/recipes-devtools/clang/libcxxabi_git.bb index 04c5bdf..2cb2408 100644 --- a/recipes-devtools/clang/libcxxabi_git.bb +++ b/recipes-devtools/clang/libcxxabi_git.bb @@ -23,6 +23,8 @@ SRC_URI = "\ ${LLVM_GIT}/libcxxabi.git;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH};name=libcxxabi;destsuffix=git/projects/libcxxabi \ " +SRC_URI += "file://0001-Use-__GLIBC__-to-differentiate-glibc-like-libc-on-li.patch;patchdir=../libcxx" + SRCREV_FORMAT = "llvm_libcxx_libcxxabi" S = "${WORKDIR}/git/projects/libcxxabi" -- cgit v1.2.3-54-g00ecf