On Wed, 2008-07-02 at 16:55 +0200, Marc Haisenko wrote:
> 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.


Good point.

> 
> 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).


Hmm, my case is that: I'm running a biarch system here (64-bit kernel,
with mixed 32- and 64-bit apps), so my compiler defaults to 32-bit
generated objects (if I ever want to compile something for 64-bit, I
need to provide the '-m64' flag). As a part of my job, I need to
guarantee that some apps correctly compile over PPC *and* PPC64, that's
why I need to switch between '-m32' and '-m64'. Therefore, I myself will
provide those flags to the build system, and that's the reason why I
don't want it to assume anything about bitness :-)

> 
> > 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:

Thanks a lot for this code. I'll try to modify it to fit my needs :-) .

Regards,

-- 
S?rgio Durigan J?nior
Linux on Power Toolchain - Software Engineer
Linux Technology Center - LTC
IBM Brazil