Skip to contentSkip to conversation

ruby: Use arm32 for coroutines on 32bit-arm

PATCH Superseded Khem Raj 2 participants 5 messages Mar 9, 2020 – Mar 10, 2020

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 ruby: Use arm32 for coroutines on 32bit-arm

in 2.7 [2] ruby enabled ucontext for coroutines on arm32 but it does not work for musl since it uses glibc specific functions e.g. getcontext/swapcontext/swapcontext also see [1]

This patch reverts back to using arm32 implementation for coroutines on arm

[1] https://bugs.ruby-lang.org/issues/16455#change-83442
[2] https://github.com/ruby/ruby/commit/6c6bf9ffcbfeb8be9d9c342e7604b74ec819e88a#diff-7fccec8474e2184cd2518046bf39d54cL10

---
 meta/recipes-devtools/ruby/ruby_2.7.0.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-devtools/ruby/ruby_2.7.0.bb +2 -0
index 268b4bebd9..884bb0ef44 100644
@@ -25,6 +25,8 @@ EXTRA_OECONF = "\
     --with-pkg-config=pkg-config \
 "
 
+EXTRA_OECONF_append_arm_libc-musl = " --with-coroutine=arm32"
+
 do_install() {
     oe_runmake 'DESTDIR=${D}' install
 }
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/2 valgrind: Fix timerfb syscall test to be 64bit time_t safe

This helps compile the testcase with musl on 32bit arches

---
 ...check-tests-Fix-timerfd-syscall-test.patch | 210 ++++++++++++++++++
 .../valgrind/valgrind_3.15.0.bb               |   1 +
 2 files changed, 211 insertions(+)
 create mode 100644 meta/recipes-devtools/valgrind/valgrind/0001-memcheck-tests-Fix-timerfd-syscall-test.patch
