python / python/cpython

configure.ac assumes -std=c11 rather than checking it, which causes make failures on old compilers

未关闭
#131,093 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

build type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug report

Bug description:
Repro

Steps:

  1. Run a container having a gcc that does not support the C11 standard (e.g., gcc 4.4.7)
  2. tar xvJf Python-3.13.2.tar.xz && cd Python-3.13.2
  3. ./configure && make

Expected: configure reports an error like "your compiler doesn't support C11"

Observed: configure succeeds, only for make to fail.

...
configure: creating Makefile
configure:

If you want a release build with all stable optimizations active (PGO, etc),
please run ./configure --enable-optimizations

configure: Your compiler or platform does have a working C11 stdatomic.h. A future version of Python may require stdatomic.h.
sh-4.1# make
gcc -std=gnu99 -pthread -c -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall    -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal -I./Include/internal/mimalloc  -I. -I./Include    -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c
cc1: error: unrecognized command line option "-std=c11"
make: *** [Programs/python.o] Error 1
Suggestion

I think this can be fixed by changing configure.ac here:

-    CFLAGS_NODIST="$CFLAGS_NODIST -std=c11"
+    AX_CHECK_COMPILE_FLAG([-std=c11],[
+        CFLAGS_NODIST="$CFLAGS_NODIST -std=c11"
+    ], [
+        AC_MSG_ERROR([Python requires -std=c11 on gcc])
+    ], [-Werror])
Related issues

#91731

CPython versions tested on:

3.12.9, 3.13.2

Operating systems tested on:

Linux

Linked PRs
  • gh-133608

贡献指南

打开贡献指南

从这里开始

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

调研方向

受影响的逻辑位于所引用行附近的 configure.ac 中,其中添加了 -std=c11。使用 GCC 4.4.7 运行 ./configure && make 进行复现,然后验证 configure 报告不支持 C11 编译器,而不是让 make 失败。

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

评估

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

把新 issue 发到你的邮箱

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