All,
I have cross-compiled php-cgi for a MIPS device (mediaplayer), but the
binary is quite large, more than 3MB. I'm using:
./configure --prefix=../result/php-5.3.5 --host=i686-pc-linux-gnu
--target=mipsel-linux-gnu --build=mipsel-linux-gnu --enable-cgi
--disable-all --without-pear --with-config-file-path=/etc/
Which options do I have to reduce size of the binary? E.g. can I
remove the zend engine?
Thanks in advance,
Martin
All,
I have cross-compiled php-cgi for a MIPS device (mediaplayer), but the
binary is quite large, more than 3MB. I'm using:./configure --prefix=../result/php-5.3.5 --host=i686-pc-linux-gnu
--target=mipsel-linux-gnu --build=mipsel-linux-gnu --enable-cgi
--disable-all --without-pear --with-config-file-path=/etc/Which options do I have to reduce size of the binary? E.g. can I
remove the zend engine?
what do you mean by "remove the zend engine"?
zend engine is the core, upon which php is built.
--
Alexey Zakhlestin, http://twitter.com/jimi_dini
http://www.milkfarmsoft.com/
2011/2/20 Alexey Zakhlestin indeyets@gmail.com:
what do you mean by "remove the zend engine"?
zend engine is the core, upon which php is built.
Ah, that explains a lot :-) I thought zend engine is an additional
engine for performance reasons..
Is there any other way to decrease binary size? (workaround is to put
php-cgi on external storage)
Is there any other way to decrease binary size? (workaround is to put
php-cgi on external storage)
php-cgi 5.2.x = ~2.4mb "./configure" without :
...
--without-iconv
--without-pear
--without-gd
--disable-bcmath
--disable-libxml --disable-dom --disable-simplexml --disable-xml
--disable-xmlreader --disable-xmlwriter --without-pear
--with-sqlite
--without-pdo-sqlite
--
freundliche Grüsse / best Regards,
Patrick C. Engel
2011/2/20 Patrick E. zenobic@googlemail.com:
php-cgi 5.2.x = ~2.4mb "./configure" without :
...
--without-iconv
--without-pear
--without-gd
--disable-bcmath
--disable-libxml --disable-dom --disable-simplexml --disable-xml
--disable-xmlreader --disable-xmlwriter --without-pear
--with-sqlite
--without-pdo-sqlite
For latest 5.3.x it still results in a 3+ MB php-cgi binary.
Am 20.02.2011 15:52, schrieb Martin Herrman:
2011/2/20 Patrick E. zenobic@googlemail.com:
php-cgi 5.2.x = ~2.4mb "./configure" without :
...
--without-iconv
--without-pear
--without-gd
--disable-bcmath
--disable-libxml --disable-dom --disable-simplexml --disable-xml
--disable-xmlreader --disable-xmlwriter --without-pear
--with-sqlite
--without-pdo-sqliteFor latest 5.3.x it still results in a 3+ MB php-cgi binary.
There are some more swicthes
--disable-all Disable all extensions which are enabled by default
What about "--disable-all" followed by "--enable-feature" for all
you want to have?
The follwoing are not needed in most cases
--disable-ipv6
--disable-posix
--disable-phar
--disable-json
--disable-ipv6 Disable IPv6 support
--disable-libxml Disable LIBXML support
--disable-ctype Disable ctype functions
--disable-inifile DBA: INI support (bundled)
--disable-flatfile DBA: FlatFile support (bundled)
--disable-dom Disable DOM support
--disable-fileinfo Disable fileinfo support
--disable-filter Disable input filter support
--disable-hash Disable hash support
--disable-json Disable JavaScript Object Serialization support
--disable-mbregex MBSTRING: Disable multibyte regex support
--disable-pdo Disable PHP Data Objects support
--disable-phar Disable phar support
--disable-posix Disable POSIX-like functions
--disable-session Disable session support
--disable-simplexml Disable SimpleXML support
--disable-tokenizer Disable tokenizer support
--disable-xml Disable XML support
--disable-xmlreader Disable XMLReader support
--disable-xmlwriter Disable XMLWriter support
2011/2/20 Reindl Harald h.reindl@thelounge.net:
There are some more swicthes
--disable-all Disable all extensions which are enabled by defaultWhat about "--disable-all" followed by "--enable-feature" for all
you want to have?The follwoing are not needed in most cases
--disable-ipv6
--disable-posix
--disable-phar
--disable-json
--disable-ipv6 Disable IPv6 support
--disable-libxml Disable LIBXML support
--disable-ctype Disable ctype functions
--disable-inifile DBA: INI support (bundled)
--disable-flatfile DBA: FlatFile support (bundled)
--disable-dom Disable DOM support
--disable-fileinfo Disable fileinfo support
--disable-filter Disable input filter support
--disable-hash Disable hash support
--disable-json Disable JavaScript Object Serialization support
--disable-mbregex MBSTRING: Disable multibyte regex support
--disable-pdo Disable PHP Data Objects support
--disable-phar Disable phar support
--disable-posix Disable POSIX-like functions
--disable-session Disable session support
--disable-simplexml Disable SimpleXML support
--disable-tokenizer Disable tokenizer support
--disable-xml Disable XML support
--disable-xmlreader Disable XMLReader support
--disable-xmlwriter Disable XMLWriter support
I already had --disabled-all. I have now tested with -Os instead of
-O2 which results in a 2.8MB executable. So that helps a bit :-)
2011/2/20 Reindl Harald h.reindl@thelounge.net:
There are some more swicthes
--disable-all Disable all extensions which are enabled by defaultWhat about "--disable-all" followed by "--enable-feature" for all
you want to have?The follwoing are not needed in most cases
--disable-ipv6
--disable-posix
--disable-phar
--disable-json
--disable-ipv6 Disable IPv6 support
--disable-libxml Disable LIBXML support
--disable-ctype Disable ctype functions
--disable-inifile DBA: INI support (bundled)
--disable-flatfile DBA: FlatFile support (bundled)
--disable-dom Disable DOM support
--disable-fileinfo Disable fileinfo support
--disable-filter Disable input filter support
--disable-hash Disable hash support
--disable-json Disable JavaScript Object Serialization support
--disable-mbregex MBSTRING: Disable multibyte regex support
--disable-pdo Disable PHP Data Objects support
--disable-phar Disable phar support
--disable-posix Disable POSIX-like functions
--disable-session Disable session support
--disable-simplexml Disable SimpleXML support
--disable-tokenizer Disable tokenizer support
--disable-xml Disable XML support
--disable-xmlreader Disable XMLReader support
--disable-xmlwriter Disable XMLWriter supportI already had --disabled-all. I have now tested with -Os instead of
-O2 which results in a 2.8MB executable. So that helps a bit :-)
2.8M? My php binary with just about everything compiled in is around
1MB. Do this:
file php
See how it says "not stripped" ?
That means you have left all the debugging symbols in. Now do this:
strip php
Then check the file size.
Magic!
-Rasmus
I already had --disabled-all. I have now tested with -Os instead of
-O2 which results in a 2.8MB executable. So that helps a bit :-)
Try running `strip` on there to take out the excess symbols.
--
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/
2011/2/20 Daniel Brown danbrown@php.net:
I already had --disabled-all. I have now tested with -Os instead of
-O2 which results in a 2.8MB executable. So that helps a bit :-)Try running
strip
on there to take out the excess symbols.
This is my cross-compile script for -O2:
#!/bin/sh
Set variables
export CFLAGS="-EL -O2"
export CXXFLAGS="-EL -O2"
export CC="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-gcc"
export CXX="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-g++"
export PATH=/opt/Sourcery_G++_Lite/bin:$PATH
export AR="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-ar"
export LDFLAGS=" -s -Xlinker -rpath /lib -Xlinker -rpath-link
/opt/Sourcery_G++_Lite/lib/gcc/mips-linux-gnu/4.3.3/el"
export STRIP="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-strip"
export RANLIB="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-ranlib"
export AS="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-as"
export LD="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-ld"
Cleanup previous compilations
rm -rf /home/martin/result/php-5.3.5
rm -rf /home/martin/work/php*
Download source and configure, compile, install
cd /home/martin/work
wget http://nl.php.net/get/php-5.3.5.tar.gz/from/this/mirror -O php-5.3.5.tar.gz
tar -zxvf php-5.3.5.tar.gz
cd php-5.3.5
#./configure --help
./configure --prefix=/home/martin/result/php-5.3.5
--host=i686-pc-linux-gnu --target=mipsel-linux-gnu
--build=mipsel-linux-gnu --enable-cgi --disable-all --without-pear
make
make install
This is the result:
martin@martindesktop ~/ $ ls -ltr result/php-5.3.5/bin/php-cgi
-rwxr-xr-x 1 martin users 3142772 Feb 20 16:58 result/php-5.3.5/bin/php-cgi
martin@martindesktop ~/ $ file result/php-5.3.5/bin/php-cgi
result/php-5.3.5/bin/php-cgi: ELF 32-bit LSB executable, MIPS, MIPS32
rel2 version 1, dynamically linked (uses shared libs), for GNU/Linux
2.6.12, with unknown capability 0xf41 = 0x756e6700, with unknown
capability 0x70100 = 0x1040000, stripped
martin@martindesktop ~/ $
/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-strip
result/php-5.3.5/bin/php-cgi
martin@martindesktop ~/ $ file result/php-5.3.5/bin/php-cgi
result/php-5.3.5/bin/php-cgi: ELF 32-bit LSB executable, MIPS, MIPS32
rel2 version 1 (SYSV), dynamically linked (uses shared libs), for
GNU/Linux 2.6.12, with unknown capability 0xf41 = 0x756e6700, with
unknown capability 0x70100 = 0x1040000, stripped
martin@martindesktop ~/ $ ls -ltr result/php-5.3.5/bin/php-cgi
-rwxr-xr-x 1 martin users 3142772 Feb 20 17:07 result/php-5.3.5/bin/php-cgi
martin@martindesktop ~/ $
Now for -Os:
martin@martindesktop ~/ $ ls -ltr result/php-5.3.5/bin/php-cgi
-rwxr-xr-x 1 martin users 2813508 Feb 20 17:10 result/php-5.3.5/bin/php-cgi
martin@martindesktop ~/ $ file result/php-5.3.5/bin/php-cgi
result/php-5.3.5/bin/php-cgi: ELF 32-bit LSB executable, MIPS, MIPS32
rel2 version 1, dynamically linked (uses shared libs), for GNU/Linux
2.6.12, with unknown capability 0xf41 = 0x756e6700, with unknown
capability 0x70100 = 0x1040000, stripped
martin@martindesktop ~/ $
/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-strip
result/php-5.3.5/bin/php-cgi
martin@martindesktop ~/ $ ls -ltr result/php-5.3.5/bin/php-cgi
-rwxr-xr-x 1 martin users 2813508 Feb 20 17:16 result/php-5.3.5/bin/php-cgi
martin@martindesktop ~/ $ file result/php-5.3.5/bin/php-cgi
result/php-5.3.5/bin/php-cgi: ELF 32-bit LSB executable, MIPS, MIPS32
rel2 version 1 (SYSV), dynamically linked (uses shared libs), for
GNU/Linux 2.6.12, with unknown capability 0xf41 = 0x756e6700, with
unknown capability 0x70100 = 0x1040000, stripped
martin@martindesktop ~/ $
On Sun, Feb 20, 2011 at 4:01 PM, Reindl Harald h.reindl@thelounge.netwrote:
Am 20.02.2011 15:52, schrieb Martin Herrman:
2011/2/20 Patrick E. zenobic@googlemail.com:
php-cgi 5.2.x = ~2.4mb "./configure" without :
...
--without-iconv
--without-pear
--without-gd
--disable-bcmath
--disable-libxml --disable-dom --disable-simplexml --disable-xml
--disable-xmlreader --disable-xmlwriter --without-pear
--with-sqlite
--without-pdo-sqliteFor latest 5.3.x it still results in a 3+ MB php-cgi binary.
There are some more swicthes
--disable-all Disable all extensions which are enabled by defaultWhat about "--disable-all" followed by "--enable-feature" for all
you want to have?The follwoing are not needed in most cases
--disable-ipv6
--disable-posix
--disable-phar
--disable-json
--disable-ipv6 Disable IPv6 support
--disable-libxml Disable LIBXML support
--disable-ctype Disable ctype functions
--disable-inifile DBA: INI support (bundled)
--disable-flatfile DBA: FlatFile support (bundled)
--disable-dom Disable DOM support
--disable-fileinfo Disable fileinfo support
--disable-filter Disable input filter support
--disable-hash Disable hash support
--disable-json Disable JavaScript Object Serialization support
--disable-mbregex MBSTRING: Disable multibyte regex support
--disable-pdo Disable PHP Data Objects support
--disable-phar Disable phar support
--disable-posix Disable POSIX-like functions
--disable-session Disable session support
--disable-simplexml Disable SimpleXML support
--disable-tokenizer Disable tokenizer support
--disable-xml Disable XML support
--disable-xmlreader Disable XMLReader support
--disable-xmlwriter Disable XMLWriter support
did you bother to read his first email?
he exactly did that: --disable-all and --enable-cgi
Tyrael
Am 20.02.2011 11:09, schrieb Martin Herrman:
2011/2/20 Alexey Zakhlestin indeyets@gmail.com:
what do you mean by "remove the zend engine"?
zend engine is the core, upon which php is built.Ah, that explains a lot :-) I thought zend engine is an additional
engine for performance reasons..Is there any other way to decrease binary size? (workaround is to put
php-cgi on external storage)
./configure --help
disable all things you do not need, but be careful as long you
do not know what you doing since "I thought zend engine is an
additional engine" sounds like you are missing basics
2011/2/20 Reindl Harald h.reindl@thelounge.net:
./configure --help
disable all things you do not need, but be careful as long you
do not know what you doing since "I thought zend engine is an
additional engine" sounds like you are missing basics
I'll go through the list of options again and disable everything
possible. I am aware of the fact that you must think that I'm a noob,
which is partly true. I do have some PHP programming experience and
sometimes tried to use a function that was not available because it
was not compiled in. But I just tried to have some really basic
functionality included, I can rebuild again when needed. But still:
thanks for the warning :-)
All,
I have cross-compiled php-cgi for a MIPS device (mediaplayer), but the
binary is quite large, more than 3MB. I'm using:./configure --prefix=../result/php-5.3.5 --host=i686-pc-linux-gnu
--target=mipsel-linux-gnu --build=mipsel-linux-gnu --enable-cgi
--disable-all --without-pear --with-config-file-path=/etc/Which options do I have to reduce size of the binary?
Check Makefile and correct cc's -O setting to -Os before compiling. Is
your binary stripped?
--
Boris
All,
I have cross-compiled php-cgi for a MIPS device (mediaplayer), but the
binary is quite large, more than 3MB. I'm using:./configure --prefix=../result/php-5.3.5 --host=i686-pc-linux-gnu
--target=mipsel-linux-gnu --build=mipsel-linux-gnu --enable-cgi
--disable-all --without-pear --with-config-file-path=/etc/Which options do I have to reduce size of the binary? E.g. can I
remove the zend engine?
you may want to re-generate zend_vm_execute.h
php zend_vm_gen.php --without-specializer
It will save ~300k.
also you may want to try to remove Reflection, SPL and Date extensions and
optimize for size: -O1
instead of performance (-O2)
Don't forget to strip off debug info from the binary.
regards,
j
HI Martin,
Is it only file size you worry about or also memory footprint? I assume it'd also be the latter.
If so, we can share a patch we've worked on which could allow you to reduce the memory footprint at compile time somewhat more (on the expense of performance, ...).
We were going to send it out for review anyway so this could be it :)
Andi
-----Original Message-----
From: martin.herrman@gmail.com [mailto:martin.herrman@gmail.com] On Behalf Of Martin Herrman
Sent: Saturday, February 19, 2011 10:25 AM
To: internals@lists.php.net
Subject: [PHP-DEV] PHP for embedded device: reduce size
All,
I have cross-compiled php-cgi for a MIPS device (mediaplayer), but the binary is quite large, more than 3MB. I'm using:
./configure --prefix=../result/php-5.3.5 --host=i686-pc-linux-gnu --target=mipsel-linux-gnu --build=mipsel-linux-gnu --enable-cgi --disable-all --without-pear --with-config-file-path=/etc/
Which options do I have to reduce size of the binary? E.g. can I remove the zend engine?
Thanks in advance,
Martin