Looking for minimalist ruby

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

···

--
soliton

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

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.

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

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-forum.com/\.

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

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.

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

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

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://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972

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.

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