Skip to contentSkip to conversation

boost: Fix build on 32-bit arches with 64bit time_t only

PATCH New Khem Raj 1 participant 2 messages Oct 16, 2020

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 boost: Fix build on 32-bit arches with 64bit time_t only

---
 ...efine-SYS_futex-if-it-does-not-exist.patch | 54 +++++++++++++++++++
 meta/recipes-support/boost/boost_1.74.0.bb    |  1 +
 2 files changed, 55 insertions(+)
 create mode 100644 meta/recipes-support/boost/boost/0001-fiber-libs-Define-SYS_futex-if-it-does-not-exist.patch
meta/recipes-support/boost/boost/0001-fiber-libs-Define-SYS_futex-if-it-does-not-exist.patch new file +54 -0
new file mode 100644
index 0000000000..523568e9bc
@@ -0,0 +1,54 @@
+From d6f7b6064dc91d1d5fa18554b40b14822ab7a32b Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Fri, 16 Oct 2020 11:13:22 -0700
+Subject: [PATCH] fiber,libs: Define SYS_futex if it does not exist
+
+__NR_futex is not defines by newer architectures e.g. arc, riscv32 as
+they only have 64bit variant of time_t. Glibc defines SYS_futex interface based on
+__NR_futex, since this is used in applications, such applications start
+to fail to build for these newer architectures. This patch defines a
+fallback to alias __NR_futex to __NR_futex_tim64 so SYS_futex keeps
+working
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ boost/fiber/detail/futex.hpp | 5 +++++
+ libs/log/src/event.cpp       | 4 ++++
+ 2 files changed, 9 insertions(+)
+
+diff --git a/boost/fiber/detail/futex.hpp b/boost/fiber/detail/futex.hpp
+index e64bd5990..16bee64f1 100644
+--- a/boost/fiber/detail/futex.hpp
++++ b/boost/fiber/detail/futex.hpp
+@@ -17,6 +17,11 @@ extern "C" {
+ #include <linux/futex.h>
+ #include <sys/syscall.h>
+ }
++
++#if !defined(SYS_futex) && defined(SYS_futex_time64)
++#define SYS_futex SYS_futex_time64
++#endif
++
+ #elif BOOST_OS_WINDOWS
+ #include <windows.h>
+ #endif
+diff --git a/libs/log/src/event.cpp b/libs/log/src/event.cpp
+index 5485154d7..2c7c0381f 100644
+--- a/libs/log/src/event.cpp
++++ b/libs/log/src/event.cpp
+@@ -31,6 +31,10 @@
+ #include <linux/futex.h>
+ #include <boost/memory_order.hpp>
+ 
++#if !defined(SYS_futex) && defined(SYS_futex_time64)
++#define SYS_futex SYS_futex_time64
++#endif
++
+ // Some Android NDKs (Google NDK and older Crystax.NET NDK versions) don't define SYS_futex
+ #if defined(SYS_futex)
+ #define BOOST_LOG_SYS_FUTEX SYS_futex
+-- 
+2.28.0
+
meta/recipes-support/boost/boost_1.74.0.bb +1 -0
index 5e9e0d87d7..b01b390a59 100644
@@ -7,4 +7,5 @@ SRC_URI += "file://arm-intrinsics.patch \
            file://0001-Apply-boost-1.62.0-no-forced-flags.patch.patch \
            file://0001-Don-t-set-up-arch-instruction-set-flags-we-do-that-o.patch \
            file://0001-dont-setup-compiler-flags-m32-m64.patch \
+           file://0001-fiber-libs-Define-SYS_futex-if-it-does-not-exist.patch \
            "
Signature · 1 line
2.28.0
author
#1 lore raw

PATCH 2/2 mesa: Fix build on 32bit arches supporting 64bit time_t only

Fixes
../mesa-20.1.8/src/util/futex.h:47:19: error: use of undeclared identifier 'SYS_futex'; did you mean 'sys_futex'?

   return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3);
                  ^~~~~~~~~
                  sys_futex
---
 ...fine-__NR_futex-if-it-does-not-exist.patch | 31 +++++++++++++++++++
 meta/recipes-graphics/mesa/mesa.inc           |  1 +
 2 files changed, 32 insertions(+)
 create mode 100644 meta/recipes-graphics/mesa/files/0001-futex.h-Define-__NR_futex-if-it-does-not-exist.patch
meta/recipes-graphics/mesa/files/0001-futex.h-Define-__NR_futex-if-it-does-not-exist.patch new file +31 -0
new file mode 100644
index 0000000000..8bedbac669
@@ -0,0 +1,31 @@
+From 8973e297f2f9b17498b9dc0e37a19481d4bb7df9 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Fri, 16 Oct 2020 11:03:47 -0700
+Subject: [PATCH] futex.h: Define __NR_futex if it does not exist
+
+__NR_futex is not defines by newer architectures e.g. arc, riscv32 as
+they only have 64bit variant of time_t. Glibc defines SYS_futex interface based on
+__NR_futex, since this is used in applications, such applications start
+to fail to build for these newer architectures. This patch defines a
+fallback to alias __NR_futex to __NR_futex_tim64 so SYS_futex keeps
+working
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+---
+ src/util/futex.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/src/util/futex.h
++++ b/src/util/futex.h
+@@ -34,6 +34,10 @@
+ #include <sys/syscall.h>
+ #include <sys/time.h>
+ 
++#if !defined(SYS_futex) && defined(SYS_futex_time64)
++# define SYS_futex SYS_futex_time64
++#endif
++
+ static inline long sys_futex(void *addr1, int op, int val1, const struct timespec *timeout, void *addr2, int val3)
+ {
+    return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3);
meta/recipes-graphics/mesa/mesa.inc +1 -0
index dd4619a06b..9fc62e95e1 100644
@@ -21,6 +21,7 @@ SRC_URI = "https://mesa.freedesktop.org/archive/mesa-${PV}.tar.xz \
            file://0004-Revert-mesa-Enable-asm-unconditionally-now-that-gen_.patch \
            file://0005-vc4-use-intmax_t-for-formatted-output-of-timespec-me.patch \
            file://0001-meson-misdetects-64bit-atomics-on-mips-clang.patch \
+           file://0001-futex.h-Define-__NR_futex-if-it-does-not-exist.patch \
            "
 
 SRC_URI[sha256sum] = "df21351494f7caaec5a3ccc16f14f15512e98d2ecde178bba1d134edc899b961"
Signature · 1 line
2.28.0