Commit 9eb3202
committed
Add --enable-embed=static support on Windows
PHP's Unix build already documents and accepts --enable-embed=static
(see sapi/embed/config.m4) for building php<N>embed as a static
library with no DLL at runtime. The Windows config.w32 ignored the
static value, leaving php<N>embed.lib as a thin wrapper that still
depended on php<N>.dll at runtime.
When --enable-embed=static is passed on Windows:
* win32/build/confutils.js generates a Makefile rule for php<N>embed
.lib that links in PHP core (PHP_GLOBAL_OBJS), statically built
extensions (STATIC_EXT_OBJS + STATIC_EXT_LIBS), the embed SAPI
objects, and ASM_OBJS in place of the import lib (BUILD_DIR/PHPLIB).
The resulting php<N>embed.lib is a self-contained static library
with no runtime DLL dependency.
* sapi/embed/config.w32 adds /D PHP_EXPORTS /D LIBZEND_EXPORTS
/D SAPI_EXPORTS /D TSRM_EXPORTS to CFLAGS_EMBED so php_embed.c
references PHP/Zend/SAPI/TSRM symbols directly instead of through
__declspec(dllimport) thunks (which would produce LNK2019 with no
DLL to import from), and defines PHP_EMBED_STATIC as a gate.
* sapi/embed/php_embed.c skips its ZEND_TSRMLS_CACHE_DEFINE() when
PHP_EMBED_STATIC is set. In static mode zend.c is in the same link
unit and already defines _tsrm_ls_cache; the duplicate from
php_embed.c produced LNK4006 and a corrupt binary.1 parent 7260b27 commit 9eb3202
4 files changed
Lines changed: 30 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
5 | 13 | | |
6 | 14 | | |
7 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
9 | 19 | | |
10 | 20 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1197 | 1197 | | |
1198 | 1198 | | |
1199 | 1199 | | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
1200 | 1208 | | |
1201 | 1209 | | |
1202 | 1210 | | |
| |||
1228 | 1236 | | |
1229 | 1237 | | |
1230 | 1238 | | |
1231 | | - | |
| 1239 | + | |
1232 | 1240 | | |
1233 | 1241 | | |
1234 | 1242 | | |
| |||
1276 | 1284 | | |
1277 | 1285 | | |
1278 | 1286 | | |
1279 | | - | |
| 1287 | + | |
1280 | 1288 | | |
1281 | 1289 | | |
1282 | | - | |
| 1290 | + | |
1283 | 1291 | | |
1284 | 1292 | | |
1285 | 1293 | | |
| |||
0 commit comments