Enabling opcache causes libraries to build as static

php.internals

David Zuelke

10 years ago
Hi all, I've been trying to get to the bottom of why even a minimal PHP build (any 5.x or 7 release, or a fresh e.g. 7.0 branch checkout after buildconf) creates .a versions of all shared extensions in addition to .so modules. I've narrowed it down to opcache: $ ./configure --disable-all ... checking whether to build shared libraries... yes checking whether to build static libraries... no versus $ ./configure --disable-all --enable-opcache=shared ... checking whether to build shared libraries... yes checking whether to build static libraries... yes but I cannot figure out why this is happening (both on OS X and Ubuntu 14.04). Is this intentional? Related to opcache's "can only be built shared" status? But why would that trigger static builds? Or is it a bug? I've been wading through config.m4s, generated configures etc but still haven't found the reason; any pointers or explanations would be much appreciated! Cheers, David

Andrew Faulds

10 years ago
Hi, David Zuelke wrote:
> Is this intentional? Related to opcache's "can only be built shared" status? But why would that trigger static builds? Or is it a bug?
While we're at it, why is Opcache still built as shared? Does something prevent it being statically-linked? Thanks.
-- Andrea Faulds https://ajf.me/

David Zuelke

10 years ago
> On 08.03.2016, at 16:18, Andrea Faulds <ajf@ajf.me> wrote: > > Hi, > > David Zuelke wrote: >> Is this intentional? Related to opcache's "can only be built shared" status? But why would that trigger static builds? Or is it a bug? > > While we're at it, why is Opcache still built as shared? Does something prevent it being statically-linked?
I remember something about PCRE and whether or not that's linked statically or not. Can't find it right now. Either way, it'd be great if someone in-the-know could chime in on this matter ;) David

David Zuelke

10 years ago
On 10.03.2016, at 16:56, David Zuelke <dz@heroku.com> wrote:
> >> On 08.03.2016, at 16:18, Andrea Faulds <ajf@ajf.me> wrote: >> >> Hi, >> >> David Zuelke wrote: >>> Is this intentional? Related to opcache's "can only be built shared" status? But why would that trigger static builds? Or is it a bug? >> >> While we're at it, why is Opcache still built as shared? Does something prevent it being statically-linked? > > I remember something about PCRE and whether or not that's linked statically or not. Can't find it right now. > > Either way, it'd be great if someone in-the-know could chime in on this matter ;)
Just a little *bump*... anyone got any idea here? Thanks!

David Zuelke

10 years ago
On 20.03.2016, at 22:10, David Zuelke <dz@heroku.com> wrote:
> > On 10.03.2016, at 16:56, David Zuelke <dz@heroku.com> wrote: >> >>> On 08.03.2016, at 16:18, Andrea Faulds <ajf@ajf.me> wrote: >>> >>> Hi, >>> >>> David Zuelke wrote: >>>> Is this intentional? Related to opcache's "can only be built shared" status? But why would that trigger static builds? Or is it a bug? >>> >>> While we're at it, why is Opcache still built as shared? Does something prevent it being statically-linked? >> >> I remember something about PCRE and whether or not that's linked statically or not. Can't find it right now. >> >> Either way, it'd be great if someone in-the-know could chime in on this matter ;) > > Just a little *bump*... anyone got any idea here? > > Thanks!
And another *bump*... anyone from Zend maybe?

Joe Watkins

10 years ago
Morning David, To confirm it was something to do with opcache, I removed opcache from the source tree: krakjoe@fiji:/usr/src/php-src$ ./configure --disable-all | grep static checking if cc static flag -static works... yes checking whether to build static libraries... yes That's pretty strange, it doesn't seem connected to opcache, at least on my os (ubuntu). So I try this, still no opcache in tree: krakjoe@fiji:/usr/src/php-src$ ./configure --disable-all --disable-static | grep static checking if cc static flag -static works... yes checking whether to build static libraries... yes So I dig around in configure ... and find this: enable_shared=yes enable_static=yes case $php_sapi_module in shared) enable_static=no case $with_pic in yes) standard_libtool_flag='-prefer-pic' ;; no) standard_libtool_flag='-prefer-non-pic' ;; esac EXTRA_LDFLAGS="$EXTRA_LDFLAGS -avoid-version -module" ;; *) standard_libtool_flag='-prefer-non-pic -static' if test -z "$PHP_MODULES" && test -z "$PHP_ZEND_EX"; then enable_shared=no fi ;; esac Unconditionally setting enable_static here makes --enable-static be ignored. Over to someone else who understands why this is the case ... Cheers Joe On Fri, Apr 29, 2016 at 12:25 AM, David Zuelke <dz@heroku.com> wrote:

Johannes Schlueter

10 years ago
On Tue, 2016-03-08 at 15:18 +0000, Andrea Faulds wrote:
> While we're at it, why is Opcache still built as shared? Does > something > prevent it being statically-linked?
The reason for this is that opcache is no "PHP module" but a "Zend Extension" and we simply don't have an initialization mechanism for static Zend Extensions. Such a mechanism would require to create an extension list, similar to the module list in main/internal_functions.c from the build system (see configure.in and .win32/build/confutils.js) and then invoke them somewhere around zend_startup_extensions_mechanism(), zend_startup_extensions() and zend_shutdown_extensions(). Should be quite straight forward to do (for somebody willing to dig into both, autofoo and our Windows build system) johannes