Bug 242630 - [PowerPC] lang/ruby26 build fails on rb_mjit_min_header-2.6.5.h (FreeBSD 12.1-RELEASE-p1)
Summary: [PowerPC] lang/ruby26 build fails on rb_mjit_min_header-2.6.5.h (FreeBSD 12.1...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: powerpc Any
: --- Affects Only Me
Assignee: freebsd-ruby (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-14 09:57 UTC by canardo
Modified: 2020-01-31 16:32 UTC (History)
6 users (show)

See Also:
bugzilla: maintainer-feedback? (ruby)


Attachments
poudriere log (21.15 KB, application/x-xz)
2019-12-14 17:11 UTC, Piotr Kubaj
no flags Details
Log file (73.61 KB, text/plain)
2019-12-27 20:43 UTC, Tibikuera
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description canardo 2019-12-14 09:57:57 UTC
Problem found when building lang/ruby26 on FreeBSD 12.1-RELEASE-p1 powerpc.


# cd /usr/ports/lang/ruby26
# make install config
===>  Building for ruby-2.6.5,1
	BASERUBY = echo executable host ruby is required.  use --with-baseruby option.; false
	CC = gcc9
	LD = /usr/local/bin/ld
	LDSHARED = gcc9 -shared
	CFLAGS = -O2 -pipe  -fstack-protector-strong -Wl,-rpath=/usr/local/lib/gcc9 -isystem /usr/local/include -fno-strict-aliasing  -fPIC 
	XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -DCANONICALIZATION_FOR_MATHN
	CPPFLAGS = -I/usr/local/include -isystem /usr/local/include   -I. -I.ext/include/powerpc-freebsd12 -I./include -I. -I./enc/unicode/12.1.0 
	DLDFLAGS = -fstack-protector-strong -Wl,-rpath=/usr/local/lib/gcc9 -L/usr/local/lib/gcc9  -Wl,--compress-debug-sections=zlib -Wl,-E -Wl,-soname,libruby26.so.26 -fstack-protector-strong  
	SOLIBS = -lexecinfo -lprocstat -lz -lthr -lrt -lrt -ldl -lcrypt -lm -lpthread -L/usr/local/lib -L/usr/local/lib
	LANG = C
	LC_ALL = C
	LC_CTYPE = 
gcc9 (FreeBSD Ports Collection) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

building .ext/include/powerpc-freebsd12/rb_mjit_min_header-2.6.5.h
./miniruby -I./lib -I. -I.ext/common  ./tool/transform_mjit_header.rb "gcc9 " rb_mjit_header.h .ext/include/powerpc-freebsd12/rb_mjit_min_header-2.6.5.h
*** Signal 11

Stop.
make[2]: stopped in /usr/ports/lang/ruby26/work/ruby-2.6.5
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/lang/ruby26
*** Error code 1

Stop.
make: stopped in /usr/ports/lang/ruby26



Hardware used is a Apple Powerbook G4 17", and ruby26 is a requirement to install gnome3.
Comment 1 Piotr Kubaj freebsd_committer 2019-12-14 17:11:14 UTC
Created attachment 209946 [details]
poudriere log

It's probably your setup. I built ruby26 recently on 12.1-RELEASE.
Comment 2 canardo 2019-12-14 20:44:00 UTC
Build is successful in your log, indeed.

But as far as I can see, you're building on powerpc64
ARCH=powerpc64
and
checking whether we are cross compiling... no

The problem I get is on powerpc (the 32bits version).

Could you please check if it also works for you on powerpc 32bits arch ?
Comment 3 Tibikuera 2019-12-16 21:49:51 UTC
(In reply to canardo from comment #0)
I had the same output as canardo. My machine is a powerpc 32-bit.
Comment 4 Tibikuera 2019-12-27 20:43:18 UTC
Created attachment 210265 [details]
Log file
Comment 5 Tibikuera 2019-12-27 20:47:39 UTC
I installed ruby-build port and attempted to install ruby 2.6.5 with it and got the following:

root@machine:~ # rbenv install 2.6.5
Downloading ruby-2.6.5.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.5.tar.bz2
Installing ruby-2.6.5...

BUILD FAILED (FreeBSD 12.1-RELEASE using ruby-build 20191205)

Inspect or clean up the working tree at /tmp/ruby-build.20191225171610.23660.WmQdcU
Results logged to /tmp/ruby-build.20191225171610.23660.log

Last 10 log lines:
gmake[1]: Entering directory '/tmp/ruby-build.20191225171610.23660.WmQdcU/ruby-2.6.5'
gmake[2]: Entering directory '/tmp/ruby-build.20191225171610.23660.WmQdcU/ruby-2.6.5/ext/-test-/arith_seq/extract'
compiling extract.c
linking shared-object -test-/arith_seq/extract.so
../../../../libruby.so: file not recognized: File format not recognized
gmake[2]: *** [Makefile:267: ../../../../.ext/powerpc-freebsd12.1/-test-/arith_seq/extract.so] Error 1
gmake[2]: Leaving directory '/tmp/ruby-build.20191225171610.23660.WmQdcU/ruby-2.6.5/ext/-test-/arith_seq/extract'
gmake[1]: *** [exts.mk:91: ext/-test-/arith_seq/extract/all] Error 2
gmake[1]: Leaving directory '/tmp/ruby-build.20191225171610.23660.WmQdcU/ruby-2.6.5'
gmake: *** [uncommon.mk:286: build-ext] Error 2
root@machine:~ # 

In addition, I added a log file here (attachment 210265 [details]).
Comment 6 lfmorrison 2019-12-28 13:36:55 UTC
I duplicated the same results attempting to build ruby26 on FreeBSD 12.1 powerpc 32-bit. Also saw similar failures with ruby25 and ruby24.

I can also confirm that ruby-build failed for 2.6.5 and 2.5.7 with some sort of linker error. (Maybe because it's trying to use the base binutils but it has a dependency on the newer binutils from ports?)
Comment 7 Tibikuera 2019-12-29 22:45:02 UTC
(In reply to Tibikuera from comment #3)

I ended up trying the following (as suggested in the web page http://www.bitwizard.nl/sig11/) and since after the "dd" command it did stop at the same place, this is not supposed to be a hardware issue:

"First lets make sure it is the hardware that is causing your trouble. When the "make" stops, simply type "make" again. If it compiles a few more files before stopping, it must be hardware that is causing you troubles. If it immediately stops again (i.e. scans a few directories with "nothing to be done for xxxx" before bombing at exactly the same place), try

   dd if=/dev/HARD_DISK of=/dev/null bs=1024k count=MEGS

Change HARD_DISK to "hda" to the name of your harddisk (e.g. hda or sda. Or use "df ."). Change the MEGS to the number of megabytes of main memory that you have. This will cause the first several megabytes of your harddisk to be read from disk, forcing the C source files and the gcc binary to be reread from disk the next time you run it. Now type make again. If it still stops in the same place I'm starting to wonder if you're reading the right FAQ, as it is starting to look like a software problem after all.... Take a peek at the "what are the other possibilities" question..... If without this "dd" command the compiler keeps on stopping at the same place, but moves to another place after you use the "dd" you definitely have a disk->ram transfer problem."
Comment 8 Nuno Vasconcellos 2019-12-31 00:39:18 UTC
cd /usr/ports/lang/ruby26
make clean
make USE_GCC=4.2 install

I hope this helps.
Comment 9 lfmorrison 2020-01-02 12:58:37 UTC
Thanks; after switching to the base system compiler gcc42, ruby26 builds successfully and a few trivial test cases show that it seems to be functional.

So it looks like this might be related to some sort of bad interaction between ruby26 and gcc9 for 32-bit powerpc.
Comment 10 commit-hook freebsd_committer 2020-01-02 16:37:56 UTC
A commit references this bug:

Author: pkubaj
Date: Thu Jan  2 16:37:12 UTC 2020
New revision: 521857
URL: https://svnweb.freebsd.org/changeset/ports/521857

Log:
  lang/ruby26: fix build on powerpc, don't use GCC on powerpc64 elfv2

  ruby currently has issues when compiling on powerpc with gcc9. Use base GCC instead.

  Also don't use GCC on powerpc64 elfv2, builds fine with clang.

  PR:		242630
  Submitted by:	nunovasconcellos@gmail.com
  Reported by:	canardo909@gmx.com
  Approved by:	portmgr (build fix blanket)

Changes:
  head/lang/ruby26/Makefile
Comment 11 Piotr Kubaj freebsd_committer 2020-01-02 16:41:52 UTC
This should now build.
Comment 12 Mark Millard 2020-01-05 23:26:23 UTC
(In reply to commit-hook from comment #10)

Context: cross building via ports-mgmt/poudriere-devel
on an old PowerMac G5. As seen from inside a jail for
the 32-bit powerpc world area poudriere uses:

JAILNAME      VERSION      ARCH              METHOD TIMESTAMP           PATH
FBSDpowerpc   13.0-CURRENT powerpc           null   2019-12-31 01:21:28 /usr/obj/DESTDIRs/clang-powerpc-installworld-poud

Based on -r522079 of ports in a head -r356187
based context (both the G5 and the system in
clang-powerpc-installworld-poud):

. . . (through linking miniruby) . . .
building .ext/include/powerpc-freebsd13/rb_mjit_min_header-2.6.5.h
./miniruby -I./lib -I. -I.ext/common  ./tool/transform_mjit_header.rb "cc " rb_mjit_header.h .ext/include/powerpc-freebsd13/rb_mjit_min_header-2.6.5.h
*** Signal 6

Stop.
make[1]: stopped in /wrkdirs/usr/ports/lang/ruby26/work/ruby-2.6.5
*** Error code 1

In other words: the miniruby that it built crashes when it
is then used.

The backtrace shows a __stack_chk_fail during rb_vm_exec:

Program terminated with signal SIGABRT, Aborted.
#0  kill () at kill.S:4
4	kill.S: No such file or directory.
(gdb) bt
#0  kill () at kill.S:4
#1  0x41d7f648 in __fail (msg=<optimized out>) at /usr/src/lib/libc/secure/stack_protector.c:128
#2  0x41d7f598 in __stack_chk_fail () at /usr/src/lib/libc/secure/stack_protector.c:135
#3  0x01a25dac in rb_vm_exec (ec=0x41f51028, mjit_enable_p=1) at vm.c:1903
#4  0x01a25fa8 in rb_iseq_eval (iseq=0x41fe0890) at vm.c:2133
#5  0x018f2554 in rb_load_internal0 (ec=0x41f51028, fname=<optimized out>, wrap=<optimized out>) at load.c:612
#6  0x018f3230 in rb_require_internal (fname=<optimized out>, safe=0) at load.c:1029
#7  0x018f272c in rb_require_safe (fname=1107240840, safe=<optimized out>) at load.c:1075
#8  rb_f_require (obj=<optimized out>, fname=1107240840) at load.c:821
#9  0x01a31938 in call_cfunc_1 (func=<optimized out>, recv=<optimized out>, argc=<optimized out>, argv=<optimized out>) at ./vm_insnhelper.c:1755
#10 0x01a2b0e0 in vm_call_cfunc_with_frame (ec=0x41f51028, reg_cfp=0x41fdb708, calling=<optimized out>, ci=0x442d3500, cc=<optimized out>) at ./vm_insnhelper.c:1908
#11 vm_call_cfunc (ec=0x41f51028, reg_cfp=0x41fdb708, calling=<optimized out>, ci=0x442d3500, cc=<optimized out>) at ./vm_insnhelper.c:1924
#12 0x01a2a00c in vm_call_method_each_type (ec=<optimized out>, cfp=<optimized out>, calling=<optimized out>, ci=<optimized out>, cc=<optimized out>) at ./vm_insnhelper.c:2245
#13 0x01a29e40 in vm_call_method (ec=0x41f51028, cfp=0x41fdb708, calling=0xffffce20, ci=0x442d3500, cc=0x44348000) at ./vm_insnhelper.c:2400
#14 0x01a10384 in vm_call_general (ec=<optimized out>, reg_cfp=<optimized out>, calling=<optimized out>, ci=<optimized out>, cc=<optimized out>) at ./vm_insnhelper.c:2417
#15 0x01a1337c in vm_exec_core (ec=0x41f51028, initial=<optimized out>) at insns.def:765
#16 0x01a25cb8 in rb_vm_exec (ec=0x41f51028, mjit_enable_p=1) at vm.c:2104
#17 0x01a260d8 in rb_iseq_eval_main (iseq=<optimized out>) at vm.c:2144
#18 0x0189b2c4 in ruby_exec_internal (n=0x41ff8080) at eval.c:262
#19 ruby_exec_node (n=<optimized out>) at eval.c:326
#20 0x0189b0d4 in ruby_run_node (n=<optimized out>) at eval.c:318
#21 0x018146ec in main (argc=<optimized out>, argv=<optimized out>) at ./main.c:42
Comment 13 lfmorrison 2020-01-16 22:14:54 UTC
Commit 522532 broke ruby26 on 12.1-RELEASE for 32-bit powerpc again.

How about "USES_GCC= 4.2+"

That ought to allow base gcc to be used on 12.1 (where it works), but on 13.0, where GCC isn't included in base it would force the use of gcc9 from ports instead.
Comment 14 commit-hook freebsd_committer 2020-01-31 16:32:38 UTC
A commit references this bug:

Author: pkubaj
Date: Fri Jan 31 16:32:18 UTC 2020
New revision: 524729
URL: https://svnweb.freebsd.org/changeset/ports/524729

Log:
  lang/ruby26: fix build on 12

  Use GCC9 only on head, ruby fails to build otherwise.

  PR:		242630
  Reported by:	lfmorrison@gmail.com

Changes:
  head/lang/ruby26/Makefile