# Compiling 2 SAPIs

- Thread: https://externals.io/message/7336
- Original archive: https://news-web.php.net/php.internals/7336
- Started by Brian J. France on 2004-01-26T21:37:56+00:00
- Messages: 14
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #7336 — Brian J. France — 2004-01-26T21:37:56+00:00

URL: https://externals.io/message/7336#7336

> I have a project where I need to have both Apache SAPI (shared) and
> embed SAPI (shared) compiled/active at the same time. Is that possible
> to do at all? Any risk of symbol clashes or other similar problems?

Andrei posted this a while ago, but nobody replied and we have learned 
this is it not possible.

With the current state of the code and configuration system what would 
it take to do something like this:

Core PHP code is built into libphpX.so (libphp4.so)

All SAPI's require libphpX.so:

libphpX_apache.so <- apache sapi
libphpX_embeded.so <- apache sapi

and the command line sapi would have a depenency on libphpX.so.

Brian

---

## #7337 — Andrei Zmievski — 2004-01-26T22:10:11+00:00

URL: https://externals.io/message/7336#7337 · In reply to: #7336

> Andrei posted this a while ago, but nobody replied and we have learned 
> this is it not possible.
> 
> With the current state of the code and configuration system what would 
> it take to do something like this:
> 
> Core PHP code is built into libphpX.so (libphp4.so)
> 
> All SAPI's require libphpX.so:
> 
> libphpX_apache.so <- apache sapi
> libphpX_embeded.so <- apache sapi
> 
> and the command line sapi would have a depenency on libphpX.so.

I guess not too many people are interested in something like this..

- Andrei

---

## #7338 — George Schlossnagle — 2004-01-26T22:16:41+00:00

URL: https://externals.io/message/7336#7338 · In reply to: #7337

> 
> > […]
>
> I guess not too many people are interested in something like this..

I remember a thread about this about a year ago.  Sascha's answer was 
something along the lines of 'build it twice if that's what you want'.  
Can't find the thread though.

George

---

## #7339 — Marcus Boerger — 2004-01-26T22:37:42+00:00

URL: https://externals.io/message/7336#7339 · In reply to: #7336

Hello Brian,

Monday, January 26, 2004, 10:37:56 PM, you wrote:

> > […]

> Andrei posted this a while ago, but nobody replied and we have learned 
> this is it not possible.

> With the current state of the code and configuration system what would 
> it take to do something like this:

> Core PHP code is built into libphpX.so (libphp4.so)

> All SAPI's require libphpX.so:

> libphpX_apache.so <- apache sapi
> libphpX_embeded.so <- apache sapi

> and the command line sapi would have a depenency on libphpX.so.

Sounds nice to me. But are you willing to work out a patch for that so that
we can play with it? Or do you anyone in mind who could do that change and
has some time for it?


Best regards,
 Marcus                            mailto:helly@php.net

---

## #7350 — Jani Taskinen — 2004-01-27T14:51:07+00:00

URL: https://externals.io/message/7336#7350 · In reply to: #7336

> > […]
>
>Andrei posted this a while ago, but nobody replied and we have learned 
>this is it not possible.
>
>With the current state of the code and configuration system what would 
>it take to do something like this:
>
>Core PHP code is built into libphpX.so (libphp4.so)
>
>All SAPI's require libphpX.so:
>
>libphpX_apache.so <- apache sapi
>libphpX_embeded.so <- apache sapi
>
>and the command line sapi would have a depenency on libphpX.so.

    Here's what I came up with:
 
      http://www.php.net/~jani/patches/multi_sapi_build.patch
   
    With the patch applied, I'm now able to build at least
    apache, cli, cgi and embed SAPIs on one run.
    
    # ./configure --disable-all --with-apxs --enable-embed
    
    (CLI and CGI are build by default..)
    
    I build them using static 'core' lib as I dislike the
    idea of having to install and maintain several libs. :)

    But if someone insists, it's possible to build one shared
    lib too..I actually tested with that first. :)
    
    --Jani

---

## #7354 — Andrei Zmievski — 2004-01-27T16:40:11+00:00

URL: https://externals.io/message/7336#7354 · In reply to: #7350

>     Here's what I came up with:
>  
>       http://www.php.net/~jani/patches/multi_sapi_build.patch
>    
>     With the patch applied, I'm now able to build at least
>     apache, cli, cgi and embed SAPIs on one run.
>     
>     # ./configure --disable-all --with-apxs --enable-embed
>     
>     (CLI and CGI are build by default..)
>     
>     I build them using static 'core' lib as I dislike the
>     idea of having to install and maintain several libs. :)
> 
>     But if someone insists, it's possible to build one shared
>     lib too..I actually tested with that first. :)

