[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Looking for minimalist ruby.

Alex Young

6/22/2007 6:44:00 AM

soliton wrote:
> Does any body know if there is ruby binary not greater than 1MB? It
> would be
> better if smaller, because it would be implemented in space constraint
> application like embedded linux system. TIA
>
$ cd ruby-1.8.6/
$ ./configure
...
$ make
...
$ ls -lh ruby
-rwxr-xr-x 1 alex alex 1.6M 2007-06-22 07:43 ruby
$ strip ruby
$ ls -lh ruby
-rwxr-xr-x 1 alex alex 657K 2007-06-22 07:41 ruby

Mind you, that's without any extensions.

--
Alex

10 Answers

M. Edward (Ed) Borasky

6/22/2007 2:13:00 PM

0

Alex Young wrote:
> soliton wrote:
>> Does any body know if there is ruby binary not greater than 1MB? It
>> would be
>> better if smaller, because it would be implemented in space constraint
>> application like embedded linux system. TIA
>>
> $ cd ruby-1.8.6/
> $ ./configure
> ...
> $ make
> ...
> $ ls -lh ruby
> -rwxr-xr-x 1 alex alex 1.6M 2007-06-22 07:43 ruby
> $ strip ruby
> $ ls -lh ruby
> -rwxr-xr-x 1 alex alex 657K 2007-06-22 07:41 ruby
>
> Mind you, that's without any extensions.
>

There's another trick you can try -- before the ./configure, type

export CFLAGS="-Os -fomit-frame-pointer"

This will optimize for space rather than speed and eliminate frame pointers.

Alex Young

6/22/2007 3:26:00 PM

0

M. Edward (Ed) Borasky wrote:
> Alex Young wrote:
>> soliton wrote:
>>> Does any body know if there is ruby binary not greater than 1MB? It
>>> would be
>>> better if smaller, because it would be implemented in space constraint
>>> application like embedded linux system. TIA
>>>
>> $ cd ruby-1.8.6/
>> $ ./configure
>> ...
>> $ make
>> ...
>> $ ls -lh ruby
>> -rwxr-xr-x 1 alex alex 1.6M 2007-06-22 07:43 ruby
>> $ strip ruby
>> $ ls -lh ruby
>> -rwxr-xr-x 1 alex alex 657K 2007-06-22 07:41 ruby
>>
>> Mind you, that's without any extensions.
>>
>
> There's another trick you can try -- before the ./configure, type
>
> export CFLAGS="-Os -fomit-frame-pointer"
>
> This will optimize for space rather than speed and eliminate frame pointers.
>
I get this:

gcc -Os -fomit-frame-pointer -DRUBY_EXPORT -rdynamic
-Wl,-export-dynamic -L. main.o libruby-static.a -ldl -lcrypt -lm -o
miniruby
/lib/fileutils.rb:1206: [BUG] Segmentation fault
ruby 1.8.6 (2007-03-13) [i686-linux]

make: *** [.rbconfig.time] Aborted

when I use those options.

--
Alex

Andrew Thompson

6/22/2007 10:23:00 PM

0

Alex Young wrote:
> I get this:
>
> gcc -Os -fomit-frame-pointer -DRUBY_EXPORT -rdynamic
> -Wl,-export-dynamic -L. main.o libruby-static.a -ldl -lcrypt -lm -o
> miniruby
> ./lib/fileutils.rb:1206: [BUG] Segmentation fault
> ruby 1.8.6 (2007-03-13) [i686-linux]
>
> make: *** [.rbconfig.time] Aborted
>
> when I use those options.

I think ruby *really* doesn't like to be built with optimizations. I
believe the garbage collector in particular has problems with it.

Andrew


--
Posted via http://www.ruby-....

Nobuyoshi Nakada

6/23/2007 12:16:00 AM

0

Hi,

At Sat, 23 Jun 2007 00:26:13 +0900,
Alex Young wrote in [ruby-talk:256583]:
> gcc -Os -fomit-frame-pointer -DRUBY_EXPORT -rdynamic
> -Wl,-export-dynamic -L. main.o libruby-static.a -ldl -lcrypt -lm -o
> miniruby
> ./lib/fileutils.rb:1206: [BUG] Segmentation fault
> ruby 1.8.6 (2007-03-13) [i686-linux]

--disable-frame-address configuration option is necessary to
use -fomit-frame-pointer.

--
Nobu Nakada

M. Edward (Ed) Borasky

6/23/2007 4:12:00 AM

0

Andrew Thompson wrote:
> Alex Young wrote:
>> I get this:
>>
>> gcc -Os -fomit-frame-pointer -DRUBY_EXPORT -rdynamic
>> -Wl,-export-dynamic -L. main.o libruby-static.a -ldl -lcrypt -lm -o
>> miniruby
>> ./lib/fileutils.rb:1206: [BUG] Segmentation fault
>> ruby 1.8.6 (2007-03-13) [i686-linux]
>>
>> make: *** [.rbconfig.time] Aborted
>>
>> when I use those options.
>
> I think ruby *really* doesn't like to be built with optimizations. I
> believe the garbage collector in particular has problems with it.
>
> Andrew
>
>

This combination just compiled successfully on my Gentoo box:


znmeb@DreamGate ~/ruby-test/ruby-1.8.6-p36 $ set|grep CFLAGS
CFLAGS='-Os -march=athlon-tbird -fomit-frame-pointer'
znmeb@DreamGate ~/ruby-test/ruby-1.8.6-p36 $ gcc --version
gcc (GCC) 4.1.2 (Gentoo 4.1.2)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Ruby 1.8.6-p36, gcc 4.1.2 and CFLAGS='-Os -march=athlon-tbird
-fomit-frame-pointer'

I doubt if the Athlon TBird piece is why mine worked and yours didn't.

Alex Young

6/23/2007 10:02:00 AM

0

M. Edward (Ed) Borasky wrote:
> Andrew Thompson wrote:
>> Alex Young wrote:
>>> I get this:
>>>
>>> gcc -Os -fomit-frame-pointer -DRUBY_EXPORT -rdynamic
>>> -Wl,-export-dynamic -L. main.o libruby-static.a -ldl -lcrypt -lm -o
>>> miniruby
>>> ./lib/fileutils.rb:1206: [BUG] Segmentation fault
>>> ruby 1.8.6 (2007-03-13) [i686-linux]
>>>
>>> make: *** [.rbconfig.time] Aborted
>>>
>>> when I use those options.
>> I think ruby *really* doesn't like to be built with optimizations. I
>> believe the garbage collector in particular has problems with it.
>>
>> Andrew
>>
>>
>
> This combination just compiled successfully on my Gentoo box:
>
>
> znmeb@DreamGate ~/ruby-test/ruby-1.8.6-p36 $ set|grep CFLAGS
> CFLAGS='-Os -march=athlon-tbird -fomit-frame-pointer'
> znmeb@DreamGate ~/ruby-test/ruby-1.8.6-p36 $ gcc --version
> gcc (GCC) 4.1.2 (Gentoo 4.1.2)
> Copyright (C) 2006 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> Ruby 1.8.6-p36, gcc 4.1.2 and CFLAGS='-Os -march=athlon-tbird
> -fomit-frame-pointer'
>
> I doubt if the Athlon TBird piece is why mine worked and yours didn't.
>
Me too. Mine's an Ubuntu Dapper install on a P4, gcc version 4.0.3
(Ubuntu 4.0.3-1ubuntu5).

Out of interest, what executable size do you get with that, before and
after stripping?

--
Alex

Alex Young

6/23/2007 10:11:00 AM

0

Nobuyoshi Nakada wrote:
> Hi,
>
> At Sat, 23 Jun 2007 00:26:13 +0900,
> Alex Young wrote in [ruby-talk:256583]:
>> gcc -Os -fomit-frame-pointer -DRUBY_EXPORT -rdynamic
>> -Wl,-export-dynamic -L. main.o libruby-static.a -ldl -lcrypt -lm -o
>> miniruby
>> ./lib/fileutils.rb:1206: [BUG] Segmentation fault
>> ruby 1.8.6 (2007-03-13) [i686-linux]
>
> --disable-frame-address configuration option is necessary to
> use -fomit-frame-pointer.
>
It's not just that...

$ export CFLAGS="-Os -fomit-frame-pointer --disable-frame-address"
$ ./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.

config.log led me to try this:

$ gcc -Os -fomit-frame-pointer --disable-frame-address test.c
cc1: error: unrecognised command line option "-fdisable-frame-address"

Is it just my build of GCC (4.0.3)?

--
Alex

darren kirby

6/23/2007 3:41:00 PM

0

quoth the Alex Young:
> Nobuyoshi Nakada wrote:
> > --disable-frame-address configuration option is necessary to
> > use -fomit-frame-pointer.
>
> It's not just that...
>
> $ export CFLAGS="-Os -fomit-frame-pointer --disable-frame-address"
> $ ./configure
> checking build system type... i686-pc-linux-gnu
> checking host system type... i686-pc-linux-gnu
> checking target system type... i686-pc-linux-gnu
> checking for gcc... gcc
> checking for C compiler default output file name...
> configure: error: C compiler cannot create executables
> See `config.log' for more details.
>
> config.log led me to try this:
>
> $ gcc -Os -fomit-frame-pointer --disable-frame-address test.c
> cc1: error: unrecognised command line option "-fdisable-frame-address"
>
> Is it just my build of GCC (4.0.3)?

Shouldn't that be:

$ export CFLAGS="-Os -fomit-frame-pointer"
$ ./configure --disable-frame-address

?

-d
--
darren kirby :: Part of the problem since 1976 :: http://badco...
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972

M. Edward (Ed) Borasky

6/23/2007 5:57:00 PM

0

Alex Young wrote:
> Nobuyoshi Nakada wrote:
>> Hi,
>>
>> At Sat, 23 Jun 2007 00:26:13 +0900,
>> Alex Young wrote in [ruby-talk:256583]:
>>> gcc -Os -fomit-frame-pointer -DRUBY_EXPORT -rdynamic
>>> -Wl,-export-dynamic -L. main.o libruby-static.a -ldl -lcrypt -lm
>>> -o miniruby
>>> ./lib/fileutils.rb:1206: [BUG] Segmentation fault
>>> ruby 1.8.6 (2007-03-13) [i686-linux]
>>
>> --disable-frame-address configuration option is necessary to
>> use -fomit-frame-pointer.
>>
> It's not just that...
>
> $ export CFLAGS="-Os -fomit-frame-pointer --disable-frame-address"
> $ ./configure
> checking build system type... i686-pc-linux-gnu
> checking host system type... i686-pc-linux-gnu
> checking target system type... i686-pc-linux-gnu
> checking for gcc... gcc
> checking for C compiler default output file name...
> configure: error: C compiler cannot create executables
> See `config.log' for more details.
>
> config.log led me to try this:
>
> $ gcc -Os -fomit-frame-pointer --disable-frame-address test.c
> cc1: error: unrecognised command line option "-fdisable-frame-address"
>
> Is it just my build of GCC (4.0.3)?
>
1. As far as I know, you don't need "-fdisable-frame-address". Mine is
working fine without it.
2. gcc 4.0.3 "should" work, but most versions of gcc 4.0 had some things
b0rk3d and 4.1 is in much better shape. I'm awaiting word from Gentoo
Central on when and how to upgrade to gcc 4.2 -- since almost everything
in Gentoo is compiled from source, a compiler change is a very big deal
in some cases.

M. Edward (Ed) Borasky

6/23/2007 6:50:00 PM

0

Alex Young wrote:
> M. Edward (Ed) Borasky wrote:
>> Andrew Thompson wrote:
>>> Alex Young wrote:
>>>> I get this:
>>>>
>>>> gcc -Os -fomit-frame-pointer -DRUBY_EXPORT -rdynamic
>>>> -Wl,-export-dynamic -L. main.o libruby-static.a -ldl -lcrypt
>>>> -lm -o
>>>> miniruby
>>>> ./lib/fileutils.rb:1206: [BUG] Segmentation fault
>>>> ruby 1.8.6 (2007-03-13) [i686-linux]
>>>>
>>>> make: *** [.rbconfig.time] Aborted
>>>>
>>>> when I use those options.
>>> I think ruby *really* doesn't like to be built with optimizations. I
>>> believe the garbage collector in particular has problems with it.
>>>
>>> Andrew
>>>
>>>
>>
>> This combination just compiled successfully on my Gentoo box:
>>
>>
>> znmeb@DreamGate ~/ruby-test/ruby-1.8.6-p36 $ set|grep CFLAGS
>> CFLAGS='-Os -march=athlon-tbird -fomit-frame-pointer'
>> znmeb@DreamGate ~/ruby-test/ruby-1.8.6-p36 $ gcc --version
>> gcc (GCC) 4.1.2 (Gentoo 4.1.2)
>> Copyright (C) 2006 Free Software Foundation, Inc.
>> This is free software; see the source for copying conditions. There
>> is NO
>> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
>> PURPOSE.
>>
>> Ruby 1.8.6-p36, gcc 4.1.2 and CFLAGS='-Os -march=athlon-tbird
>> -fomit-frame-pointer'
>>
>> I doubt if the Athlon TBird piece is why mine worked and yours didn't.
>>
> Me too. Mine's an Ubuntu Dapper install on a P4, gcc version 4.0.3
> (Ubuntu 4.0.3-1ubuntu5).
>
> Out of interest, what executable size do you get with that, before and
> after stripping?
>

"-Os":
$ export CFLAGS='-Os -fomit-frame-pointer -march=athlon-tbird'
$ ./configure --enable-pthread # required on my system because I have a
threaded Tcl/Tk
$ make

...

$ ls -l ruby
-rwxr-xr-x 1 znmeb users 637415 Jun 23 11:03 ruby
$ size ruby
text data bss dec hex filename
542399 3048 63928 609375 94c5f ruby
$ strip ruby
$ ls -l ruby
-rwxr-xr-x 1 znmeb users 548636 Jun 23 11:08 ruby
$ size ruby
text data bss dec hex filename
542399 3048 63928 609375 94c5f ruby


"-O2":
$ make clean
$ export CFLAGS='-O2 -fomit-frame-pointer -march=athlon-tbird'
$ ./configure --enable-pthread
$ make
...

$ ls -l ruby
-rwxr-xr-x 1 znmeb users 778524 Jun 23 11:40 ruby
$ size ruby
text data bss dec hex filename
683954 3028 63928 750910 b753e ruby
$ strip ruby
$ ls -l ruby
-rwxr-xr-x 1 znmeb users 690172 Jun 23 11:41 ruby
$ size ruby
text data bss dec hex filename
683954 3028 63928 750910 b753e ruby


So it looks like -O2 is a good bit larger than -Os. What I don't know is
the speed penalty, or what yours will do if you substitute
"-march=pentium4" for my "-march=athlon-tbird". My recollection is that
one of the gimmicks that enables -Os to generate smaller code is
elimination of 4-byte and 8-byte alignment adjustments whenever
possible, which would be a severe performance hit on floating-point work
but probably not in a Ruby interpreter.

I don't plan to benchmark any of this, mostly because I'm interested in
the other extreme -- waste as much RAM as you need and try all the
compiler optimizations to make the inner interpreter as fast as
possible. :)