[DRE-maint] Bug#1018230: mkmf.rb's pkg_config function does not work for cross compilation

Helmut Grohne helmut at subdivi.de
Sat Aug 27 13:54:41 BST 2022


Package: libruby3.0
Version: 3.0.4-7+b1
File: /usr/lib/ruby/3.0.0/mkmf.rb
User: debian-cross at lists.debian.org
Usertags: ftcbfs
X-Debbugs-Cc: debian-cross at lists.debian.org
Control: affects -1 + src:ruby-augeas

Hi Antonio et al,

during DebConf22, Antonio made cross building ruby extensions work.
That's awesome. It also means that we can not start looking into issues
further down in that stack.

ruby-augeas fails to cross build. It use pkg-config via the pkg_config
function from mkmf.rb. This function happens to use the build
architecture pkg-config and thus fails finding the requested packages
(which happen to only be installed for the host architecture). This is
not an issue in ruby-augeas, but an issue in mkmf.rb aka libruby3.0 and
it will affect many source packages.

Relevant code at:
https://sources.debian.org/src/ruby3.0/3.0.4-7/lib/mkmf.rb/#L1822

For some reason, this function says that if we are cross compiling,
pkg-config doesn't work. While that used to be true, it is not on Debian
since quite a while. We should do something like:

-           (pkgconfig = with_config("pkg-config", ("pkg-config" unless CROSS_COMPILING))) &&
+           (pkgconfig = with_config("pkg-config", CROSS_COMPILING ? "#{DEB_HOST_GNU_TYPE}-pkg-config" : "pkg-config")) &&

Unfortunately, DEB_HOST_GNU_TYPE doesn't exist as a ruby variable here.
It probably needs to come from the host architecture's rbconfig.rb. I
checked and unfortunately, rbconfig.rb doesn't have any variable that
would know the right value. It has CONFIG['arch'], which is more like
DEB_HOST_MULTIARCH (and that happens to be correct everywhere except
any-i386). It also has CC valued "#{DEB_HOST_GNU_TYPE}-gcc" and we may
be able to dissect that.

I think the best solution here would be adding CONFIG['PKG_CONFIG'] to
rbconfig.rb and using that. I happen to not know how to implement that.
Does the approach sound reasonable? Would it be upstreamable?

Helmut



More information about the Pkg-ruby-extras-maintainers mailing list