Building a PHP-lite like Axis - Embedded

This is a discussion on Building a PHP-lite like Axis - Embedded ; I am trying to build a small "PHP-lite" similar to what Axis has done for their video servers and network cameras. They have managed to create a PHP3 executable that is less than 400k. I don't need it to be ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Building a PHP-lite like Axis

  1. Building a PHP-lite like Axis

    I am trying to build a small "PHP-lite" similar to what Axis has done
    for their video servers and network cameras. They have managed to
    create a PHP3 executable that is less than 400k.

    I don't need it to be that small, but I would like to get it
    substantially under the 2 meg or so that I get when I compile it using
    the "configure" script included with PHP3, with everything disabled.

    What I am observing is that, even though I have, for example, disabled
    MySQL support, the mysql.c file is still compiled into mysql.o, and it
    is still linked into the php executable. This seems to indicate that
    in order to substantially reduce the size of the executable, some
    serious hacking will be required.

    If anyone has done this, please advise!

    Thank you.


  2. Re: Building a PHP-lite like Axis

    On Sun, 09 Apr 2006 10:29:52 -0700, tomviolin wrote:
    >
    > What I am observing is that, even though I have, for example, disabled
    > MySQL support, the mysql.c file is still compiled into mysql.o, and it
    > is still linked into the php executable. This seems to indicate that
    > in order to substantially reduce the size of the executable, some
    > serious hacking will be required.
    >


    I've not looked into the PHP build scripts, but which version are you
    trying to build? ISTR that PHP 4 built up to about 800K out of the box
    once you eliminate all of the fluff, while PHP 5 built to something like
    2.5 MB...

    Typically most of the 'hacking' needed is in the build scripts...

    --
    o__
    ,>/'_ o__
    (_)\(_) ,>/'_ o__
    Yan Seiner, PE (_)\(_) ,>/'_ o__
    Certified Personal Trainer (_)\(_) ,>/'_ o__
    Licensed Professional Engineer (_)\(_) ,>/'_
    Who says engineers have to be pencil necked geeks? (_)\(_)


  3. Re: Building a PHP-lite like Axis

    I have found, so far, that to begin to reduce the executable size, it
    is necessary to go into the Makefile and eliminate references to
    specific .c files. However, some files, such as functions/info.c,
    which provides the phpinfo() function, contain functions that are used
    elsewhere, and require modifications to other files. I've spent
    several hours and only got the executable down to around 1.6 meg.

    There doesn't seem to be a "magic" way to do this, one apparently just
    has to dig in.

    I wonder if later releases of PHP might have been written in a more
    modular fashion, and thus be easier to reduce. If I can get a version
    of PHP, that at least has some basic functionality, with an exectuable
    under 1 MB, I'll be happy.


  4. Re: Building a PHP-lite like Axis

    "tomviolin" wrote in message
    news:1144750498.881803.19980@u72g2000cwu.googlegro ups.com...
    > I have found, so far, that to begin to reduce the executable size, it
    > is necessary to go into the Makefile and eliminate references to
    > specific .c files. However, some files, such as functions/info.c,
    > which provides the phpinfo() function, contain functions that are used
    > elsewhere, and require modifications to other files. I've spent
    > several hours and only got the executable down to around 1.6 meg.
    >
    > There doesn't seem to be a "magic" way to do this, one apparently just
    > has to dig in.
    >
    > I wonder if later releases of PHP might have been written in a more
    > modular fashion, and thus be easier to reduce. If I can get a version
    > of PHP, that at least has some basic functionality, with an exectuable
    > under 1 MB, I'll be happy.


    gcc has the (non-default) ability to compile each function and data
    declaration into a separate section. Combining that with linking that
    removes unreferenced sections can reduce your workload. I doesn't matter if
    the code is in the same file - if it isn't referenced then it doesn't get
    pulled in, and if it doesn't get pulled in it does pull other stuff in. This
    has worked well for me on a few embedded projects.

    Look up -ffunction-sections -fdata-sections for compiling and
    -Wl,--gc-sections for linking.

    Peter



+ Reply to Thread