-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ndk-sysroot-gcc-compact: fix various compile error
Closes #650
- Loading branch information
Showing
6 changed files
with
258 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
tur/ndk-sysroot-gcc-compact/0007-reland-macro-guard-for-is_trivially_destructible.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Since commit [1], libcxx assumed that gcc has fully supported `__has_builtin`, | ||
and dropped special-casing for GCC-provided builtins, but `__has_builtin` isn't | ||
supported by gcc-9. | ||
|
||
[1]: https://github.com/llvm/llvm-project/commit/2040fde9097ae7753531c9c58332a933cbaaa43c | ||
|
||
--- a/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_trivially_destructible.h | ||
+++ b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_trivially_destructible.h | ||
@@ -24,7 +24,7 @@ | ||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible | ||
: public integral_constant<bool, __is_trivially_destructible(_Tp)> {}; | ||
|
||
-#elif __has_builtin(__has_trivial_destructor) | ||
+#elif __has_builtin(__has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC) | ||
|
||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible | ||
: public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {}; |
41 changes: 41 additions & 0 deletions
41
tur/ndk-sysroot-gcc-compact/0008-workaround-for-no-builtin-is_same.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Since commit [1], libcxx assumes that gcc has builtin `__is_same`, but it | ||
doesn't exists in gcc-9. | ||
|
||
[1]: https://github.com/llvm/llvm-project/commit/5c0ea7488bc051453ad07135f32145465f502a84 | ||
|
||
--- a/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_same.h | ||
+++ b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_same.h | ||
@@ -18,6 +18,8 @@ | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
+#if __has_builtin(__is_same) | ||
+ | ||
template <class _Tp, class _Up> | ||
struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { }; | ||
|
||
@@ -39,6 +41,24 @@ | ||
template <class _Tp, class _Up> | ||
using _IsNotSame = _BoolConstant<!__is_same(_Tp, _Up)>; | ||
|
||
+#else | ||
+ | ||
+template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {}; | ||
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {}; | ||
+ | ||
+#if _LIBCPP_STD_VER > 14 | ||
+template <class _Tp, class _Up> | ||
+inline constexpr bool is_same_v = is_same<_Tp, _Up>::value; | ||
+#endif | ||
+ | ||
+template <class _Tp, class _Up> | ||
+using _IsSame = _BoolConstant<is_same<_Tp, _Up>::value>; | ||
+ | ||
+template <class _Tp, class _Up> | ||
+using _IsNotSame = _BoolConstant<!is_same<_Tp, _Up>::value>; | ||
+ | ||
+#endif // __has_builtin(__is_same) | ||
+ | ||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___TYPE_TRAITS_IS_SAME_H |
144 changes: 144 additions & 0 deletions
144
tur/ndk-sysroot-gcc-compact/0009-workaround-for-no-builtin-is_nothrow_assignable.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
Since commit [1], libcxx assumes that gcc has builtin `__is_nothrow_assignable` and | ||
`__is_nothrow_constructible`, but they don't exists in gcc-9 and gcc-10. | ||
|
||
[1]: https://github.com/llvm/llvm-project/commit/a13822b35d11cb6afa759fa0672fbc0b6ef295d0 | ||
|
||
--- a/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_nothrow_assignable.h | ||
+++ b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_nothrow_assignable.h | ||
@@ -18,13 +18,39 @@ | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
+#if __has_builtin(__is_nothrow_assignable) | ||
+ | ||
template <class _Tp, class _Arg> | ||
struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable | ||
: public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {}; | ||
|
||
+#else | ||
+ | ||
+template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable; | ||
+ | ||
+template <class _Tp, class _Arg> | ||
+struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg> | ||
+ : public false_type | ||
+{ | ||
+}; | ||
+ | ||
+template <class _Tp, class _Arg> | ||
+struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg> | ||
+ : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Arg>()) > | ||
+{ | ||
+}; | ||
+ | ||
+template <class _Tp, class _Arg> | ||
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable | ||
+ : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg> | ||
+{ | ||
+}; | ||
+ | ||
+#endif // __has_builtin(__is_nothrow_assignable) | ||
+ | ||
#if _LIBCPP_STD_VER > 14 | ||
template <class _Tp, class _Arg> | ||
-inline constexpr bool is_nothrow_assignable_v = __is_nothrow_assignable(_Tp, _Arg); | ||
+inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value; | ||
#endif | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
--- a/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_nothrow_copy_assignable.h | ||
+++ b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_nothrow_copy_assignable.h | ||
@@ -20,6 +20,8 @@ | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
+#if __has_builtin(__is_nothrow_assignable) | ||
+ | ||
template <class _Tp> | ||
struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable | ||
: public integral_constant< | ||
@@ -28,6 +30,14 @@ | ||
__add_lvalue_reference_t<_Tp>, | ||
__add_lvalue_reference_t<typename add_const<_Tp>::type>)> {}; | ||
|
||
+#else | ||
+ | ||
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable | ||
+ : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, | ||
+ typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; | ||
+ | ||
+#endif | ||
+ | ||
#if _LIBCPP_STD_VER > 14 | ||
template <class _Tp> | ||
inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value; | ||
--- a/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_nothrow_default_constructible.h | ||
+++ b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_nothrow_default_constructible.h | ||
@@ -11,6 +11,7 @@ | ||
|
||
#include <__config> | ||
#include <__type_traits/integral_constant.h> | ||
+#include <__type_traits/is_nothrow_constructible.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
@@ -18,13 +19,23 @@ | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
+#if __has_builtin(__is_nothrow_constructible) | ||
+ | ||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible | ||
: public integral_constant<bool, __is_nothrow_constructible(_Tp)> | ||
{}; | ||
|
||
+#else | ||
+ | ||
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible | ||
+ : public is_nothrow_constructible<_Tp> | ||
+ {}; | ||
+ | ||
+#endif | ||
+ | ||
#if _LIBCPP_STD_VER > 14 | ||
template <class _Tp> | ||
-inline constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(_Tp); | ||
+inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value; | ||
#endif | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
--- a/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_nothrow_move_assignable.h | ||
+++ b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_nothrow_move_assignable.h | ||
@@ -13,6 +13,7 @@ | ||
#include <__type_traits/add_lvalue_reference.h> | ||
#include <__type_traits/add_rvalue_reference.h> | ||
#include <__type_traits/integral_constant.h> | ||
+#include <__type_traits/is_nothrow_assignable.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
@@ -20,6 +21,8 @@ | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
+#if __has_builtin(__is_nothrow_assignable) | ||
+ | ||
template <class _Tp> | ||
struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable | ||
: public integral_constant< | ||
@@ -27,6 +30,15 @@ | ||
__is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> { | ||
}; | ||
|
||
+#else | ||
+ | ||
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable | ||
+ : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, | ||
+ typename add_rvalue_reference<_Tp>::type> | ||
+ {}; | ||
+ | ||
+#endif | ||
+ | ||
#if _LIBCPP_STD_VER > 14 | ||
template <class _Tp> | ||
inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value; |
21 changes: 21 additions & 0 deletions
21
tur/ndk-sysroot-gcc-compact/0010-workaround-for-adl_only-namespace-in-system_error.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Since commit [1], libcxx implements LWG 3629 for `system_error` header, | ||
but this breaks compile on gcc-9, gcc-10 and gcc-11. | ||
|
||
[1]: https://github.com/llvm/llvm-project/commit/ef843c8271027b89419d07ffc2aaa3abf91438ef | ||
|
||
--- a/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/system_error | ||
+++ b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/system_error | ||
@@ -259,8 +259,13 @@ | ||
namespace __adl_only { | ||
// Those cause ADL to trigger but they are not viable candidates, | ||
// so they are never actually selected. | ||
+#if defined(__GNUC__) && __GNUC__ < 12 | ||
+ void make_error_condition(); | ||
+ void make_error_code(); | ||
+#else | ||
void make_error_condition() = delete; | ||
void make_error_code() = delete; | ||
+#endif | ||
} // namespace __adl_only | ||
|
||
class _LIBCPP_TYPE_VIS error_condition |
34 changes: 34 additions & 0 deletions
34
...dk-sysroot-gcc-compact/0011-workaround-for-has_specialization-in-segmented_iterator.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
GCC doesn't have proper support for CWG 1315 until commit [2], which is landed in GCC | ||
12. I don't want to cherry-pick this commit for every GCC toolchain, so I implement | ||
`has_specialization` with SFINAE. Hopefully there aren't many bugs... | ||
|
||
[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96555 | ||
[2]: https://github.com/gcc-mirror/gcc/commit/9b94785dedb08b006419bec1a402614d9241317a | ||
|
||
--- a/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__iterator/segmented_iterator.h | ||
+++ b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__iterator/segmented_iterator.h | ||
@@ -65,12 +65,24 @@ | ||
}; | ||
*/ | ||
|
||
+#if defined(__GNUC__) && __GNUC__ < 12 | ||
+ | ||
+template <class _Tp, class = void> | ||
+struct __has_specialization : false_type {}; | ||
+ | ||
+template <class _Tp> | ||
+struct __has_specialization<_Tp, __void_t<decltype(_Tp())>> : true_type {}; | ||
+ | ||
+#else | ||
+ | ||
template <class _Tp, size_t = 0> | ||
struct __has_specialization : false_type {}; | ||
|
||
template <class _Tp> | ||
struct __has_specialization<_Tp, sizeof(_Tp) * 0> : true_type {}; | ||
|
||
+#endif | ||
+ | ||
template <class _Iterator> | ||
using __is_segmented_iterator = __has_specialization<__segmented_iterator_traits<_Iterator> >; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters