ソースを参照

php5: add php5-mod-opcache (fixes #1010)

This patch adds build infrastructure for PHP's OPcache extension.
Compared with the other extension, this is a Zend module and it
need a little workaround during cross-compiling.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
Michael Heimpold 9 年 前
コミット
cd0bcd23e7
共有3 個のファイルを変更した182 個の追加2 個の削除を含む
  1. 13
    2
      lang/php5/Makefile
  2. 10
    0
      lang/php5/files/php.ini
  3. 159
    0
      lang/php5/patches/200-ext-opcache-fix-detection-of-shm-mmap.patch

+ 13
- 2
lang/php5/Makefile ファイルの表示

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=php
11 11
 PKG_VERSION:=5.6.8
12
-PKG_RELEASE:=1
12
+PKG_RELEASE:=2
13 13
 
14 14
 PKG_MAINTAINER:=W. Michael Petullo <mike@flyn.org>
15 15
 
@@ -36,7 +36,7 @@ PHP5_MODULES = \
36 36
 	json \
37 37
 	ldap \
38 38
 	mbstring mcrypt mysql mysqli \
39
-	openssl \
39
+	opcache openssl \
40 40
 	pcntl pdo pdo-mysql pdo-pgsql pdo-sqlite pgsql \
41 41
 	session shmop simplexml soap sockets sqlite3 sysvmsg sysvsem sysvshm \
42 42
 	tokenizer \
@@ -276,6 +276,12 @@ else
276 276
   CONFIGURE_ARGS+= --without-mysqli
277 277
 endif
278 278
 
279
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-opcache),)
280
+  CONFIGURE_ARGS+= --enable-opcache=shared
281
+else
282
+  CONFIGURE_ARGS+= --disable-opcache
283
+endif
284
+
279 285
 ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-openssl),)
280 286
   CONFIGURE_ARGS+= \
281 287
 	--with-openssl=shared,"$(STAGING_DIR)/usr" \
@@ -508,7 +514,11 @@ define BuildModule
508 514
 	$(INSTALL_DIR) $$(1)/usr/lib/php
509 515
 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/modules/$(subst -,_,$(1)).so $$(1)/usr/lib/php/
510 516
 	$(INSTALL_DIR) $$(1)/etc/php5
517
+      ifeq ($(4),zend)
518
+	echo "zend_extension=/usr/lib/php/$(subst -,_,$(1)).so" > $$(1)/etc/php5/$(subst -,_,$(1)).ini
519
+      else
511 520
 	echo "extension=$(subst -,_,$(1)).so" > $$(1)/etc/php5/$(subst -,_,$(1)).ini
521
+    endif
512 522
   endef
513 523
 
514 524
   $$(eval $$(call BuildPackage,php5-mod-$(1)))
@@ -540,6 +550,7 @@ $(eval $(call BuildModule,mbstring,MBString))
540 550
 $(eval $(call BuildModule,mcrypt,Mcrypt,+PACKAGE_php5-mod-mcrypt:libmcrypt +PACKAGE_php5-mod-mcrypt:libltdl))
541 551
 $(eval $(call BuildModule,mysql,MySQL,+PACKAGE_php5-mod-mysql:libmysqlclient))
542 552
 $(eval $(call BuildModule,mysqli,MySQL Improved Extension,+PACKAGE_php5-mod-mysqli:libmysqlclient))
553
+$(eval $(call BuildModule,opcache,OPcache,,zend))
543 554
 $(eval $(call BuildModule,openssl,OpenSSL,+PACKAGE_php5-mod-openssl:libopenssl))
544 555
 $(eval $(call BuildModule,pcntl,PCNTL))
545 556
 $(eval $(call BuildModule,pdo,PHP Data Objects))

+ 10
- 0
lang/php5/files/php.ini ファイルの表示

@@ -309,3 +309,13 @@ ldap.max_links = -1
309 309
 [mcrypt]
310 310
 ;mcrypt.algorithms_dir=
311 311
 ;mcrypt.modes_dir=
312
+
313
+[opcache]
314
+;opcache.memory_consumption=8		; 8M is the allowed minimum
315
+;opcache.interned_strings_buffer=1
316
+opcache.max_accelerated_files=200	; 200 is the allowed minimum
317
+;opcache.revalidate_freq=60
318
+;opcache.fast_shutdown=1
319
+opcache.enable_cli=1
320
+opcache.enable=1
321
+;opcache.log_verbosity_level=4

+ 159
- 0
lang/php5/patches/200-ext-opcache-fix-detection-of-shm-mmap.patch ファイルの表示

