On Wednesday 02 July 2008, S?rgio Durigan J?nior wrote:
> Hello all,
>
> I'm trying to compile the package 'eruby', and it uses its own
> autoconf.rb and configure.rb. Well, the thing is that its configure.rb
> uses the 'mkmf' package, which is getting some "environment variables"
> that I think are wrong. Take a look at the CFLAGS that it has got:
>
> CFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
> -fstack-protector --param=ssp-buffer-size=4 -m64 -mminimal-toc -Wall
> -fPIC -Wall -m64    -DLINUX=2 -    D_REENTRANT -D_GNU_SOURCE
> -D_LARGEFILE64_SOURCE -pthread -I. -I$(hdrdir) $(APACHE_INCLUDES)
> $(LIBAPREQ_INCLUDES)
>
> Honestly, I don't think the '-m64' flag belongs there because it should
> somehow "trust" in the compiler bitness and assume that it will generate
> executable files with XX bits (being XX the bitness of the archtecture).
> Also, if the user specify its own CFLAGS, it can occur an inconsistency
> because of that choice made by mkmf (for example, if the user specified
> '-m32' in this case).

Not quite: if Ruby is compiled with -m64 and you compile your extension 
with -m32 I don't think it will load.

That being said, I also miss not being able to override mkmf.rb's values. It's 
a pain e.g. on OpenSolaris where the values can be problematic (e.g. CC 
pointing to some compiler I don't have).

> So, I'd like to know if this is really a misbehaviour of mkmf. Also, if
> you could please explain the exact place from where mkmf takes those
> flags, I'd appreciate too. It's kind of confusing, at least for me.

/usr/lib/ruby/1.8/$HOSTTYPE-linux/rbconfig.rb

I managed to get the ncurses-ruby extension to compile on OpenSolaris 2008.5 
with this nasty little wrapper:

===[snip]===
require 'mkmf'
Config::CONFIG['CC']='/opt/SunStudioExpress/bin/cc'
Config::MAKEFILE_CONFIG['CC']='/opt/SunStudioExpress/bin/cc'
Config::CONFIG['CPP']='/opt/SunStudioExpress/bin/cc -E'
$INCFLAGS="-I/opt/sfw/include/ncurses -I/opt/sfw/include -I#{Dir.glob '/usr/ruby/1.8/lib/ruby/1.8/*solaris*'}"
$LDFLAGS='-L/opt/sfw/lib -R/opt/sfw/lib -L/usr/ruby/1.8/lib -R/usr/ruby/1.8/lib /opt/sfw/lib/libpanel.so'
Config::MAKEFILE_CONFIG['INSTALL']=nil
eval File.read('./extconf.rb')
===[/snip]===

Yes, it makes your eyes bleed but it works ;-)

Bye,
	Marc


-- 
Marc Haisenko

Comdasys AG
R?desheimer Str. 7
80686 M?nchen
Germany

Tel.: +49 (0)89 548 433 321