meta/recipes-devtools/valgrind/valgrind/0001-memcheck-tests-Fix-timerfd-syscall-test.patch new file +210 -0
new file mode 100644
index 0000000000..d1d96a0eff
@@ -0,0 +1,210 @@
+From 5d411fd147d652e9d7bb259f4048693c6e4742aa Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Mon, 9 Mar 2020 16:30:19 -0700
+Subject: [PATCH] memcheck/tests: Fix timerfd syscall test
+
+modern libc provides these functions, moreover this also ensures that we
+are 64bit time_t safe. Fallback to existing definitions if libc does not
+have the implementation or syscall is not defined
+
+Upstream-Status: Submitted [https://sourceforge.net/p/valgrind/mailman/message/36943866/]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ config.h                               |  9 +++++++++
+ config.h.in                            |  9 +++++++++
+ configure                              |  3 +++
+ configure.ac                           |  3 +++
+ memcheck/tests/linux/timerfd-syscall.c | 10 ++++++++--
+ 5 files changed, 32 insertions(+), 2 deletions(-)
+
+--- a/config.h
++++ b/config.h
+@@ -47,20 +47,20 @@
+ /* #undef ENABLE_LTO */
+ 
+ /* path to GDB */
+-#define GDB_PATH "/usr/bin/gdb"
++#define GDB_PATH "/no/gdb/was/found/at/configure/time"
+ 
+ /* Define to 1 if index() and strlen() have been optimized heavily (x86 glibc
+    >= 2.12) */
+-#define GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT 1
++/* #undef GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT */
+ 
+ /* Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10) */
+-#define GLIBC_MANDATORY_STRLEN_REDIRECT 1
++/* #undef GLIBC_MANDATORY_STRLEN_REDIRECT */
+ 
+ /* Define to 1 if you have the <asm/unistd.h> header file. */
+ #define HAVE_ASM_UNISTD_H 1
+ 
+ /* Define to 1 if as supports fxsave64/fxrstor64. */
+-#define HAVE_AS_AMD64_FXSAVE64 1
++/* #undef HAVE_AS_AMD64_FXSAVE64 */
+ 
+ /* Define to 1 if as supports floating point phased out category. */
+ /* #undef HAVE_AS_PPC_FPPO */
+@@ -92,7 +92,7 @@
+ #define HAVE_CLOCK_MONOTONIC 1
+ 
+ /* Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID. */
+-#define HAVE_DLINFO_RTLD_DI_TLS_MODID 1
++/* #undef HAVE_DLINFO_RTLD_DI_TLS_MODID */
+ 
+ /* Define to 1 if the system has the type `Elf32_Chdr'. */
+ #define HAVE_ELF32_CHDR 1
+@@ -134,7 +134,7 @@
+ /* #undef HAVE_LIBSCF */
+ 
+ /* Define to 1 if you have the `mallinfo' function. */
+-#define HAVE_MALLINFO 1
++/* #undef HAVE_MALLINFO */
+ 
+ /* Define to 1 if you have the `memchr' function. */
+ #define HAVE_MEMCHR 1
+@@ -176,26 +176,26 @@
+ /* #undef HAVE_PTHREAD_CREATE_GLIBC_2_0 */
+ 
+ /* Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant. */
+-#define HAVE_PTHREAD_MUTEX_ADAPTIVE_NP 1
++/* #undef HAVE_PTHREAD_MUTEX_ADAPTIVE_NP */
+ 
+ /* Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant. */
+-#define HAVE_PTHREAD_MUTEX_ERRORCHECK_NP 1
++/* #undef HAVE_PTHREAD_MUTEX_ERRORCHECK_NP */
+ 
+ /* Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant. */
+-#define HAVE_PTHREAD_MUTEX_RECURSIVE_NP 1
++/* #undef HAVE_PTHREAD_MUTEX_RECURSIVE_NP */
+ 
+ /* Define to 1 if you have the `pthread_mutex_timedlock' function. */
+ #define HAVE_PTHREAD_MUTEX_TIMEDLOCK 1
+ 
+ /* Define to 1 if pthread_mutex_t has a member __data.__kind. */
+-#define HAVE_PTHREAD_MUTEX_T__DATA__KIND 1
++/* #undef HAVE_PTHREAD_MUTEX_T__DATA__KIND */
+ 
+ /* Define to 1 if pthread_mutex_t has a member called __m_kind. */
+ /* #undef HAVE_PTHREAD_MUTEX_T__M_KIND */
+ 
+ /* Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP'
+    constant. */
+-#define HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP 1
++/* #undef HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP */
+ 
+ /* Define to 1 if you have the `pthread_rwlock_t' type. */
+ #define HAVE_PTHREAD_RWLOCK_T 1
+@@ -213,7 +213,7 @@
+ #define HAVE_PTHREAD_SPIN_LOCK 1
+ 
+ /* Define to 1 if you have the `pthread_yield' function. */
+-#define HAVE_PTHREAD_YIELD 1
++/* #undef HAVE_PTHREAD_YIELD */
+ 
+ /* Define to 1 if you have the `PTRACE_GETREGS' ptrace request. */
+ #define HAVE_PTRACE_GETREGS 1
+@@ -309,7 +309,16 @@
+ #define HAVE_SYS_TYPES_H 1
+ 
+ /* Define to 1 if <sys/user.h> defines struct user_regs_struct */
+-#define HAVE_SYS_USER_REGS 1
++/* #undef HAVE_SYS_USER_REGS */
++
++/* Define to 1 if you have the `timerfd_create' function. */
++#define HAVE_TIMERFD_CREATE 1
++
++/* Define to 1 if you have the `timerfd_gettime' function. */
++#define HAVE_TIMERFD_GETTIME 1
++
++/* Define to 1 if you have the `timerfd_settime' function. */
++#define HAVE_TIMERFD_SETTIME 1
+ 
+ /* can use __thread to define thread-local variables */
+ #define HAVE_TLS 1
+@@ -324,7 +333,7 @@
+ #define HAVE_UTIMENSAT 1
+ 
+ /* Define to 1 if you're using Musl libc */
+-/* #undef MUSL_LIBC */
++#define MUSL_LIBC 1
+ 
+ /* Name of package */
+ #define PACKAGE "valgrind"
+--- a/config.h.in
++++ b/config.h.in
+@@ -310,6 +310,15 @@
+ /* Define to 1 if <sys/user.h> defines struct user_regs_struct */
+ #undef HAVE_SYS_USER_REGS
+ 
++/* Define to 1 if you have the `timerfd_create' function. */
++#undef HAVE_TIMERFD_CREATE
++
++/* Define to 1 if you have the `timerfd_gettime' function. */
++#undef HAVE_TIMERFD_GETTIME
++
++/* Define to 1 if you have the `timerfd_settime' function. */
++#undef HAVE_TIMERFD_SETTIME
++
+ /* can use __thread to define thread-local variables */
+ #undef HAVE_TLS
+ 
+--- a/configure.ac
++++ b/configure.ac
+@@ -4169,6 +4169,9 @@ AC_CHECK_FUNCS([     \
+         strrchr      \
+         strstr       \
+         syscall      \
++        timerfd_create    \
++        timerfd_gettime   \
++        timerfd_settime   \
+         utimensat    \
+         process_vm_readv  \
+         process_vm_writev \
+--- a/memcheck/tests/linux/timerfd-syscall.c
++++ b/memcheck/tests/linux/timerfd-syscall.c
+@@ -54,7 +54,7 @@
+  * timerfd_* system call numbers introduced in 2.6.23. These constants are
+  * not yet in the glibc 2.7 headers, that is why they are defined here.
+  */
+-#ifndef __NR_timerfd_create
++#if !defined(__NR_timerfd_create) && !defined(HAVE_TIMERFD_CREATE)
+ #if defined(__x86_64__)
+ #define __NR_timerfd_create  283
+ #elif defined(__i386__)
+@@ -68,7 +68,7 @@
+ #endif
+ #endif
+ 
+-#ifndef __NR_timerfd_settime
++#if !defined(__NR_timerfd_settime) && !defined(HAVE_TIMERFD_SETTIME)
+ #if defined(__x86_64__)
+ #define __NR_timerfd_settime 286
+ #define __NR_timerfd_gettime 287
+@@ -127,21 +127,27 @@ void set_timespec(struct timespec *tmr,
+   tmr->tv_nsec = (long) (1000ULL * (ustime % 1000000ULL));
+ }
+ 
++#if !defined(HAVE_TIMERFD_CREATE)
+ int timerfd_create(int clockid, int flags)
+ {
+   return syscall(__NR_timerfd_create, clockid, flags);
+ }
++#endif
+ 
++#if !defined(HAVE_TIMERFD_SETTIME)
+ int timerfd_settime(int ufc, int flags, const struct itimerspec *utmr,
+ 		    struct itimerspec *otmr)
+ {
+   return syscall(__NR_timerfd_settime, ufc, flags, utmr, otmr);
+ }
++#endif
+ 
++#if !defined(HAVE_TIMERFD_GETTIME)
+ int timerfd_gettime(int ufc, struct itimerspec *otmr)
+ {
+   return syscall(__NR_timerfd_gettime, ufc, otmr);
+ }
++#endif
+ 
+ long waittmr(int tfd, int timeo)
+ {
meta/recipes-devtools/valgrind/valgrind_3.15.0.bb +1 -0
index 1475ff841e..7954437a1a 100644
@@ -41,6 +41,7 @@ SRC_URI = "https://sourceware.org/pub/valgrind/valgrind-${PV}.tar.bz2 \
            file://s390x_vec_op_t.patch \
            file://0001-none-tests-fdleak_cmsg.stderr.exp-adjust-tmp-paths.patch \
            file://0001-tests-Make-pthread_detatch-call-portable-across-plat.patch \
+           file://0001-memcheck-tests-Fix-timerfd-syscall-test.patch \
            "
 SRC_URI[md5sum] = "46e5fbdcbc3502a5976a317a0860a975"
 SRC_URI[sha256sum] = "417c7a9da8f60dd05698b3a7bc6002e4ef996f14c13f0ff96679a16873e78ab1"
Signature · 1 line
2.25.1
#2 lore raw
In reply to Khem Raj
Quoted 21 lines · Khem Raj

in 2.7 [2] ruby enabled ucontext for coroutines on arm32 but it does not work for musl since it uses glibc specific functions e.g. getcontext/swapcontext/swapcontext also see [1]

This patch reverts back to using arm32 implementation for coroutines on arm

[1] https://bugs.ruby-lang.org/issues/16455#change-83442
[2] https://github.com/ruby/ruby/commit/6c6bf9ffcbfeb8be9d9c342e7604b74ec819e88a#diff-7fccec8474e2184cd2518046bf39d54cL10

---
 meta/recipes-devtools/ruby/ruby_2.7.0.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-devtools/ruby/ruby_2.7.0.bb +0 -0
index 268b4bebd9..884bb0ef44 100644

meta/recipes-devtools/ruby/ruby_2.7.0.bb EXTRA_OECONF = "\ · line 28

Quoted 4 lines
meta/recipes-devtools/ruby/ruby_2.7.0.bb +1 -0
@@ -25,6 +25,8 @@ EXTRA_OECONF = "\
     --with-pkg-config=pkg-config \
 "
 
+EXTRA_OECONF_append_arm_libc-musl = " --with-coroutine=arm32"

Generally any _arm over-ride should either be duplicated for _armeb too (or the commit message should explain why the over-ride is specific to little endian ARM only).

Quoted 11 lines
meta/recipes-devtools/ruby/ruby_2.7.0.bb +0 -1
 do_install() {
     oe_runmake 'DESTDIR=${D}' install
 }
--

2.25.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

author
#3 lore raw
Quoted 25 lines · Andre McCurdy
Quoted 24 lines · Khem Raj

in 2.7 [2] ruby enabled ucontext for coroutines on arm32 but it does not work for musl since it uses glibc specific functions e.g. getcontext/swapcontext/swapcontext also see [1]

This patch reverts back to using arm32 implementation for coroutines on arm

[1] https://bugs.ruby-lang.org/issues/16455#change-83442
[2] https://github.com/ruby/ruby/commit/6c6bf9ffcbfeb8be9d9c342e7604b74ec819e88a#diff-7fccec8474e2184cd2518046bf39d54cL10

---
 meta/recipes-devtools/ruby/ruby_2.7.0.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-devtools/ruby/ruby_2.7.0.bb +0 -0
index 268b4bebd9..884bb0ef44 100644
@@ -25,6 +25,8 @@ EXTRA_OECONF = "\
     --with-pkg-config=pkg-config \
 "
 
Quoted 5 lines

meta/recipes-devtools/ruby/ruby_2.7.0.bb EXTRA_OECONF = "\ · line 28

Quoted 1 line
meta/recipes-devtools/ruby/ruby_2.7.0.bb +1 -0
+EXTRA_OECONF_append_arm_libc-musl = " --with-coroutine=arm32"

Generally any _arm over-ride should either be duplicated for _armeb too (or the commit message should explain why the over-ride is specific to little endian ARM only).

its just that I did not test it on armeb, and its assembly piece which would need some testing on BE before it is enabled.

Quoted 12 lines
Quoted 12 lines
meta/recipes-devtools/ruby/ruby_2.7.0.bb +0 -1
 do_install() {
     oe_runmake 'DESTDIR=${D}' install
 }
--

2.25.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#4 lore raw
Quoted 27 lines · Khem Raj
Quoted 25 lines · Andre McCurdy
Quoted 24 lines · Khem Raj

in 2.7 [2] ruby enabled ucontext for coroutines on arm32 but it does not work for musl since it uses glibc specific functions e.g. getcontext/swapcontext/swapcontext also see [1]

This patch reverts back to using arm32 implementation for coroutines on arm

[1] https://bugs.ruby-lang.org/issues/16455#change-83442
[2] https://github.com/ruby/ruby/commit/6c6bf9ffcbfeb8be9d9c342e7604b74ec819e88a#diff-7fccec8474e2184cd2518046bf39d54cL10

---
 meta/recipes-devtools/ruby/ruby_2.7.0.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-devtools/ruby/ruby_2.7.0.bb +0 -0
index 268b4bebd9..884bb0ef44 100644
@@ -25,6 +25,8 @@ EXTRA_OECONF = "\
     --with-pkg-config=pkg-config \
 "
 
Quoted 8 lines
Quoted 5 lines

meta/recipes-devtools/ruby/ruby_2.7.0.bb EXTRA_OECONF = "\ · line 28

Quoted 1 line
meta/recipes-devtools/ruby/ruby_2.7.0.bb +1 -0
+EXTRA_OECONF_append_arm_libc-musl = " --with-coroutine=arm32"

Generally any _arm over-ride should either be duplicated for _armeb too (or the commit message should explain why the over-ride is specific to little endian ARM only).

its just that I did not test it on armeb, and its assembly piece which would need some testing on BE before it is enabled.

The default should be to keep arm and armeb in sync, unless there's a clear reason not to. If you want to test big endian ARM then that's great, but if you don't then just keeping the two targets in sync is better than leaving big endian ARM unfixed _and_ untested.

Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
meta/recipes-devtools/ruby/ruby_2.7.0.bb +0 -1
 do_install() {> >>      oe_runmake 'DESTDIR=${D}' install
 }
--

2.25.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core