diff --git a/tur/ndk-sysroot-gcc-compact/0007-reland-macro-guard-for-is_trivially_destructible.patch b/tur/ndk-sysroot-gcc-compact/0007-reland-macro-guard-for-is_trivially_destructible.patch new file mode 100644 index 000000000..c56232a15 --- /dev/null +++ b/tur/ndk-sysroot-gcc-compact/0007-reland-macro-guard-for-is_trivially_destructible.patch @@ -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 struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible + : public integral_constant {}; + +-#elif __has_builtin(__has_trivial_destructor) ++#elif __has_builtin(__has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC) + + template struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible + : public integral_constant::value && __has_trivial_destructor(_Tp)> {}; diff --git a/tur/ndk-sysroot-gcc-compact/0008-workaround-for-no-builtin-is_same.patch b/tur/ndk-sysroot-gcc-compact/0008-workaround-for-no-builtin-is_same.patch new file mode 100644 index 000000000..1f9a2ca95 --- /dev/null +++ b/tur/ndk-sysroot-gcc-compact/0008-workaround-for-no-builtin-is_same.patch @@ -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 + struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { }; + +@@ -39,6 +41,24 @@ + template + using _IsNotSame = _BoolConstant; + ++#else ++ ++template struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {}; ++template struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {}; ++ ++#if _LIBCPP_STD_VER > 14 ++template ++inline constexpr bool is_same_v = is_same<_Tp, _Up>::value; ++#endif ++ ++template ++using _IsSame = _BoolConstant::value>; ++ ++template ++using _IsNotSame = _BoolConstant::value>; ++ ++#endif // __has_builtin(__is_same) ++ + _LIBCPP_END_NAMESPACE_STD + + #endif // _LIBCPP___TYPE_TRAITS_IS_SAME_H diff --git a/tur/ndk-sysroot-gcc-compact/0009-workaround-for-no-builtin-is_nothrow_assignable.patch b/tur/ndk-sysroot-gcc-compact/0009-workaround-for-no-builtin-is_nothrow_assignable.patch new file mode 100644 index 000000000..e103d0aaa --- /dev/null +++ b/tur/ndk-sysroot-gcc-compact/0009-workaround-for-no-builtin-is_nothrow_assignable.patch @@ -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 + struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable + : public integral_constant {}; + ++#else ++ ++template struct __libcpp_is_nothrow_assignable; ++ ++template ++struct __libcpp_is_nothrow_assignable ++ : public false_type ++{ ++}; ++ ++template ++struct __libcpp_is_nothrow_assignable ++ : public integral_constant() = declval<_Arg>()) > ++{ ++}; ++ ++template ++struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable ++ : public __libcpp_is_nothrow_assignable::value, _Tp, _Arg> ++{ ++}; ++ ++#endif // __has_builtin(__is_nothrow_assignable) ++ + #if _LIBCPP_STD_VER > 14 + template +-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 + struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable + : public integral_constant< +@@ -28,6 +30,14 @@ + __add_lvalue_reference_t<_Tp>, + __add_lvalue_reference_t::type>)> {}; + ++#else ++ ++template struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable ++ : public is_nothrow_assignable::type, ++ typename add_lvalue_reference::type>::type> {}; ++ ++#endif ++ + #if _LIBCPP_STD_VER > 14 + template + 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 struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible + : public integral_constant + {}; + ++#else ++ ++template struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible ++ : public is_nothrow_constructible<_Tp> ++ {}; ++ ++#endif ++ + #if _LIBCPP_STD_VER > 14 + template +-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 + 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 struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable ++ : public is_nothrow_assignable::type, ++ typename add_rvalue_reference<_Tp>::type> ++ {}; ++ ++#endif ++ + #if _LIBCPP_STD_VER > 14 + template + inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value; diff --git a/tur/ndk-sysroot-gcc-compact/0010-workaround-for-adl_only-namespace-in-system_error.patch b/tur/ndk-sysroot-gcc-compact/0010-workaround-for-adl_only-namespace-in-system_error.patch new file mode 100644 index 000000000..b4a624fa4 --- /dev/null +++ b/tur/ndk-sysroot-gcc-compact/0010-workaround-for-adl_only-namespace-in-system_error.patch @@ -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 diff --git a/tur/ndk-sysroot-gcc-compact/0011-workaround-for-has_specialization-in-segmented_iterator.patch b/tur/ndk-sysroot-gcc-compact/0011-workaround-for-has_specialization-in-segmented_iterator.patch new file mode 100644 index 000000000..25f9ab083 --- /dev/null +++ b/tur/ndk-sysroot-gcc-compact/0011-workaround-for-has_specialization-in-segmented_iterator.patch @@ -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 ++struct __has_specialization : false_type {}; ++ ++template ++struct __has_specialization<_Tp, __void_t> : true_type {}; ++ ++#else ++ + template + struct __has_specialization : false_type {}; + + template + struct __has_specialization<_Tp, sizeof(_Tp) * 0> : true_type {}; + ++#endif ++ + template + using __is_segmented_iterator = __has_specialization<__segmented_iterator_traits<_Iterator> >; + diff --git a/tur/ndk-sysroot-gcc-compact/build.sh b/tur/ndk-sysroot-gcc-compact/build.sh index d5f2cf5bd..dbbf569a8 100644 --- a/tur/ndk-sysroot-gcc-compact/build.sh +++ b/tur/ndk-sysroot-gcc-compact/build.sh @@ -5,6 +5,7 @@ TERMUX_PKG_MAINTAINER="@licy183" # Version should be equal to TERMUX_NDK_{VERSION_NUM,REVISION} in # scripts/properties.sh TERMUX_PKG_VERSION=26b +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=https://dl.google.com/android/repository/android-ndk-r${TERMUX_PKG_VERSION}-linux.zip TERMUX_PKG_SHA256=ad73c0370f0b0a87d1671ed2fd5a9ac9acfd1eb5c43a7fbfbd330f85d19dd632 # This package has taken over from the previous libutil-dev