Dear Srs,
I'm trying to compile a statically linked, without shared libs, CGI version
of PHP, I've already tested with 5.2.6 and 5.2.7-dev.
Is there any option in ./configure to compile PHP with this feature?
Also I have tried passing CC and CFLAGS environment variables with
"-static" flags.. but the CGI builds using shared libs, example:
file /tmp/php-cgi /tmp/php-cgi: ELF 32-bit LSB executable, Intel 80386,
version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared
libs), stripped
ldd php-cgi | head
libcrypt.so.1 => /lib/libcrypt.so.1 (0x00335000)
libc-client.so.0 => /usr/lib/libc-client.so.0 (0xb7f38000)
libexslt.so.0 => /usr/lib/libexslt.so.0 (0x00367000)
libz.so.1 => /usr/lib/libz.so.1 (0x00323000)
libm.so.6 => /lib/tls/libm.so.6 (0x002fe000)
libaspell.so.15 => /usr/lib/libaspell.so.15 (0x00767000)
libpspell.so.15 => /usr/lib/libpspell.so.15 (0xb7f36000)
librt.so.1 => /lib/tls/librt.so.1 (0x006b2000)
libmysqlclient.so.14 => /usr/lib/mysql/libmysqlclient.so.14
(0xb7dff000)
libmcrypt.so.4 => /usr/lib/libmcrypt.so.4 (0xb7dce000)
How can I compile statically the CGI version of PHP? Thanks!!
Regards,
--
Santi Saez
http://woop.es
santi@usansolo.net escribió:
Dear Srs,
I'm trying to compile a statically linked, without shared libs,
Why you want such thing ?
Is there any option in ./configure to compile PHP with this feature?
No.
How can I compile statically the CGI version of PHP? Thanks!!
even if you manage to link all libraries statically, you will end with a
huge, memory hungry and hard to debug php binary that anyways require
shared libc at runtime ;-P
--
"A computer is like an Old Testament god, with a lot of rules and no
mercy. "
Cristian Rodríguez R.
Platform/OpenSUSE - Core Services
SUSE LINUX Products GmbH
Research & Development
http://www.opensuse.org/
On Wed, 10 Sep 2008 11:06:32 -0400, Cristian Rodríguez
crrodriguez@suse.de wrote:
Dear Cristian,
I'm trying to compile a statically linked, without shared libs,
Why you want such thing ?
We want to provide a method to "customize" PHP version to our clients; for
example, all our servers run with PHP 5.1.6, but if one client needs PHP
v5.2.6 to run X CMS.. so we provide a statically linked version of the CGI
for 5.2.6.
In the future, if we upgrade from CentOS 4 to CentOS 5 (for example).. all
clients running with the default PHP version in the server will not have
problem. But clients with "personalized" PHP version running as CGI, will
have problems: there will be no available the shared libs wich is
dynamically linked to..
So, we want to provide this version of the CGI.., we know that the version
of the CGI will be bigger, and that's not a good idea, but we need to do it
;-(
How can I compile statically the CGI version of PHP? Thanks!!
even if you manage to link all libraries statically, you will end with a
huge, memory hungry and hard to debug php binary that anyways require
shared libc at runtime ;-P
Yes, it maybe a problem..
Now we're using statifier [1] to convert dynamically linked executables and
all it's libraries in one file:
file php-cgi
php-cgi: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for
GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped
ldd php-cgi | head -10
libcrypt.so.1 => /lib/libcrypt.so.1 (0x00335000)
libc-client.so.0 => /usr/lib/libc-client.so.0 (0x00397000)
libexslt.so.0 => /usr/lib/libexslt.so.0 (0x00367000)
libz.so.1 => /usr/lib/libz.so.1 (0x00323000)
libm.so.6 => /lib/tls/libm.so.6 (0x002fe000)
libaspell.so.15 => /usr/lib/libaspell.so.15 (0x00767000)
libpspell.so.15 => /usr/lib/libpspell.so.15 (0x00111000)
librt.so.1 => /lib/tls/librt.so.1 (0x006b2000)
libmysqlclient.so.14 => /usr/lib/mysql/libmysqlclient.so.14
(0x001c8000)
libmcrypt.so.4 => /usr/lib/libmcrypt.so.4 (0x00f67000)
statifier php-cgi php-cgi.statifier
file php-cgi.statifier
php-cgi.statifier: ELF 32-bit LSB executable, Intel 80386, version 1
(SYSV), dynamically linked, not stripped
ldd php-cgi.statifier
not a dynamic executable
statifier'd version of the CGI works fine.. but we're looking a better
method to directly built the CGI.
ls -lh php-cgi php-cgi.statifier
-rwxr-xr-x 1 root root 7.0M Sep 10 15:10 php-cgi
-rwxr-xr-x 1 root root 19M Sep 10 17:14 php-cgi.statifier
Regards,
[1] http://statifier.sourceforge.net/
--
Santi Saez
http://woop.es
statifier'd version of the CGI works fine.. but we're looking a better
method to directly built the CGI.
you can always use llvm and compile all libraries you need to bitcode
and then link them with PHP. that way will enable more optimizations
and will also reduce the binary size, since llvm will remove the
library functions that PHP doesn't use. (details on how to do this are
too much off-topic for this list)
Still, upgrading a library only represents a problem if its ABI
changes (usually the filename changes as well). If not, there isn't
any trouble.
Nuno
Cristian Rodríguez kirjoitti:
santi@usansolo.net escribió:
Dear Srs,
I'm trying to compile a statically linked, without shared libs,
Why you want such thing ?
Is there any option in ./configure to compile PHP with this feature?
No.
Wrong: --disable-shared --enable-static
Might or might not work, no guarantees.
--Jani
Jani Taskinen escribió:
Wrong: --disable-shared --enable-static
Might or might not work, no guarantees.
Dear Jani,
Thanks for your reply, I have tried with a very simple:
./configure --disable-all --disable-shared --enable-static
But, generated binary uses shared libs ;-(
file sapi/cgi/php-cgi
sapi/cgi/php-cgi: ELF 32-bit LSB executable, Intel 80386, version 1
(SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not
stripped
ldd sapi/cgi/php-cgi
libcrypt.so.1 => /lib/libcrypt.so.1 (0x00335000)
libresolv.so.2 => /lib/libresolv.so.2 (0x00375000)
libm.so.6 => /lib/tls/libm.so.6 (0x002fe000)
libdl.so.2 => /lib/libdl.so.2 (0x002f8000)
libnsl.so.1 => /lib/libnsl.so.1 (0x0039e000)
libc.so.6 => /lib/tls/libc.so.6 (0x001ca000)
/lib/ld-linux.so.2 (0x001b0000)
Thanks anyway! I will try other method..
--
Santi Saez
http://woop.es
Hi Santi,
Jani Taskinen escribió:
Wrong: --disable-shared --enable-static
As you say, this doesn't work.
I needed something like this to for profiling. I believe I got the
static archive linked, but it was a while ago, so I'm not positive
(sadly, the profiling never worked this way).
Here is the script I used. I don't think the script itself works, but
if you have a look through the last 5 or 6 lines of it, it should be
easy enough.
http://code.google.com/p/phc/source/browse/trunk/misc/old/get_libphp5_archive
Those long lines were created by looking at the make output used for
building the shared archive. I think I had to manually remove .o files
every time the linker complained, which was a lot, a problem that you
don't have with shared libs.
Let me know how you get on,
Paul
Jani Taskinen escribió:
--
Paul Biggar
paul.biggar@gmail.com
Santi Saez wrote:
Jani Taskinen escribió:
Wrong: --disable-shared --enable-static
Might or might not work, no guarantees.
Dear Jani,
Thanks for your reply, I have tried with a very simple:
./configure --disable-all --disable-shared --enable-static
But, generated binary uses shared libs ;-(
Yes, that wasn't really the thing. Libtool is nasty but it is possible.
With this small Makefile modification you'll get what you want:
BUILD_CLI = $(LIBTOOL) --mode=link $(CC) -all-static
^^^^^^^^^^^
Just add the '-all-static' option there after $(CC) and before any other
stuff on the line. And same for BUILD_CGI line too if you want that as
all static too.
I tested this and it worked, with some nasty notices but those can be
ignored. :)
BEWARE: You need ALL the libraries that PHP links to as static libs for
this to work!
--Jani
Jani Taskinen escribió:
BEWARE: You need ALL the libraries that PHP links to as static libs for
this to work!
And that is exactly what may not work ;) static libraries are being
retired from linux distributions, this is at least the case of openSUSE,
Fedora and probably others.
--
"A computer is like an Old Testament god, with a lot of rules and no
mercy. "
Cristian Rodríguez R.
Platform/OpenSUSE - Core Services
SUSE LINUX Products GmbH
Research & Development
http://www.opensuse.org/
Jani Taskinen escribió:
BEWARE: You need ALL the libraries that PHP links to as static libs for
this to work!And that is exactly what may not work ;) static libraries are being
retired from linux distributions, this is at least the case of openSUSE,
Fedora and probably others.
Are you sure?
I can see them in -devel packages all right.
rpm -qf /usr/lib64/libbz2.a
libbz2-devel-1.0.5-13.1
--
Wbr,
Antony Dovgal
Antony Dovgal wrote:
Jani Taskinen escribió:
BEWARE: You need ALL the libraries that PHP links to as static libs for
this to work!And that is exactly what may not work ;) static libraries are being
retired from linux distributions, this is at least the case of openSUSE,
Fedora and probably others.Are you sure?
I can see them in -devel packages all right.rpm -qf /usr/lib64/libbz2.a
libbz2-devel-1.0.5-13.1
..and you can always build your libs yourself too.. ;)
--Jani