#64906 closed defect (wontfix)
fixing Ruby for PowerPC
Reported by: | barracuda156 | Owned by: | kimuraw (kimura wataru) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.7.2 |
Keywords: | powerpc, leopard, snowleopard | Cc: | |
Port: | ruby27, ruby30 |
Description
I have tried building ruby27
and ruby30
for ppc, they fail on configure with one test. The following patch fixes configure, and then both build through completion (example for ruby30):
--- configure.orig 2021-11-24 19:12:17.000000000 +0800 +++ configure 2022-03-30 03:51:50.000000000 +0800 @@ -8443,6 +8443,8 @@ ARCH_FLAG=-m64 ;; #( i[3-6]86) : ARCH_FLAG=-m32 ;; #( + ppc) : + ARCH_FLAG=-m32 ;; #( *) : as_fn_error $? "unknown target architecture: $target_archs" "$LINENO" 5 ;;
Elsewhere the source code has references to ppc and powerpc-darwin, so this test looks rather arbitrary. Everything looks okay then:
36-109% file /opt/local/bin/ruby3.0 /opt/local/bin/ruby3.0: Mach-O executable ppc 36-109% /opt/local/bin/ruby3.0 -v ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [ppc-darwin10] 36-109% port -v installed ruby30 The following ports are currently installed: ruby30 @3.0.3_1 (active) requested_variants='' platform='darwin 10' archs='ppc' date='2022-03-30T04:04:37+0800'
However when I try building dependencies with either of newly installed ruby versions, compilation freezes. No error is given, process just hangs indefinitely with 100% on one core but apparently doing nothing. (I had a similar freeze with recent gobject/vala-related dependencies like gexiv2.)
What did I miss?
Attachments (1)
Change History (24)
comment:1 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)
Keywords: | ruby removed |
---|---|
Owner: | set to kimuraw |
Status: | new → assigned |
comment:2 follow-ups: 5 13 18 Changed 3 years ago by evanmiller (Evan Miller)
comment:3 follow-ups: 4 19 Changed 3 years ago by evanmiller (Evan Miller)
After building each port try
port test ruby30 test.run=yes test.target=check
That should give you an idea about whether the interpreter works correctly. If Ruby 3 hasn't been designed for Darwin/PPC then there are a number of things that could go wrong.
comment:4 Changed 3 years ago by barracuda156
Replying to evanmiller:
Thank you. By the way, looks like ruby
may have issues with specific compilers: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242630#c9
I think I used gcc10
to build. I should try ancient gcc-4.2
.
comment:5 follow-up: 6 Changed 3 years ago by barracuda156
Replying to evanmiller:
When I was tinkering with Ruby on PPC, I ran into some issues with coroutines.
Looks like they are simply missing for ppc Big endian :(
And configure only has --with-coroutine=IMPLEMENTATION
, not --disable.
I have quickly checked earlier versions, and apparently they appeared in ruby26
and back then already had no ppc/ppc64, only ppc64le.
How do we go about that, any thoughts?
comment:6 follow-up: 7 Changed 3 years ago by evanmiller (Evan Miller)
Replying to barracuda156:
Replying to evanmiller:
When I was tinkering with Ruby on PPC, I ran into some issues with coroutines.
Looks like they are simply missing for ppc Big endian :( And configure only has
--with-coroutine=IMPLEMENTATION
, not --disable.I have quickly checked earlier versions, and apparently they appeared in
ruby26
and back then already had no ppc/ppc64, only ppc64le.How do we go about that, any thoughts?
Try port test ruby26 test.run=yes test.target=check
and see how the test results look. I think that version of Ruby at least built on my PPC machine, but I don't know if coroutines worked properly.
comment:7 Changed 3 years ago by barracuda156
Replying to evanmiller:
Chunk of basic tests are successful for both ruby25
(no coroutines) and ruby30
:
ruby25
test_autoload.rb ........ :info:test test_block.rb .......................................................... :info:test test_class.rb ................................................ :info:test test_env.rb .. :info:test test_eval.rb ..................................... :info:test test_exception.rb .................................. :info:test test_finalizer.rb . :info:test test_flip.rb . :info:test test_flow.rb .............................................................. :info:test test_fork.rb ..... :info:test test_gc.rb .. :info:test test_insns.rb ........................................................................................................................................................................................... :info:test test_io.rb ......... :info:test test_jump.rb ............................. :info:test test_literal.rb ............................................................................................................................................................ :info:test test_literal_suffix.rb ................................................ :info:test test_load.rb .. :info:test test_marshal.rb . :info:test test_massign.rb .................................. :info:test test_method.rb ............................................................................................................................................................................................................................... :info:test test_objectspace.rb ..... :info:test test_proc.rb ....................................... :info:test test_string.rb . :info:test test_struct.rb . :info:test test_syntax.rb ............................................................................................................................................................ :info:test test_thread.rb .................................................. :info:test PASS all 1201 tests :info:test exec ./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems "./bootstraptest/runner.rb" --ruby="ruby2.5 --disable-gems" ./KNOWNBUGS.rb :info:test 2022-04-13 11:06:40 +0800 :info:test Driver is ruby 2.5.9p229 (2021-04-05 revision 67939) [powerpc-darwin10.0.0d2] :info:test Target is ruby 2.5.9p229 (2021-04-05 revision 67939) [powerpc-darwin10.0.0d2] :info:test KNOWNBUGS.rb :info:test No tests, no problem :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:assignment ....................................................................................................................................................................................................................................................................................................................................................................................OK 372 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:condition ..OK 2 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:if/unless ...OK 3 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:case .....OK 5 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:while/until ........OK 8 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:exception ..........OK 10 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:array .......................................OK 39 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:hash ...........................OK 27 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:iterator ...............................................................................................................OK 111 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:float ................................................................................OK 80 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:bignum ...............................OK 31 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:string & char ..............................................................OK 62 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:assignment ..........OK 10 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:call ......OK 6 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:proc .........OK 9 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:signal ..OK 2 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:eval ...........................OK 27 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:system ........OK 8 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:const .....OK 5 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:clone .....OK 5 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:marshal ....OK 4 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:pack ....OK 4 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:math ..OK 2 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:struct ......OK 6 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:variable ...........OK 11 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:trace ...OK 3 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:defined? ............OK 12 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:alias ......OK 6 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:path .......................OK 23 :info:test /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby25/ruby25/work/ruby-2.5.9/basictest/test.rb:gc ....OK 4 :info:test test succeeded :info:test Run options: "--ruby=./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems" :info:test # Running tests: :info:test Finished tests in 9.275339s, 23.9344 tests/s, 49.7017 assertions/s. :info:test 222 tests, 461 assertions, 0 failures, 0 errors, 0 skips :info:test ruby -v: ruby 2.5.9p229 (2021-04-05 revision 67939) [powerpc-darwin10.0.0d2]
ruby30
test_attr.rb .. test_autoload.rb ........ test_block.rb .......................................................... test_class.rb ................................................ test_env.rb .. test_eval.rb ..................................... test_exception.rb .................................. test_fiber.rb ..... test_finalizer.rb . test_flip.rb . test_flow.rb .............................................................. test_fork.rb .... test_gc.rb .. test_insns.rb ............................................................................................................................................................................................................................................................................................................................................................................................... test_io.rb ......... test_jump.rb ............................. test_literal.rb ............................................................................................................................................................ test_literal_suffix.rb ................................................ test_load.rb .. test_marshal.rb . test_massign.rb .................................. test_method.rb ............................................................................................................................................................................................................................... test_objectspace.rb ...... test_proc.rb ..................................... test_ractor.rb .......................................................................................... test_string.rb . test_struct.rb . test_syntax.rb ............................................................................................................................................................ test_thread.rb ................................................. Fiber count: 10000 (skipping) PASS all 1489 tests exec ./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems "./bootstraptest/runner.rb" --ruby="ruby3.0 --disable-gems" ./KNOWNBUGS.rb 2022-04-13 11:50:03 +0800 Driver is ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [ppc-darwin10] Target is ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [ppc-darwin10] KNOWNBUGS.rb No tests, no problem /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:assignment ....................................................................................................................................................................................................................................................................................................................................................................................OK 372 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:condition ..OK 2 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:if/unless ...OK 3 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:case .....OK 5 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:while/until ........OK 8 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:exception ..........OK 10 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:array .......................................OK 39 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:hash ...........................OK 27 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:iterator ...........................................................................................................OK 107 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:float ................................................................................OK 80 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:bignum ...............................OK 31 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:string & char ..............................................................OK 62 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:assignment ..........OK 10 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:call ......OK 6 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:proc .........OK 9 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:signal ..OK 2 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:eval ...........................OK 27 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:system ........OK 8 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:const .....OK 5 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:clone .....OK 5 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:marshal ....OK 4 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:pack ....OK 4 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:math ..OK 2 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:struct ......OK 6 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:variable ............OK 12 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:trace ...OK 3 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:defined? ............OK 12 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:alias ......OK 6 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:path .......................OK 23 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby30/ruby30/work/ruby-3.0.3/basictest/test.rb:gc ....OK 4 test succeeded Run options: --seed=12085 "--ruby=./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems" # Running tests: Finished tests in 37.348612s, 9.7460 tests/s, 45.2761 assertions/s. 364 tests, 1691 assertions, 0 failures, 0 errors, 0 skips ruby -v: ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [ppc-darwin10]
Then further down ruby25
had a number of failures with IMAP and FTP, which I am not yet sure if those are genuine failures and not a result of my restrictive web-access here (plus Little Snitch which complained in the process).
ruby30
is stuck on the same part already forever, and I am afraid I can't try waiting for it to end today. I think something is broken, and the same problem I faced when trying to use newer Ruby to build other ports.
comment:8 follow-up: 12 Changed 3 years ago by kimuraw (kimura wataru)
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
ppc Mac is not target of ruby-2.0 (released 2013) or later for ruby dev team. ruby 2.6->2.7 and 2.7->3.0 contains many changes of core system. I do not think we can let to work ruby2.7 or 3.x on ppc Mac with a little change to current code.
I'll set supported_archs
into Portfiles.
comment:9 follow-up: 10 Changed 3 years ago by kencu (Ken)
So let this be a tiny lesson to people.
If you open many tickets about little failures, the end result is the port is locked down to prevent you from ever trying to build it again.
This is why you see me trying to be a bit judicious about 1000s of tickets being opened, and closing many of them (at least I was previously closing many of them).
If you want ruby on PPC Tiger and Leopard (and as I recall it works quite well, almost all tests pass as above) what you do is FIX THE PROBLEM yourself and PR the fix into GitHub for the maintainer to commit, just posting that it fixed XYZ problem.
The more you make the port look broken to people, the more likely this will happen to it.
Now, you see, it will be hard to impossible to ever get ruby support back for PPC in MacPorts, once this decision has been made. So this is where you wind up.
comment:10 Changed 3 years ago by barracuda156
Replying to kencu:
So let this be a tiny lesson to people.
If you open many tickets about little failures, the end result is the port is locked down to prevent you from ever trying to build it again.
This is why you see me trying to be a bit judicious about 1000s of tickets being opened, and closing many of them (at least I was previously closing many of them).
If you want ruby on PPC Tiger and Leopard (and as I recall it works quite well, almost all tests pass as above) what you do is FIX THE PROBLEM yourself and PR the fix into GitHub for the maintainer to commit, just posting that it fixed XYZ problem.
The more you make the port look broken to people, the more likely this will happen to it.
Now, you see, it will be hard to impossible to ever get ruby support back for PPC in MacPorts, once this decision has been made. So this is where you wind up.
I get your point, but as for Ruby goes, this is the only ticket I have opened, and that too I did not demand anyone fix it for me and actually started working on it myself. While I may be guilty of unnecessary tickets in some cases, here I don’t see anything to justify such a response.
On a general note, my understanding has been that having a ticket about existing problem is useful, as it informs anyone else interested that such a problem exists. How else we are to inform developers and users? Yes, I definitely agree that if me or anyone is able to provide a fix, it makes better sense to propose a fix rightaway rather than merely state that something is broken. However often that’s not the case, and resorting to developers on Github may or may not work (we know a number of cases when developers just don’t care).
comment:11 Changed 3 years ago by kencu (Ken)
Yes, it's tricky getting the balance.
The truth is 99.99999999999% of MacPorts maintainers don't care about PowerPC and would be happiest if it was dropped completely due to all the noise it generates.
PowerPC Rosetta on 10.6 or PowerPC on 10.6 is yet another order of magnitude away from relevant to everyone.
So you have to be judicious -- nobody really cares if some port doesn't build on 10.6 as Rosetta, and nobody is going to fix it but you anyway most likely.
The likely outcome from all these tickets is really MacPorts dropping PowerPC support completely and all these tickets being en-masse closed.
comment:12 Changed 3 years ago by barracuda156
Replying to kimuraw:
ppc Mac is not target of ruby-2.0 (released 2013) or later for ruby dev team. ruby 2.6->2.7 and 2.7->3.0 contains many changes of core system. I do not think we can let to work ruby2.7 or 3.x on ppc Mac with a little change to current code.
I'll set
supported_archs
into Portfiles.
Maybe you could just leave it as is for now? It seems that there is no inherent problem with the ppc/ppc64 arch for Ruby, since FreeBSD has been building it: https://cgit.freebsd.org/ports/commit/?id=d87e3a4da8da560ab9a55150a5e71080543d4e38 I will see if I can make it work.
comment:13 Changed 3 years ago by barracuda156
Replying to evanmiller:
When I was tinkering with Ruby on PPC, I ran into some issues with coroutines.
With an earlier Ruby, someone apparently succeeded building it for ppc32 (though not Darwin in that case) with using --with-coroutine=copy
: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/98716
Also: https://www.mail-archive.com/ports@openbsd.org/msg91940.html
This option is gone in @3.1, however now there is --with-coroutine=pthread
, which logically should also be cpu-agnostic.
Now, there is one problem with thread_pthread.c
for Ruby @3.1: there is no pthread_threadid_np
on Tiger and Leopard (and on 10A190 too). Similar issue has been solved for Python and Mesa:
https://trac.macports.org/ticket/59772
https://trac.macports.org/ticket/34499
However Ruby case differs somewhat, and I am unsure how to rewrite it correctly:
#if defined(RB_THREAD_T_HAS_NATIVE_ID) || defined(__APPLE__) static VALUE native_thread_native_thread_id(rb_thread_t *target_th) { #ifdef RB_THREAD_T_HAS_NATIVE_ID int tid = target_th->tid; if (tid == 0) return Qnil; return INT2FIX(tid); #elif defined(__APPLE__) uint64_t tid; int e = pthread_threadid_np(target_th->thread_id, &tid); if (e != 0) rb_syserr_fail(e, "pthread_threadid_np"); return ULL2NUM((unsigned long long)tid); #endif } # define USE_NATIVE_THREAD_NATIVE_THREAD_ID 1 #else # define USE_NATIVE_THREAD_NATIVE_THREAD_ID 0 #endif
comment:14 Changed 3 years ago by kencu (Ken)
This would do it:
#if defined(RB_THREAD_T_HAS_NATIVE_ID) || defined(__APPLE__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1050) static VALUE native_thread_native_thread_id(rb_thread_t *target_th) { #ifdef RB_THREAD_T_HAS_NATIVE_ID int tid = target_th->tid; if (tid == 0) return Qnil; return INT2FIX(tid); #elif defined(__APPLE__) uint64_t tid; int e = pthread_threadid_np(target_th->thread_id, &tid); if (e != 0) rb_syserr_fail(e, "pthread_threadid_np"); return ULL2NUM((unsigned long long)tid); #endif } # define USE_NATIVE_THREAD_NATIVE_THREAD_ID 1 #else # define USE_NATIVE_THREAD_NATIVE_THREAD_ID 0 #endif
amongst other fixes that might actually return some thread_id.
The thread_id is really not particularly useful anyway -- helps with debugging threads, which is not likely to be anybody's issue on Tiger or Leopard anyway.
comment:15 follow-ups: 16 21 Changed 3 years ago by kencu (Ken)
Or this should work:
#if defined(RB_THREAD_T_HAS_NATIVE_ID) || defined(__APPLE__) static VALUE native_thread_native_thread_id(rb_thread_t *target_th) { #ifdef RB_THREAD_T_HAS_NATIVE_ID int tid = target_th->tid; if (tid == 0) return Qnil; return INT2FIX(tid); #elif defined(__APPLE__) #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1050 uint64_t tid; int e = pthread_threadid_np(target_th->thread_id, &tid); if (e != 0) rb_syserr_fail(e, "pthread_threadid_np"); return ULL2NUM((unsigned long long)tid); #else uint64_t tid; tid = pthread_mach_thread_np(pthread_self()); #endif #endif } # define USE_NATIVE_THREAD_NATIVE_THREAD_ID 1 #else # define USE_NATIVE_THREAD_NATIVE_THREAD_ID 0 #endif
comment:16 Changed 3 years ago by barracuda156
Replying to kencu:
Or this should work:
Thank you! Trying now.
- S. I made initially this, and it did build, but I was suspecting it is wrong:
#if defined(RB_THREAD_T_HAS_NATIVE_ID) || defined(__APPLE__) static VALUE native_thread_native_thread_id(rb_thread_t *target_th) { #ifdef RB_THREAD_T_HAS_NATIVE_ID int tid = target_th->tid; if (tid == 0) return Qnil; return INT2FIX(tid); #elif defined(__APPLE__) uint64_t tid; #if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 tid = pthread_mach_thread_np(pthread_self()); #elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060 if (&pthread_threadid_np) { int e = pthread_threadid_np(target_th->thread_id, &tid); if (e != 0) rb_syserr_fail(e, "pthread_threadid_np"); } else { tid = pthread_mach_thread_np(pthread_self()); } #else int e = pthread_threadid_np(target_th->thread_id, &tid); if (e != 0) rb_syserr_fail(e, "pthread_threadid_np"); #endif return ULL2NUM((unsigned long long)tid); #endif } # define USE_NATIVE_THREAD_NATIVE_THREAD_ID 1 #else # define USE_NATIVE_THREAD_NATIVE_THREAD_ID 0 #endif
comment:17 Changed 3 years ago by barracuda156
UPD. @3.1.1 builds and passes basic tests, but tests freeze on the same spot:
config.status: creating ruby-runner.h making mjit_build_dir.dylib generating ppc-darwin10.0.0d2-fake.rb ppc-darwin10.0.0d2-fake.rb updated test_attr.rb .. test_autoload.rb ........ test_block.rb .......................................................... test_class.rb ................................................ test_env.rb .. test_eval.rb ........................................ test_exception.rb .................................. test_fiber.rb ..... test_finalizer.rb . test_flip.rb . test_flow.rb .............................................................. test_fork.rb .... test_gc.rb .. test_insns.rb ................................................................................................................................................................................................................................................................................................................................................................................................. test_io.rb ......... test_jump.rb ............................. test_literal.rb ............................................................................................................................................................ test_literal_suffix.rb ................................................ test_load.rb .. test_marshal.rb . test_massign.rb .................................. test_method.rb ............................................................................................................................................................................................................................... test_objectspace.rb ...... test_proc.rb ..................................... test_ractor.rb .................................................................................................... test_string.rb . test_struct.rb . test_syntax.rb ............................................................................................................................................................ test_thread.rb ................................................. test_yjit.rb .................................................................................................................................................................. test_yjit_30k_ifelse.rb . test_yjit_30k_methods.rb . Fiber count: 2558 (Cannot allocate memory - coroutine_transfer) PASS all 1668 tests exec ./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems "./bootstraptest/runner.rb" --ruby="ruby3.1 --disable-gems" ./KNOWNBUGS.rb 2022-04-16 11:22:38 +0800 Driver is ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [ppc-darwin10.0.0d2] Target is ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [ppc-darwin10.0.0d2] KNOWNBUGS.rb No tests, no problem /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:assignment ....................................................................................................................................................................................................................................................................................................................................................................................OK 372 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:condition ..OK 2 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:if/unless ...OK 3 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:case .....OK 5 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:while/until ........OK 8 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:exception ..........OK 10 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:array .......................................OK 39 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:hash ...........................OK 27 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:iterator ...........................................................................................................OK 107 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:float ................................................................................OK 80 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:bignum ...............................OK 31 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:string & char ..............................................................OK 62 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:assignment ..........OK 10 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:call ......OK 6 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:proc .........OK 9 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:signal ..OK 2 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:eval ...........................OK 27 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:system ........OK 8 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:const .....OK 5 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:clone .....OK 5 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:marshal ....OK 4 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:pack ....OK 4 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:math ..OK 2 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:struct ......OK 6 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:variable ............OK 12 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:trace ...OK 3 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:defined? ............OK 12 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:alias ......OK 6 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:path .......................OK 23 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/basictest/test.rb:gc ....OK 4 test succeeded Run options: --seed=40591 "--ruby=./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems" # Running tests: Finished tests in 32.239231s, 9.4295 tests/s, 54.3747 assertions/s. 304 tests, 1753 assertions, 0 failures, 0 errors, 12 skips ruby -v: ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [ppc-darwin10.0.0d2] Run options: --seed=13135 "--ruby=./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems" --excludes-dir=./test/excludes --name=!/memory_leak/ # Running tests: test-script:4:in `setrlimit': Invalid argument - setrlimit (Errno::EINVAL) from test-script:4:in `<main>' test-script:4:in `setrlimit': Invalid argument - setrlimit (Errno::EINVAL) from test-script:4:in `<main>'
Need to find out what goes wrong here.
After interrupting the process, I got a long output of errors concluding with:
11212 tests, 1581830 assertions, 51 failures, 7 errors, 32 skips gmake: *** [uncommon.mk:821: yes-test-all] Error 1 Command failed: cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1" && /opt/local/bin/gmake check Killed by signal: 2 Error: Aborted: SIGINT received.
Changed 3 years ago by barracuda156
Attachment: | main_ruby31_tests.log added |
---|
Log suggests it ran quite a number of tests without showing it in verbose in real time, however towards the end CPU activity had no Ruby presence, so I concluded it froze.
comment:18 Changed 3 years ago by barracuda156
Replying to evanmiller:
When I was tinkering with Ruby on PPC, I ran into some issues with coroutines. It's possible that's the source of the hangs, but it could be something else. Try attaching to the hanging process using Sampler (found in Developer > Applications > Performance Tools). If you record a sample then you should be able to see where the process CPU time is going and maybe get a hint about what's freezing.
I have done it, but in what way I should export its output?
Besides, a basic sampling via Activity Monitor gives this:
Analysis of sampling ruby3.1 (pid 31703) every 1 millisecond Call graph: 1807 Thread_362b 1807 start 1807 main 1807 ruby_run_node 1807 rb_ec_exec_node 1807 rb_vm_exec 1807 vm_exec_core 1807 vm_sendish 1807 vm_call_cfunc_with_frame 1807 rb_require_string 1807 require_internal 1807 rb_vm_exec 1807 vm_exec_core 1807 vm_sendish 1807 vm_call_method_each_type 1807 vm_call_cfunc_with_frame 1807 rb_ary_each 1807 rb_yield 1807 vm_yield_with_cref 1807 rb_vm_exec 1807 vm_exec_core 1807 vm_sendish 1807 vm_call_method_each_type 1807 vm_call_cfunc_with_frame 1807 rb_ary_each 1807 rb_yield 1807 vm_yield_with_cref 1807 rb_vm_exec 1807 vm_exec_core 1807 vm_sendish 1807 vm_call_cfunc_with_frame 1807 rb_ary_collect 1807 rb_yield 1807 vm_yield_with_cref 1807 rb_vm_exec 1807 vm_exec_core 1807 vm_sendish 1807 vm_call_cfunc_with_frame 1807 tcp_accept 1807 rsock_s_accept 1807 rb_io_maybe_wait_readable 1807 rb_io_wait 1807 rb_thread_wait_for_single_fd 1807 rb_ensure 1807 select_single 1807 rb_thread_fd_select 1807 rb_ensure 1807 select$DARWIN_EXTSN 1807 select$DARWIN_EXTSN 1807 Thread_3703 1807 timer_pthread_fn 1807 poll$UNIX2003 1807 poll$UNIX2003 1807 Thread_3803 1807 _pthread_start 1807 coroutine_trampoline 1807 fiber_entry 1807 rb_fiber_start 1807 fiber_switch 1807 fiber_setcontext 1807 coroutine_transfer 1807 _pthread_cond_wait 1807 __semwait_signal 1807 __semwait_signal 1807 Thread_3903 1807 _pthread_start 1807 coroutine_trampoline 1807 fiber_entry 1807 rb_fiber_start 1807 fiber_switch 1807 fiber_setcontext 1807 coroutine_transfer 1807 _pthread_cond_wait 1807 __semwait_signal 1807 __semwait_signal 1807 Thread_3a03 1807 _pthread_start 1807 coroutine_trampoline 1807 fiber_entry 1807 rb_fiber_start 1807 fiber_switch 1807 fiber_setcontext 1807 coroutine_transfer 1807 _pthread_cond_wait 1807 __semwait_signal 1807 __semwait_signal 1807 Thread_3b03 1807 _pthread_start 1807 coroutine_trampoline 1807 fiber_entry 1807 rb_fiber_start 1807 fiber_switch 1807 fiber_setcontext 1807 coroutine_transfer 1807 _pthread_cond_wait 1807 __semwait_signal 1807 __semwait_signal 1807 Thread_3c03 1807 _pthread_start 1807 coroutine_trampoline 1807 fiber_entry 1807 rb_fiber_start 1807 fiber_switch 1807 fiber_setcontext 1807 coroutine_transfer 1807 _pthread_cond_wait 1807 __semwait_signal 1807 __semwait_signal Total number in stack (recursive counted multiple, when >=5): 5 __semwait_signal 5 _pthread_cond_wait 5 _pthread_start 5 coroutine_trampoline 5 coroutine_transfer 5 fiber_entry 5 fiber_setcontext 5 fiber_switch 5 rb_fiber_start 5 rb_vm_exec 5 vm_call_cfunc_with_frame 5 vm_exec_core 5 vm_sendish Sort by top of stack, same collapsed (when >= 5): __semwait_signal 9035 poll$UNIX2003 1807 select$DARWIN_EXTSN 1807
Developer sampler also specifies library, libSystem.B.dylib.
- S. Interrupting it gave this:
237) Error: TestSocket#test_accept_loop_with_unix: ArgumentError: too long unix socket path (111 bytes given but 104 bytes max) /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/.ext/common/socket.rb:1116:in `unix' /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/.ext/common/socket.rb:1116:in `unix_server_socket' /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/test/socket/test_socket.rb:259:in `block in test_accept_loop_with_unix' /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/lib/tmpdir.rb:96:in `mktmpdir' /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_ruby31/ruby31/work/ruby-3.1.1/test/socket/test_socket.rb:253:in `test_accept_loop_with_unix' Finished tests in 4677.087692s, 4.4857 tests/s, 585.4192 assertions/s. 20980 tests, 2738057 assertions, 205 failures, 32 errors, 59 skips gmake: *** [uncommon.mk:821: yes-test-all] Error 1
There are quite a number of these too long unix socket path (111 bytes given but 104 bytes max) errors. Should be fixable, for example: https://github.com/deployphp/deployer/pull/1940/commits/abb6c91232ca24cc025fa0a3ca7d0e3ec5c7ee58
comment:19 Changed 3 years ago by barracuda156
Replying to evanmiller:
I have tried to fix native coroutine, however compiler then fails on tests (earlier then before). Apparently something more is needed besides fixing register names and replacing assembler instructions. The source code isn’t complex in fact: https://github.com/ruby/ruby/blob/master/coroutine/ppc64le/Context.S
comment:20 follow-up: 22 Changed 3 years ago by kencu (Ken)
ppcle and ppc/ppc64 are very different beasties. (ppcle means Little Endian, the others are Big Endian).
There apparently is no coroutine implementation for ppc/ppc64:
https://github.com/ruby/ruby/tree/master/coroutine
So coroutines should not be used on those systems. It is optional anyway.
By default it appears that the coroutines should not be enabled on ppc*-darwin anyway:
https://github.com/ruby/ruby/blob/7172ab0ec523fd190f661f52e999307d2e34429f/configure.ac#L2253
but if somehow they are being accidentally enabled, there is a configure argument to force them to be off:
--disable-fiber-coroutine
comment:21 Changed 3 years ago by barracuda156
Replying to kencu:
Or this should work:
No idea if that’s legit, but some software uses very simple replacements like
pid_t gettid(void) { #ifdef __FreeBSD__ return (pid_t)pthread_getthreadid_np(); #elif defined(__APPLE__) #if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060) uint64_t curthreadid; pthread_threadid_np(NULL, &curthreadid); return (pid_t)curthreadid; #else /* __MAC_OS_X_VERSION_MIN_REQUIRED */ return (pid_t)pthread_self; #endif /* __MAC_OS_X_VERSION_MIN_REQUIRED */ #else /* __APPLE__*/ return (pid_t)syscall(SYS_gettid); #endif /* __FreeBSD__, __APPLE__*/ }
comment:22 Changed 3 years ago by barracuda156
Replying to kencu:
ppcle and ppc/ppc64 are very different beasties. (ppcle means Little Endian, the others are Big Endian).
I thought to try, because a) not a big deal of effort even if wasted anyway, b) some cases of code may be mostly identical (judging from examples, not from real knowledge).
There apparently is no coroutine implementation for ppc/ppc64: https://github.com/ruby/ruby/tree/master/coroutine
Yes, I know. I wanted to make it :)
So coroutines should not be used on those systems. It is optional anyway. By default it appears that the coroutines should not be enabled on ppc*-darwin anyway:
https://github.com/ruby/ruby/blob/7172ab0ec523fd190f661f52e999307d2e34429f/configure.ac#L2253
but if somehow they are being accidentally enabled, there is a configure argument to force them to be off:
--disable-fiber-coroutine
Somehow I did not find an option to turn them off completely (or maybe tried and it failed, not sure now). What I did try initially is using pthread
type coroutine, and that led to freezing in the mid of test suite (could be because my pthread
patch has an error).
I will try it now.
comment:23 Changed 2 years ago by kimuraw (kimura wataru)
[note] this issue was fixed at PR-16454 by @barracuda156 .
When I was tinkering with Ruby on PPC, I ran into some issues with coroutines. It's possible that's the source of the hangs, but it could be something else. Try attaching to the hanging process using Sampler (found in Developer > Applications > Performance Tools). If you record a sample then you should be able to see where the process CPU time is going and maybe get a hint about what's freezing.