opcache/zend_shared_alloc.c: needed but ineffective pre-processor instructions
未关闭
还没有人认领这个 Issue。
Bug
Extension: opcache
Status: Verified
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.1k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
_GNU_SOURCE enabled sys/mman.h is needed for memfd_create and MFD_CLOEXEC, yet the needed pre-processor instructions at the top of zend_shared_alloc.c are useless since they are wrapped with ifdef HAVE_MEMFD_CREATE, which is defined in a *config.h not yet included.
See https://github.com/php/php-src/blob/master/ext/opcache/zend_shared_alloc.c#L22-L27
As a consequence, the build failed for me on Ubuntu-24.04 with GCC-13.
'./configure' \
'--disable-all' \
'--enable-debug' \
'--enable-cli' \
'--enable-opcache'
make -j
/bin/bash /home/mike/src/php-src/libtool --silent --preserve-dup-deps --tag=CC --mode=compile cc -Iext/opcache/ -I/home/mike/src/php-src/ext/opcache/ -I/home/mike/src/php-src/main -I/home/mike/src/php-src -I/home/mike/src/php-src/ext/date/lib -I/home/mike/src/php-src/ext/raphf/src -I/home/mike/src/php-src/ext/raphf -I/home/mike/src/php-src/ext/http/src -I/home/mike/src/php-src/TSRM -I/home/mike/src/php-src/Zend -fno-common -Wstrict-prototypes -Wformat-truncation -Wlogical-op -Wduplicated-cond -Wno-clobbered -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -g -ffp-contract=off -fvisibility=hidden -O0 -Wno-strict-prototypes -Wimplicit-fallthrough=1 -DZEND_SIGNALS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -Iext/opcache/jit/ir -DIR_TARGET_X64 -DIR_PHP -DIR_DEBUG -DZEND_COMPILE_DL_EXT=1 -c /home/mike/src/php-src/ext/opcache/zend_shared_alloc.c -o ext/opcache/zend_shared_alloc.lo -MMD -MF ext/opcache/zend_shared_alloc.dep -MT ext/opcache/zend_shared_alloc.lo
In file included from /home/mike/src/php-src/Zend/zend.h:454,
from /home/mike/src/php-src/Zend/zend_objects.h:23,
from /home/mike/src/php-src/Zend/zend_globals.h:35,
from /home/mike/src/php-src/Zend/zend_compile.h:843,
from /home/mike/src/php-src/Zend/zend_extensions.h:23,
from /home/mike/src/php-src/ext/opcache/ZendAccelerator.h:51,
from /home/mike/src/php-src/ext/opcache/zend_shared_alloc.c:30:
/home/mike/src/php-src/Zend/zend_operators.h: In function ‘zend_memrchr’:
/home/mike/src/php-src/Zend/zend_operators.h:221:29: warning: implicit declaration of function ‘memrchr’; did you mean ‘memchr’? [-Wimplicit-function-declaration]
221 | return (const void*)memrchr(s, c, n);
| ^~~~~~~
| memchr
/home/mike/src/php-src/Zend/zend_operators.h:221:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
221 | return (const void*)memrchr(s, c, n);
| ^
/home/mike/src/php-src/ext/opcache/zend_shared_alloc.c: In function ‘zend_shared_alloc_create_lock’:
/home/mike/src/php-src/ext/opcache/zend_shared_alloc.c:98:21: warning: implicit declaration of function ‘memfd_create’; did you mean ‘timer_create’? [-Wimplicit-function-declaration]
98 | lock_file = memfd_create("opcache_lock", MFD_CLOEXEC);
| ^~~~~~~~~~~~
| timer_create
/home/mike/src/php-src/ext/opcache/zend_shared_alloc.c:98:50: error: ‘MFD_CLOEXEC’ undeclared (first use in this function); did you mean ‘FD_CLOEXEC’?
98 | lock_file = memfd_create("opcache_lock", MFD_CLOEXEC);
| ^~~~~~~~~~~
| FD_CLOEXEC
/home/mike/src/php-src/ext/opcache/zend_shared_alloc.c:98:50: note: each undeclared identifier is reported only once for each function it appears in
make: *** [Makefile:794: ext/opcache/zend_shared_alloc.lo] Error 1
PHP Version
master
Operating System
Ubuntu 24.04
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
受影响的文件是 ext/opcache/zend_shared_alloc.c,预处理器代码块位于第 22-27 行附近。使用报告中的 configure 选项在 Ubuntu 24.04 上复现,并运行 make -j,然后确认 opcache 构建完成且没有 memfd_create/MFD_CLOEXEC 错误。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, php
- 领域
- build-system
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 55/100