Does your patch just build multiple SAPIs as separate shared libs or
does it make one shared lib that has multiple SAPIs in it? The latter is
what I want.

The best (ideal) result would be to have one libphp[45].so that contains
the core. The SAPIs should link against it, so we'd have libphpembed.so,
libphpapache.so, etc. Can this be done?

- Andrei

---

## #7358 — Uwe Schindler — 2004-01-27T16:57:22+00:00

URL: https://externals.io/message/7336#7358 · In reply to: #7354

At 17:40 27.01.2004, you wrote:
>
> > […]
>
>Does your patch just build multiple SAPIs as separate shared libs or
>does it make one shared lib that has multiple SAPIs in it? The latter is
>what I want.
>
>The best (ideal) result would be to have one libphp[45].so that contains
>the core. The SAPIs should link against it, so we'd have libphpembed.so,
>libphpapache.so, etc. Can this be done?

Would be great. The only thing is: We must compile all SAPIs with ZTS 
enabled... But thats the same on windows.


-----
Uwe Schindler
thetaphi@php.net - http://www.php.net
NSAPI SAPI developer
Erlangen, Germany

---

## #7359 — Andrei Zmievski — 2004-01-27T17:02:17+00:00

URL: https://externals.io/message/7336#7359 · In reply to: #7358

> Would be great. The only thing is: We must compile all SAPIs with ZTS 
> enabled... But thats the same on windows.

Well, maybe we can have a ZTS and a non-ZTS version of the core lib.

- Andrei

---

## #7360 — George Schlossnagle — 2004-01-27T17:05:44+00:00

URL: https://externals.io/message/7336#7360 · In reply to: #7359

> 
> > […]
>
> Well, maybe we can have a ZTS and a non-ZTS version of the core lib.

That seems like a nice standard way of handling it.

George

---

## #7362 — Wez Furlong — 2004-01-27T17:40:50+00:00

URL: https://externals.io/message/7336#7362 · In reply to: #7360

That is also how the new win32 build system handles it;
you have the option of php5ts.dll or php5.dll.

--Wez.

> > […]
> 
> That seems like a nice standard way of handling it.

---

## #7367 — Jani Taskinen — 2004-01-28T06:49:27+00:00

URL: https://externals.io/message/7336#7367 · In reply to: #7359

>
> > […]
>
>Well, maybe we can have a ZTS and a non-ZTS version of the core lib.

    Yes, but it makes no sense to build both on same run as you'd
    have to build the core objects twice..
    
    --Jani

---

## #7368 — Jani Taskinen — 2004-01-28T06:56:15+00:00

URL: https://externals.io/message/7336#7368 · In reply to: #7354

>
> > […]
>
>Does your patch just build multiple SAPIs as separate shared libs or
>does it make one shared lib that has multiple SAPIs in it? The latter is
>what I want.

    It creates a static libphp5_core.a which is linked to each build
    SAPI module / binary. Dunno how you could have same lib loaded
    by e.g. Apache / Apache2 ?? Or what did you mean? :)

>The best (ideal) result would be to have one libphp[45].so that contains
>the core. The SAPIs should link against it, so we'd have libphpembed.so,
>libphpapache.so, etc. Can this be done?
 
    My first tests had the libphp5_core lib as shared..so yes.
    I'll update my patch a bit. 
    
    --Jani

---

## #7381 — Andrei Zmievski — 2004-01-28T19:00:37+00:00

URL: https://externals.io/message/7336#7381 · In reply to: #7368

>     It creates a static libphp5_core.a which is linked to each build
>     SAPI module / binary. Dunno how you could have same lib loaded
>     by e.g. Apache / Apache2 ?? Or what did you mean? :)
> 
> > […]
>  
>     My first tests had the libphp5_core lib as shared..so yes.
>     I'll update my patch a bit. 

Okay, is it possible to make the same patch for php4?

- Andrei

---

## #7382 — Jani Taskinen — 2004-01-28T19:22:43+00:00

URL: https://externals.io/message/7336#7382 · In reply to: #7381

>
> > […]
>
>Okay, is it possible to make the same patch for php4?

    I didn't try, but I think the same patch might even apply
    without modifying it at all. :)
    
    The build stuff is pretty much same in both HEAD and PHP_4_3
    branches, AFAICT.
    
    --Jani