@@ -0,0 +1,159 @@
1
+From dc8bb6a53bfdfe42d9ae81d4e78c6155ad4bfd6e Mon Sep 17 00:00:00 2001
2
+From: Michael Heimpold <mhei@heimpold.de>
3
+Date: Sun, 17 May 2015 16:50:50 +0200
4
+Subject: [PATCH] ext/opcache: fix detection of shm/mmap
5
+
6
+The detection of sysvipc and mmap doesn't work well when cross-compiling,
7
+so I decided to only check for the availability of the functions involved.
8
+This is not a clean solution, but works for now(tm) :-)
9
+
10
+It should be discussed with upstream to find a better solution.
11
+
12
+This solves the issue reported at
13
+https://github.com/openwrt/packages/issues/1010
14
+and makes opcache usable on OpenWrt.
15
+
16
+Signed-off-by: Michael Heimpold <mhei@heimpold.de>
17
+---
18
+ ext/opcache/config.m4 |  122 ++-----------------------------------------------
19
+ 1 file changed, 4 insertions(+), 118 deletions(-)
20
+
21
+diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4
22
+index b7e4835..7b6c0aa 100644
23
+--- a/ext/opcache/config.m4
24
++++ b/ext/opcache/config.m4
25
+@@ -11,127 +11,13 @@ if test "$PHP_OPCACHE" != "no"; then
26
+     AC_DEFINE(HAVE_MPROTECT, 1, [Define if you have mprotect() function])
27
+   ])
28
+ 
29
+-  AC_MSG_CHECKING(for sysvipc shared memory support)
30
+-  AC_TRY_RUN([
31
+-#include <sys/types.h>
32
+-#include <sys/wait.h>
33
+-#include <sys/ipc.h>
34
+-#include <sys/shm.h>
35
+-#include <unistd.h>
36
+-#include <string.h>
37
+-
38
+-int main() {
39
+-  pid_t pid;
40
+-  int status;
41
+-  int ipc_id;
42
+-  char *shm;
43
+-  struct shmid_ds shmbuf;
44
+-
45
+-  ipc_id = shmget(IPC_PRIVATE, 4096, (IPC_CREAT | SHM_R | SHM_W));
46
+-  if (ipc_id == -1) {
47
+-    return 1;
48
+-  }
49
+-
50
+-  shm = shmat(ipc_id, NULL, 0);
51
+-  if (shm == (void *)-1) {
52
+-    shmctl(ipc_id, IPC_RMID, NULL);
53
+-    return 2;
54
+-  }
55
+-
56
+-  if (shmctl(ipc_id, IPC_STAT, &shmbuf) != 0) {
57
+-    shmdt(shm);
58
+-    shmctl(ipc_id, IPC_RMID, NULL);
59
+-    return 3;
60
+-  }
61
+-
62
+-  shmbuf.shm_perm.uid = getuid();
63
+-  shmbuf.shm_perm.gid = getgid();
64
+-  shmbuf.shm_perm.mode = 0600;
65
+-
66
+-  if (shmctl(ipc_id, IPC_SET, &shmbuf) != 0) {
67
+-    shmdt(shm);
68
+-    shmctl(ipc_id, IPC_RMID, NULL);
69
+-    return 4;
70
+-  }
71
+-
72
+-  shmctl(ipc_id, IPC_RMID, NULL);
73
+-
74
+-  strcpy(shm, "hello");
75
+-
76
+-  pid = fork();
77
+-  if (pid < 0) {
78
+-    return 5;
79
+-  } else if (pid == 0) {
80
+-    strcpy(shm, "bye");
81
+-    return 6;
82
+-  }
83
+-  if (wait(&status) != pid) {
84
+-    return 7;
85
+-  }
86
+-  if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
87
+-    return 8;
88
+-  }
89
+-  if (strcmp(shm, "bye") != 0) {
90
+-    return 9;
91
+-  }
92
+-  return 0;
93
+-}
94
+-],dnl
95
++  AC_CHECK_FUNC(shmget,[
96
+     AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
97
+-    msg=yes,msg=no,msg=no)
98
+-  AC_MSG_RESULT([$msg])
99
+-
100
+-  AC_MSG_CHECKING(for mmap() using MAP_ANON shared memory support)
101
+-  AC_TRY_RUN([
102
+-#include <sys/types.h>
103
+-#include <sys/wait.h>
104
+-#include <sys/mman.h>
105
+-#include <unistd.h>
106
+-#include <string.h>
107
+-
108
+-#ifndef MAP_ANON
109
+-# ifdef MAP_ANONYMOUS
110
+-#  define MAP_ANON MAP_ANONYMOUS
111
+-# endif
112
+-#endif
113
+-#ifndef MAP_FAILED
114
+-# define MAP_FAILED ((void*)-1)
115
+-#endif
116
+-
117
+-int main() {
118
+-  pid_t pid;
119
+-  int status;
120
+-  char *shm;
121
+-
122
+-  shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
123
+-  if (shm == MAP_FAILED) {
124
+-    return 1;
125
+-  }
126
+-
127
+-  strcpy(shm, "hello");
128
++  ])
129
+ 
130
+-  pid = fork();
131
+-  if (pid < 0) {
132
+-    return 5;
133
+-  } else if (pid == 0) {
134
+-    strcpy(shm, "bye");
135
+-    return 6;
136
+-  }
137
+-  if (wait(&status) != pid) {
138
+-    return 7;
139
+-  }
140
+-  if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
141
+-    return 8;
142
+-  }
143
+-  if (strcmp(shm, "bye") != 0) {
144
+-    return 9;
145
+-  }
146
+-  return 0;
147
+-}
148
+-],dnl
149
++  AC_CHECK_FUNC(mmap,[
150
+     AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
151
+-    msg=yes,msg=no,msg=no)
152
+-  AC_MSG_RESULT([$msg])
153
++  ])
154
+ 
155
+   AC_MSG_CHECKING(for mmap() using /dev/zero shared memory support)
156
+   AC_TRY_RUN([
157
+-- 
158
+1.7.10.4
159
+