Is there a difference between compiling php with the parameter:
--with-[extension name]
as opposed to just compiling it as a shared module and including it that way? Is there any performance benefit? If not, why would you want to do this?
Is there a difference between compiling php with the parameter:
--with-[extension name]
as opposed to just compiling it as a shared module and including it that way? Is there any performance benefit? If not, why would you want to do this?
Hi,
Maybe it won't be a full answer to your question, but here's what I've been able to find so far : there is some kind of a partial answer in the book "Extending and Embedding PHP", written by Sara Golemon (amazon ; some parts are also available on google books).
The relevant part (a note at the top of page 56) is :
Ever wonder why some extensions are configured using
--enable-extname
and some are configured using--with-extename
? Functionnaly, there is no difference between the two. In practice, however,--enable
is meant for features that can be turned on witout requiring any third-party libraries.--with
, by contrast, is meant for features that do have such prerequisites.
So, not a single word about performance (I guess, if there is a difference, it is only a matter of "loading one more file" vs "loading one bigger file") ; but there is a technical reason behind this possibility.
I guess this is done so PHP itself doesn't require an additionnal external library because of some extension ; using the right option allows for users to enable or disable the extension themselves, depending on whether or not they already have that external library.
Any performance benefit would be negligible. It’s simply another option for packaging up your PHP build.
On my Mac I use Marc Liyange’s build of PHP, which includes, among other things, built-in PostgreSQL support. It was built with the --with-pdo-pgsql
flag. As a result it does not need to be distributed with the pdo-pgsql shared library.
If he did not build with --with-pdo-pgsql
, he would have needed to distribute the pdo-pgsql shared library and include a directive in php.ini
to load it. Sure, it’s just a minor difference, but if you know you are going to be using that functionality, it’s fine to build it into PHP itself.
Hi,
I guess Nate is right about the performance and that this options only help for packing.
Basically with a compiled-in module PHP can call directly the module functions, but, after the compilation, this calls are translated into memory addresses to be called.
In the loadable module version, PHP will call a dl_open to load the library and then call the functions by there addresses, juts like the compiled-in version does. I guess that this dl_open call is done only once when the webserver is started, so you can ignore it.