[ruby-core:66668] Re: setarch i686 bash -c ' [ $( ruby -e 'print RUBY_PLATFORM' ) == x86_64_linux ] '-> TRUE (0) - would expect platform to be i386_linux

From: Tanaka Akira <akr@...>
Date: 2014-12-04 00:26:23 UTC
List: ruby-core #66668
2014-12-04 0:18 GMT+09:00 Jason Vas Dias <jason.vas.dias@gmail.com>:

> Couldn't ruby use the uname() system call and if i686 is reported as
> 'machine', then check if /usr/lib/ruby/i386_linux exists, and if so, return
> i686 as 'RUBY_PLATFORM' and use that directory as the arch-specific
> dependency directory .

Ruby binary uses architecture dependent data types (64 bit ruby uses
64 bit pointers).
So extension libraries, such as socket.so, should be compiled with
same data types.

setarch cannot change data types.
So, Ruby's library search path is not changable using setarch.

> In perl, POSIX::uname() correctly reports 'i686' as the machine on
> an x86_64 platform in a sub-process of 'setarch i686' . Why can't Ruby
> be a bit more intelligent in the platform it reports ?
> Is this a bug or new feature request ? Any votes / ideas ?

setarch doesn't change data types used for perl binary too.
I don't think 64 bit perl can use 32 bit libraries.

Note that Ruby 2.2 will have Etc.uname method.
Of course, it doesn't change library path.

% ./ruby -retc -e 'p Etc.uname[:machine]'
"x86_64"
% setarch i686 ./ruby -retc -e 'p Etc.uname[:machine]'
"i686"
-- 
Tanaka Akira

In This Thread

Prev Next