Upstream: https://github.com/ruby/ruby/pull/2995 From 9ce598b91e6ec8a146eec57c751d18dbebd2db60 Mon Sep 17 00:00:00 2001 From: Paul Jordan Date: Wed, 1 Apr 2020 02:13:49 +0100 Subject: [PATCH 1/3] ucontext doesn't exist in a musl-libc env; use native assembly --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 5bc93800efd1..a054d163b316 100644 --- a/configure.ac +++ b/configure.ac @@ -2353,8 +2353,8 @@ AS_CASE([$rb_cv_coroutine], [yes|''], [ [*86-mingw32], [ rb_cv_coroutine=win32 ], - [armv7*-linux*], [ - rb_cv_coroutine=ucontext + [arm*-linux*], [ + rb_cv_coroutine=arm32 ], [aarch64-linux*], [ rb_cv_coroutine=arm64 From e2f04a9a9684ea3575546cc317dd16dba54ecbaf Mon Sep 17 00:00:00 2001 From: Paul Jordan Date: Wed, 1 Apr 2020 02:15:20 +0100 Subject: [PATCH 2/3] Patch assembly so that it aligns properly --- coroutine/arm32/Context.S | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/coroutine/arm32/Context.S b/coroutine/arm32/Context.S index 195364fb655f..b66db29622a4 100644 --- a/coroutine/arm32/Context.S +++ b/coroutine/arm32/Context.S @@ -5,9 +5,13 @@ ## Copyright, 2018, by Samuel Williams. ## +.file "Context.S" .text - .globl coroutine_transfer +.align 2 +.type coroutine_transfer,%function +.syntax unified + coroutine_transfer: # Save caller state (8 registers + return address) push {r4-r11,lr} From 360904b97e0f1012855cd150a59cc0074cfa7453 Mon Sep 17 00:00:00 2001 From: Paul Jordan Date: Wed, 1 Apr 2020 02:18:23 +0100 Subject: [PATCH 3/3] Fix helper to not assume glibc --- test/fiddle/helper.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/fiddle/helper.rb b/test/fiddle/helper.rb index 348131e4480f..f5c7bd2ca6c7 100644 --- a/test/fiddle/helper.rb +++ b/test/fiddle/helper.rb @@ -32,7 +32,11 @@ # libc.so and libm.so are installed to /lib/arm-linux-gnu*. # It's not installed to /lib32. dirs = Dir.glob('/lib/arm-linux-gnu*') - libdir = dirs[0] if dirs && File.directory?(dirs[0]) + if dirs.length > 0 + libdir = dirs[0] if dirs && File.directory?(dirs[0]) + else # handle alpine environment + libdir = '/lib' if File.directory? '/lib' + end else libdir = '/lib32' if File.directory? '/lib32' end @@ -40,8 +44,17 @@ # 64-bit ruby libdir = '/lib64' if File.directory? '/lib64' end - libc_so = File.join(libdir, "libc.so.6") - libm_so = File.join(libdir, "libm.so.6") + + # Handle musl libc + libc = Dir.glob(File.join(libdir, "libc.musl*.so*")) + if libc && libc.length > 0 + libc_so = libc[0] + libm_so = libc[0] + else + # glibc + libc_so = File.join(libdir, "libc.so.6") + libm_so = File.join(libdir, "libm.so.6") + end when /mingw/, /mswin/ require "rbconfig" crtname = RbConfig::CONFIG["RUBY_SO_NAME"][/msvc\w+/] || 'ucrtbase'