Bug 241633 - devel/ruby-build: 20191030 or later cannot build MRI
Summary: devel/ruby-build: 20191030 or later cannot build MRI
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Koichiro Iwao
URL: https://bugs.ruby-lang.org/issues/16331
Depends on:
Reported: 2019-11-01 05:31 UTC by Koichiro Iwao
Modified: 2019-11-19 02:47 UTC (History)
2 users (show)

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

ruby-build.patch (355 bytes, patch)
2019-11-06 01:22 UTC, Yuichiro NAITO
no flags Details | Diff
whole-ruby-build-log.log (37.92 KB, text/plain)
2019-11-06 02:14 UTC, Koichiro Iwao
no flags Details
ruby-build-use-gmake (1.96 KB, patch)
2019-11-07 02:41 UTC, Koichiro Iwao
no flags Details | Diff
Makefile.in.patch (556 bytes, patch)
2019-11-08 03:21 UTC, Yuichiro NAITO
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Koichiro Iwao freebsd_committer 2019-11-01 05:31:29 UTC

devel/ruby-build has not been updated to 20191030 but I'm trying to update it.

Release note: https://github.com/rbenv/ruby-build/releases/tag/v20191030

20191030 fails to build Ruby. This might be caused by recent change of ruby-build.

compiling ./enc/iso_8859_13.c
--- trans ---
ld: error: unable to find library -lruby
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** [.ext/x86_64-freebsd12.1/enc/trans/transdb.so] Error code 1

make[1]: stopped in /tmp/ruby-build.20191101142002.24843/ruby-2.6.4
1 error

make[1]: stopped in /tmp/ruby-build.20191101142002.24843/ruby-2.6.4
*** [trans] Error code 2

make: stopped in /tmp/ruby-build.20191101142002.24843/ruby-2.6.4
--- enc ---
A failure has been detected in another branch of the parallel make

make[1]: stopped in /tmp/ruby-build.20191101142002.24843/ruby-2.6.4
*** [enc] Error code 2

make: stopped in /tmp/ruby-build.20191101142002.24843/ruby-2.6.4
--- .ext/include/x86_64-freebsd12.1/rb_mjit_min_header-2.6.4.h ---

To record what I investigated and tried to fix it, I created this bug.
Comment 1 commit-hook freebsd_committer 2019-11-05 00:54:51 UTC
A commit references this bug:

Author: meta
Date: Tue Nov  5 00:53:50 UTC 2019
New revision: 516763
URL: https://svnweb.freebsd.org/changeset/ports/516763

  devel/ruby-build: add a comment that mention bug 241633

  PR:		241633

Comment 2 Yuichiro NAITO 2019-11-06 01:22:19 UTC
Created attachment 208899 [details]
Comment 3 Yuichiro NAITO 2019-11-06 01:24:00 UTC
I see same problem on my FreeBSD 12.1R machine with the latest ruby-build
from GitHub. `rbenv install 2.6.[54]` fails as same as this PR.

For a quick work around, `ruby-build.patch` fixes this problem and
ruby 2.6.5 is build successfully.
But I don't understand why this patch works for now.

It seems BSD make's problem but compiling Ruby from tarball with BSD make
was succeeded.
Comment 4 Yuichiro NAITO 2019-11-06 01:27:36 UTC
I see same result on FreeBSD CURRENT r354344.
Comment 5 Koichiro Iwao freebsd_committer 2019-11-06 02:09:14 UTC
(In reply to Yuichiro NAITO from comment #3)
Above that block, it appears that ruby-build determiniing FreeBSD or not.

I confirmed using gmake can build Ruby successfully. However, lang/ruby2[456] is built by /usr/bin/make with --enable-shared. I'm trying to find out why ruby-build + --enable-shared + /usr/bin/make fails.
Comment 6 Koichiro Iwao freebsd_committer 2019-11-06 02:14:59 UTC
Created attachment 208900 [details]
Comment 7 Yuichiro NAITO 2019-11-07 01:59:28 UTC
I think it's kind of race condition.
BSD make with parallel build fails and BSD make with single job builds successfully.
I think GNU make has different job scheduling from BSD make.
One of these will solve this PR.

1. use BSD make with -j 1
2. use GNU make
3. fix dependencies in Ruby's Makefile
Comment 8 Koichiro Iwao freebsd_committer 2019-11-07 02:15:55 UTC
(In reply to Yuichiro NAITO from comment #7)

I'm inclined to choose 2. 3 would be a best but it doesn't take effect on past released Ruby. 1 makes build slower.
Comment 9 Koichiro Iwao freebsd_committer 2019-11-07 02:41:30 UTC
Created attachment 208930 [details]

As workaround, use gmake. I'll report to Ruby and ruby-build upstream later.
Comment 10 Koichiro Iwao freebsd_committer 2019-11-07 13:04:45 UTC
Reported to Ruby upstream.
Comment 11 commit-hook freebsd_committer 2019-11-07 13:07:21 UTC
A commit references this bug:

Author: meta
Date: Thu Nov  7 13:06:35 UTC 2019
New revision: 516970
URL: https://svnweb.freebsd.org/changeset/ports/516970

  devel/ruby-build: Update to 20191030

  and use GNU make when building Ruby to avoid Ruby build failure.

  PR:		241633
  Submitted by:	Yuichiro NAITO <naito.yuichiro@gmail.com>, myself
  Sponsored by:	HAW International, Inc.

Comment 12 Koichiro Iwao freebsd_committer 2019-11-07 13:24:02 UTC
Committed workaround, thanks!
Comment 13 Yuichiro NAITO 2019-11-08 03:20:45 UTC
In my investigation, There are two reasons about ruby build failure.

  It seems that it is not intended to call $(PRE_LIBRARY_UPDATE) in Ruby's Makefile,
  when libruby.so.26 is built.
  Comparing to libruby-static library build,
  Ruby's Makefile should be fixed like `Makefile.in.patch`.

  If $(PRE_LIBRARY_UPDATE) is not called, the build finished successfully.

  $(PRE_LIBRARY_UPDATE) expands to "[ -n '' ] || exec rm -f ./.libruby-with-ext.time".
  The 'exec' behavior is different between with and without -j option in BSD make.

  With -j option, following commands after 'exec rm' are not executed.
  So libruby.so.26 is not build.
  Without -j option, following commands after 'exec rm' are executed normally.

  I'm not sure this behavior is a bug of BSD make.
  But it's enough to confuse me.
Comment 14 Yuichiro NAITO 2019-11-08 03:21:26 UTC
Created attachment 208958 [details]
Comment 15 Koichiro Iwao freebsd_committer 2019-11-08 09:57:09 UTC
If this issue is fixed in upstream, MAKE_JOBS_UNSAFE=yes in lang/ruby2[456] ports   should be removed and can be built parallely.
Comment 16 Koichiro Iwao freebsd_committer 2019-11-19 02:47:36 UTC
Fixed in Ruby upstream: https://bugs.ruby-lang.org/issues/16331