Skip to content

Commit c63a89b

Browse files
committed
add static opcache 84 patch
1 parent 44fdc89 commit c63a89b

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

patches/static_opcache_84.patch

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
diff --git a/build/order_by_dep.awk b/build/order_by_dep.awk
2+
index 1e71ea2069..3da32d8830 100644
3+
--- a/build/order_by_dep.awk
4+
+++ b/build/order_by_dep.awk
5+
@@ -37,6 +37,11 @@ function get_module_index(name, i)
6+
function do_deps(mod_idx, module_name, mod_name_len, dep, ext, val, depidx)
7+
{
8+
module_name = mods[mod_idx];
9+
+ # TODO: real skip zend extension
10+
+ if (module_name == "opcache") {
11+
+ delete mods[mod_idx];
12+
+ return;
13+
+ }
14+
mod_name_len = length(module_name);
15+
16+
for (ext in mod_deps) {
17+
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
18+
index 8d45b2ae41..a7cc9abbb8 100644
19+
--- a/ext/opcache/ZendAccelerator.c
20+
+++ b/ext/opcache/ZendAccelerator.c
21+
@@ -93,7 +93,10 @@ typedef int gid_t;
22+
#include <immintrin.h>
23+
#endif
24+
25+
+#ifdef COMPILE_DL_OPCACHE
26+
+// avoid symbol conflict
27+
ZEND_EXTENSION();
28+
+#endif
29+
30+
#ifndef ZTS
31+
zend_accel_globals accel_globals;
32+
@@ -4803,7 +4806,11 @@ static zend_result accel_finish_startup(void)
33+
#endif /* ZEND_WIN32 */
34+
}
35+
36+
+#ifdef COMPILE_DL_OPCACHE
37+
ZEND_EXT_API zend_extension zend_extension_entry = {
38+
+#else
39+
+zend_extension opcache_zend_extension_entry = {
40+
+#endif
41+
ACCELERATOR_PRODUCT_NAME, /* name */
42+
PHP_VERSION, /* version */
43+
"Zend Technologies", /* author */
44+
diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4
45+
index bef360e7c3..a96f80a82b 100644
46+
--- a/ext/opcache/config.m4
47+
+++ b/ext/opcache/config.m4
48+
@@ -27,7 +27,8 @@ PHP_ARG_WITH([capstone],,
49+
if test "$PHP_OPCACHE" != "no"; then
50+
51+
dnl Always build as shared extension
52+
- ext_shared=yes
53+
+ dnl why?
54+
+ dnl ext_shared=yes
55+
56+
if test "$PHP_HUGE_CODE_PAGES" = "yes"; then
57+
AC_DEFINE(HAVE_HUGE_CODE_PAGES, 1, [Define to enable copying PHP CODE pages into HUGE PAGES (experimental)])
58+
@@ -337,7 +338,9 @@ int main(void) {
59+
shared_alloc_mmap.c \
60+
shared_alloc_posix.c \
61+
$ZEND_JIT_SRC,
62+
- shared,,"-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 ${JIT_CFLAGS}",,yes)
63+
+ $ext_shared,,"-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 ${JIT_CFLAGS}",,yes)
64+
+
65+
+ AC_DEFINE(HAVE_OPCACHE, 1, [opcache enabled])
66+
67+
PHP_ADD_EXTENSION_DEP(opcache, pcre)
68+
69+
diff --git a/ext/opcache/config.w32 b/ext/opcache/config.w32
70+
index 24b4acaabc..452d57cc7d 100644
71+
--- a/ext/opcache/config.w32
72+
+++ b/ext/opcache/config.w32
73+
@@ -16,7 +16,9 @@ if (PHP_OPCACHE != "no") {
74+
zend_persist_calc.c \
75+
zend_file_cache.c \
76+
zend_shared_alloc.c \
77+
- shared_alloc_win32.c", true, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
78+
+ shared_alloc_win32.c", PHP_OPCACHE_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
79+
+
80+
+ AC_DEFINE('HAVE_OPCACHE', 1, 'opcache enabled');
81+
82+
if (PHP_OPCACHE_JIT == "yes") {
83+
if (CHECK_HEADER_ADD_INCLUDE("ir/ir.h", "CFLAGS_OPCACHE", PHP_OPCACHE + ";ext\\opcache\\jit")) {
84+
diff --git a/main/main.c b/main/main.c
85+
index a3acaf94b7..a1324aab51 100644
86+
--- a/main/main.c
87+
+++ b/main/main.c
88+
@@ -2048,6 +2048,18 @@ void dummy_invalid_parameter_handler(
89+
}
90+
#endif
91+
92+
+// this can be moved to other place
93+
+#if defined(HAVE_OPCACHE) && !defined(COMPILE_DL_OPCACHE)
94+
+extern zend_extension opcache_zend_extension_entry;
95+
+extern void zend_register_extension(zend_extension *new_extension, void *handle);
96+
+
97+
+int zend_load_static_extensions(void)
98+
+{
99+
+ zend_register_extension(&opcache_zend_extension_entry, NULL /*opcache cannot be unloaded*/);
100+
+ return 0;
101+
+}
102+
+#endif
103+
+
104+
/* {{{ php_module_startup */
105+
zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_module)
106+
{
107+
@@ -2224,6 +2236,9 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi
108+
ahead of all other internals
109+
*/
110+
php_ini_register_extensions();
111+
+#if defined(HAVE_OPCACHE) && !defined(COMPILE_DL_OPCACHE)
112+
+ zend_load_static_extensions();
113+
+#endif
114+
zend_startup_modules();
115+
116+
/* start Zend extensions */
117+
diff --git a/win32/build/confutils.js b/win32/build/confutils.js
118+
index 1da17bddbd..8aa1e6557d 100644
119+
--- a/win32/build/confutils.js
120+
+++ b/win32/build/confutils.js
121+
@@ -1534,6 +1534,8 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)
122+
}
123+
}
124+
125+
+ // TODO: real skip zend extensions
126+
+ if (extname != 'opcache')
127+
extension_module_ptrs += '\tphpext_' + extname + '_ptr,\r\n';
128+
129+
DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_PHP) $(CFLAGS_' + EXT + ')');

0 commit comments

Comments
 (0)