Opened 10 years ago

Closed 10 years ago

#44508 closed defect (fixed)

ruby21: fix compilation with libffi (*3.1!) so that module fiddle works

Reported by: jf (Jeffrey 'jf' Lim) Owned by: kimuraw (kimura wataru)
Priority: Normal Milestone:
Component: ports Version: 2.3.1
Keywords: Cc:
Port: ruby21

Description

To confirm:

ruby2.1 -e 'p require "fiddle"'

Correctly configured and compiled, the output should be

true

NOTE: this patch is only for libffi 3.1, and should be removed once libffi goes to 3 numbers in its version. It is, of course best fixed upstream, and I will deal with that and report back once it's solved there. Until then, this patch will fix things.

--- ext/fiddle/extconf.rb.orig	2013-05-19 10:42:16.000000000 +0800
+++ ext/fiddle/extconf.rb	2014-07-31 16:26:56.000000000 +0800
@@ -7,7 +7,7 @@
 pkg_config("libffi")
 if ver = pkg_config("libffi", "modversion")
   ver = ver.gsub(/-rc\d+/, '') # If ver contains rc version, just ignored.
-  $defs.push(%{-DRUBY_LIBFFI_MODVERSION=#{ '%d%03d%03d' % ver.split('.') }})
+  $defs.push(%{-DRUBY_LIBFFI_MODVERSION=#{ '%d%03d' % ver.split('.') }})
 end
 
 unless have_header('ffi.h')

Change History (5)

comment:1 Changed 10 years ago by jf (Jeffrey 'jf' Lim)

Ok sorry, the patch should be this instead (ext/fiddle/closure.c relies on RUBY_LIBFFI_MODVERSION being generated off of a 3-digit 'ver')!

--- ext/fiddle/extconf.rb.orig	2013-05-19 10:42:16.000000000 +0800
+++ ext/fiddle/extconf.rb	2014-07-31 23:39:34.000000000 +0800
@@ -7,7 +7,9 @@
 pkg_config("libffi")
 if ver = pkg_config("libffi", "modversion")
   ver = ver.gsub(/-rc\d+/, '') # If ver contains rc version, just ignored.
-  $defs.push(%{-DRUBY_LIBFFI_MODVERSION=#{ '%d%03d%03d' % ver.split('.') }})
+  ver_split = ver.split('.')
+  ver_split.push '0' if ver_split.length == 2
+  $defs.push(%{-DRUBY_LIBFFI_MODVERSION=#{ '%d%03d%03d' % ver_split }})
 end
 
 unless have_header('ffi.h')

comment:2 Changed 10 years ago by ryandesign (Ryan Carsten Schmidt)

Owner: changed from macports-tickets@… to kimuraw@…
Port: ruby21 added

comment:3 Changed 10 years ago by kimuraw (kimura wataru)

Port: ruby20 added
Status: newassigned

Thanks!

ruby-2.1 branch was fixed this problem at https://bugs.ruby-lang.org/projects/ruby-21/repository/revisions/46609. I'll apply this change.

note: upstream ruby filed this problem as http://bugs.ruby-lang.org/issues/9897. ruby-2.0 has same problem.

comment:4 Changed 10 years ago by jf (Jeffrey 'jf' Lim)

Sure. I realized that myself after some time.... That patch will take care of libffi versions with just 1 number (?), as well as 2.

Last edited 10 years ago by jf (Jeffrey 'jf' Lim) (previous) (diff)

comment:5 Changed 10 years ago by kimuraw (kimura wataru)

Port: ruby20 removed
Resolution: fixed
Status: assignedclosed

fixed at r122863.

my misunderstanding, ruby2.0 does not have this problem.

Note: See TracTickets for help on using tickets.