0
votes

I built Ruby 1.9.2-p320 on Fedora 16 with a vanilla ./configure command, installing in /usr/local

The include files are in /usr/local/include/ruby-1.9.1

This program says "no":

require 'mkmf'
puts have_func('rb_thread_blocking_region') ? "yes" : "no"

I think it's because the command-line to build conftest.c to see if rb_thread_blocking_region exists doesn't include a -I path to the various directories under /usr/local/include/ruby-1.9.1, so the build fails. I'm not sure though, because mkmf uses a custom logger, and anytime I try to add $stderr.puts statements to some of the methods, I either don't see output, or I get that error message telling me I need to install development tools. I'm on linux with a lot of dev tools in place, plus Ruby source, but if someone could tell me how to dump the headers variable in the try_func method that might be helpful.

The weird thing is I had no trouble building other binary gems up to now, including RMagick, but I'm stuck on mysql2, as it thinks that rb_thread_blocking_region doesn't exist, so it generates incorrect code.

Digging in a bit more, I can compile this program with the appropriate -I options, so rb_thread_blocking_region definitely exists.

$ cat conftest.c 
#include "ruby.h"
int main(int argc, char **argv) { return 1; }

int t() {
  void ((*volatile p)());
  p = (void ((*)())) rb_thread_blocking_region;
  return 0;
}

Ahh, here's the problem, from mkmf.log:

"gcc -o conftest -I/usr/local/include/ruby-1.9.1/i686-linux 
    -I/usr/local/include/ruby-1.9.1/ruby/backward  
    -I/usr/local/include/ruby-1.9.1 -I.  
    -I/usr/local/include/ruby-1.9.1/  -D_FILE_OFFSET_BITS=64    
    -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses  
    -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers  
    -Wno-long-long conftest.c  -L. -L/usr/local/lib -Wl,-R/usr/local/lib  
    -L.  -rdynamic -Wl,-export-dynamic     -Wl,-R -Wl,/usr/local/lib  
    -L/usr/local/lib -lruby-static  -lpthread -lrt -ldl -lcrypt -lm   -lc"
/usr/lib/gcc/i686-redhat-linux/4.6.3/../../../libcrypt.a(md5-crypt.o):  
    In function `__md5_crypt_r':
(.text+0x96): undefined reference to `NSSLOW_Init'
/usr/lib/gcc/i686-redhat-linux/4.6.3/../../../libcrypt.a(md5-crypt.o):  
    In function `__md5_crypt_r':

I should've thought of that -- the crypt and openssl libraries have been a hassle on Fedora.

1
I think you should be able to provide optional include dirs to the install procedure with something like gem install mysql2 -- --with-opt-include=/usr/local/include/ruby-1.9.1.Casper
Thanks, but that didn't work. I was able to build/install a local gem (0.2.11), but the gem was broken. mysql2.rb requires 'mysql2/mysql2.rb', which doesn't exist. I removed the gem, and running the suggested command resulted in the same problem: "checking for rb_thread_blocking_region()... no"Eric
You say you can build conftest with the appropriate options. What are the appropriate options you're using? Also isn't there an mkmf.log somewhere?Casper
I can build conftest with -I's pointing to the two ruby include dir's, no big deal. I'm trying to understand why mkmf is failing by echoing the command used to build conftest. How do I use the logger for that?Eric
Aren't you getting any errors when you install the gem? In most cases any error condition leaves behind a log files named mkmf.log. That's where all the output goes. Read your error message, in all cases I've seen it even tells you that you should read mkmf.log, and it tells you where the file is.Casper

1 Answers

-1
votes

Answer found by looking in mkmf.log. Still not working, but that's another problem.