boost: Fix fiber compilation for mips
authorRosen Penev <rosenp@gmail.com>
Fri, 15 Nov 2019 20:34:26 +0000 (12:34 -0800)
committerRosen Penev <rosenp@gmail.com>
Sun, 17 Nov 2019 02:14:11 +0000 (18:14 -0800)
The issue was that the pause instruction was emitted through an asm
directive which was not correct for some mips platforms.

Simplified boost-fiber-exclude as a result.

Removed uClibc-ng math patch. It was not correct as it broke float and
long double support (std variants use function overloads). A different
solution was applied upstream. As it's quite annoying to backport, just
wait until a new release comes with that change. ARC as a platform is
barely supported anyways.

Swapped asio patch for the upstream submission, which is unfortunately, in
limbo.

Refreshed remaining patch.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
(cherry-picked from f795779c0a4080ccf497a0266e33f1842248efe8)

libs/boost/Makefile
libs/boost/patches/001-uclibc-asio.patch
libs/boost/patches/002-utime-filesystem.patch
libs/boost/patches/003-mips-pause.patch [new file with mode: 0644]
libs/boost/patches/101-uclibc-ng-math.patch [deleted file]

index 90518c17a1e58969cc6a4391ee86a1a45e972631..4eac36ae47c39548429522199846f0bcc3803e2a 100644 (file)
@@ -13,7 +13,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=boost
 PKG_VERSION:=1.71.0
 PKG_SOURCE_VERSION:=1_71_0
-PKG_RELEASE:=4
+PKG_RELEASE:=5
 
 PKG_SOURCE:=$(PKG_NAME)_$(PKG_SOURCE_VERSION).tar.bz2
 PKG_SOURCE_URL:=@SF/$(PKG_NAME)/$(PKG_NAME)/$(PKG_VERSION) https://dl.bintray.com/boostorg/release/$(PKG_VERSION)/source/
@@ -130,7 +130,7 @@ define Package/boost/config
 
        config boost-fiber-exclude
                bool
-               default y if (TARGET_ar7 || TARGET_brcm47xx_generic || TARGET_brcm47xx_legacy || TARGET_lantiq_ase || TARGET_rb532 || mips32 || mips64 || boost-coroutine-exclude)
+               default y if boost-coroutine-exclude
                default n
 
        menu "Select Boost Options"
index b7732d0e713e95497c7242c85ae216e81e28fc5d..07efd1305e1798c9b985cfe588f56f80be2f644c 100644 (file)
@@ -1,3 +1,28 @@
+From 95d82acc57bb7d8bae431f7a6ce0707aac3ef33f Mon Sep 17 00:00:00 2001
+From: Rosen Penev <rosenp@gmail.com>
+Date: Thu, 5 Sep 2019 19:41:13 -0700
+Subject: [PATCH] Use eventfd() function with uClibc
+
+The Boost eventfd code either directly makes the eventfd system call
+using __NR_eventfd (when __GLIBC_MINOR is less than 8), or otherwise
+uses the eventfd() function provided by the C library.
+
+However, since uClibc pretends to be glibc 2.2, the Boost eventfd code
+directly uses the system call. While it works fine on most
+architectures, it doesn't on ARC since __NR_eventfd is not defined on
+this architecture. However, eventfd() is properly implemented.
+
+So, this patch adjusts the logic used by Boost to consider uClibc as a
+C library providing the eventfd() function.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Signed-off-by: Rosen Penev <rosenp@gmail.com>
+---
+ a/boost/asio/detail/impl/eventfd_select_interrupter.ipp  | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/boost/asio/detail/impl/eventfd_select_interrupter.ipp b/boost/asio/detail/impl/eventfd_select_interrupter.ipp
+index 38d4b2a61..e16cc8b00 100644
 --- a/boost/asio/detail/impl/eventfd_select_interrupter.ipp
 +++ b/boost/asio/detail/impl/eventfd_select_interrupter.ipp
 @@ -23,11 +23,11 @@
@@ -15,7 +40,7 @@
  #include <boost/asio/detail/cstdint.hpp>
  #include <boost/asio/detail/eventfd_select_interrupter.hpp>
  #include <boost/asio/detail/throw_error.hpp>
