php / php/php-src

Issue with undefined _GNU_SOURCE

未关闭
#13,825 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Category: Build System Status: Needs Triage
主要语言
C
星标
40.4k
派生
8.1k
平均合并
2 天 13 小时
30 天内合并 PR
96

描述

Description

Original report: https://bugzilla.redhat.com/2271925

$ gcc -c -g -O2  -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib conftest.c >&5
In file included from /usr/include/php/Zend/zend.h:418,
                 from /usr/include/php/main/php.h:32,
                 from conftest.c:63:
/usr/include/php/Zend/zend_operators.h: In function 'zend_memrchr':
/usr/include/php/Zend/zend_operators.h:207:29: error: implicit declaration of function 'memrchr'; did you mean 'memchr'? [-Wimplicit-function-declaration]
  207 |         return (const void*)memrchr(s, c, n);
      |                             ^~~~~~~
      |                             memchr
/usr/include/php/Zend/zend_operators.h:207:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  207 |         return (const void*)memrchr(s, c, n);
      |                ^
configure:3238: $? = 1



configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "test"
| #define PACKAGE_TARNAME "test"
| #define PACKAGE_VERSION "1.0.0-1"
| #define PACKAGE_STRING "test 1.0.0-1"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define HAVE_STDIO_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_UNISTD_H 1
| #define STDC_HEADERS 1
| /* end confdefs.h.  */
| #include <stddef.h>
| #ifdef HAVE_STDIO_H
| # include <stdio.h>
| #endif
| #ifdef HAVE_STDLIB_H
| # include <stdlib.h>
| #endif
| #ifdef HAVE_STRING_H
| # include <string.h>
| #endif
| #ifdef HAVE_INTTYPES_H
| # include <inttypes.h>
| #endif
| #ifdef HAVE_STDINT_H
| # include <stdint.h>
| #endif
| #ifdef HAVE_STRINGS_H
| # include <strings.h>
| #endif
| #ifdef HAVE_SYS_TYPES_H
| # include <sys/types.h>
| #endif
| #ifdef HAVE_SYS_STAT_H
| # include <sys/stat.h>
| #endif
| #ifdef HAVE_UNISTD_H
| # include <unistd.h>
| #endif
| #include <php.h>
configure:3238: result: no
configure:3243: PHP haders not found or test compile failed

Notice: related to GCC 14 where -Wimplicit-function-declaration now raises an error

A workaround is to use -D_GNU_SOURCE

I try to dig where it is missing (zend_operators.h ?), but cannot find a proper place to add it (we already have tons of places where it is defined)

Would it be simpler to define it globally and earlier?

PHP Version

PHP 8.3

Operating System

Fedora 40 with GCC 14

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 Zend/zend_operators.h 以及包含 php.h 的 configure 编译检查开始,然后在 Fedora 40 上使用 GCC 14 重现失败。跟踪当前在哪里定义了 _GNU_SOURCE,并确定修复缺失的 memrchr 声明所需的适当作用域。报告的配置测试无需 workaround 即可编译通过,就表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
c
领域
build-system
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。