in reply to bootstrapping with microperl

Microperl dosn't do it all, and seems to have some small peculiarities compared to full perl. Notably, I needed to use `ls` and grep to simulate a glob or readdir.

This is because functions which need to be implemented in a system-specific manner are not incorporated into the microperl binary. This "feature" is mentioned in the Perl Journal article by Simon Cozens here.

As for the size of the compiled microperl binary, there is much room for hacking. For instance the supplied Makefile.micro incorporates no optimisation flags in the compile process - With the additional of a -O3 optimisation flag, a stripped microperl binary can be made as small as 705Kb. Building against a C library optimised for embedded programming may shrink this binary further.

However as Jarkko states, it is an experimental production and if you find problems with your build - Don't report them, fix them :-)

 

Update - Following prompting by PodMaster, I compressed the stripped microperl binary which had been built with the -O3 optimisation flag with UPX - The resultant binary was 308Kb in size.

kathmandu:/home/build/perl-5.8.0# upx -9 microperl -omicroperl.upx Ultimate Packer for eXecutables Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 UPX 1.20 Markus F.X.J. Oberhumer & Laszlo Molnar May 23 +rd 2001 File size Ratio Format Name -------------------- ------ ----------- ----------- 721956 -> 315924 43.75% linux/386 microperl.upx Packed 1 file.

 

perl -le 'print+unpack("N",pack("B32","00000000000000000000001000011011"))'

Replies are listed 'Best First'.
Re: Re: bootstrapping with microperl
by zentara (Cardinal) on Jan 19, 2003 at 14:27 UTC
    Hi, that UPX is very cool. ++ . To continue discussion on microperl: Would you know how to modify the Makefile.micro to get it to produce a statically linked microperl? It's still linked to some shared libs:
    libm.so.6 => /lib/libm.so.6 
    libc.so.6 => /lib/libc.so.6 
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 
    
    libc.so.6 and ld-linux.so.2 seem pretty standard in boot disks, but I was thinking of statically linking libm.so.6 .
      It is very easy to build microperl statically - To do this, the flag -static needs to be added to the compiler flags. For example:

      LD = $(CC) DEFINES = -DPERL_CORE -DPERL_MICRO OPTIMIZE = -O3 -static CFLAGS = $(DEFINES) $(OPTIMIZE) LIBS = -lm _O = .o

      On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has no effect.

       

      perl -le 'print+unpack("N",pack("B32","00000000000000000000001000011110"))'

        Thanks rob_au. Here is another tip which might save some time for monks trying to get upx(the binary compressor) to work. If you have gcc3.2 on linux, it dosn't automatically switch to using g++, as do previous versions. So if your compile of upx fails with a message including " __gxx_personality_v0" you need to edit the Makefile to use CC=g++.