-@@ -46,14 +46,14 @@ eventfd_select_interrupter::eventfd_sele
+@@ -46,14 +46,14 @@ eventfd_select_interrupter::eventfd_select_interrupter()
  
  void eventfd_select_interrupter::open_descriptors()
  {
@@ -32,7 +57,7 @@
  # if defined(EFD_CLOEXEC) && defined(EFD_NONBLOCK)
    write_descriptor_ = read_descriptor_ =
      ::eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
-@@ -70,7 +70,7 @@ void eventfd_select_interrupter::open_de
+@@ -70,7 +70,7 @@ void eventfd_select_interrupter::open_descriptors()
        ::fcntl(read_descriptor_, F_SETFD, FD_CLOEXEC);
      }
    }
index 2a778af3a5db114d4d873526d7534932a8e8e087..9b5c246ae198fcb85fff410778135743d249cabd 100644 (file)
@@ -37,7 +37,7 @@ index 9bba1cf7a..038109d35 100644
  #   include "limits.h"
  
  # else // BOOST_WINDOW_API
-@@ -1451,6 +1453,22 @@ namespace detail
+@@ -1459,6 +1461,22 @@ namespace detail
                          system::error_code* ec)
    {
  #   ifdef BOOST_POSIX_API
@@ -60,7 +60,7 @@ index 9bba1cf7a..038109d35 100644
  
      struct stat path_stat;
      if (error(::stat(p.c_str(), &path_stat)!= 0,
-@@ -1462,6 +1480,8 @@ namespace detail
+@@ -1470,6 +1488,8 @@ namespace detail
      error(::utime(p.c_str(), &buf)!= 0 ? BOOST_ERRNO : 0,
        p, ec, "boost::filesystem::last_write_time");
  
diff --git a/libs/boost/patches/003-mips-pause.patch b/libs/boost/patches/003-mips-pause.patch
new file mode 100644 (file)
index 0000000..10a0ae9
--- /dev/null
@@ -0,0 +1,28 @@
+From 5f7cda29add367c5381775a314ec9f90e311457a Mon Sep 17 00:00:00 2001
+From: Rosen Penev <rosenp@gmail.com>
+Date: Fri, 15 Nov 2019 12:43:50 -0800
+Subject: [PATCH] cpu_relax: Fix MIPS check
+
+BOOST_ARCH_MIPS as a macro is totally broken. It always gets defined to either 32
+or 64 with a bunch of zeroes depending on the architecture.
+
+Use GCC's internal define to check the architecture properly.
+
+Signed-off-by: Rosen Penev <rosenp@gmail.com>
+---
+ boost/fiber/detail/cpu_relax.hpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/boost/fiber/detail/cpu_relax.hpp b/boost/fiber/detail/cpu_relax.hpp
+index 72564394..f40545c2 100644
+--- a/boost/fiber/detail/cpu_relax.hpp
++++ b/boost/fiber/detail/cpu_relax.hpp
+@@ -47,7 +47,7 @@ namespace detail {
+ # else
+ #  define cpu_relax() asm volatile ("nop" ::: "memory");
+ # endif
+-#elif BOOST_ARCH_MIPS
++#elif BOOST_ARCH_MIPS && (__mips_isa_rev > 1)
+ # define cpu_relax() asm volatile ("pause" ::: "memory");
+ #elif BOOST_ARCH_PPC
+ // http://code.metager.de/source/xref/gnu/glibc/sysdeps/powerpc/sys/platform/ppc.h
diff --git a/libs/boost/patches/101-uclibc-ng-math.patch b/libs/boost/patches/101-uclibc-ng-math.patch
deleted file mode 100644 (file)
index 0d16686..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/boost/math/tools/roots.hpp
-+++ b/boost/math/tools/roots.hpp
-@@ -665,8 +665,8 @@ namespace detail
-     inline T discriminant(T const & a, T const & b, T const & c)
-     {
-         T w = 4*a*c;
--        T e = std::fma(-c, 4*a, w);
--        T f = std::fma(b, b, -w);
-+        T e = fma(-c, 4*a, w);
-+        T f = fma(b, b, -w);
-         return f + e;
-     }
- }
-@@ -674,7 +674,6 @@ namespace detail
- template<class T>
- auto quadratic_roots(T const& a, T const& b, T const& c)
- {
--    using std::copysign;
-     using std::sqrt;
-     if constexpr (std::is_integral<T>::value)
-     {