Skip to content

Commit 45b54b0

Browse files
committed
Review conf_syslibs.py: fix check_funcs return value and minor cleanup.
- pyconf.py / pyconf.awk: check_funcs/pyconf_check_funcs now return True/1 if any function was found, matching AC_CHECK_FUNCS action-if-found semantics. Previously returned None/0, causing the backtrace/dladdr1 check in check_base_libraries to never set ac_cv_require_ldl, so -ldl was never added to LDFLAGS for faulthandler support. - conf_syslibs.py: fix module docstring (remove incorrect "pthreads setup", add missing check_stat_timestamps and setup_tzpath descriptions). - conf_syslibs.py: initialize r and libatomic_needed before with-blocks to avoid Pyright possibly-unbound warnings. Assisted-by: Claude
1 parent d547345 commit 45b54b0

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

Tools/configure/conf_syslibs.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
"""conf_syslibs — GDBM, DBM, pthreads setup, base libraries, libatomic.
1+
"""conf_syslibs — GDBM, DBM, base libraries, libatomic, stat timestamps, tzpath.
22
33
Detects GDBM library and headers; handles --with-dbmliborder and
44
detects DBM backends (gdbm, ndbm, bdb) in the specified order;
5-
configures POSIX threads (THREADOBJ, thread CFLAGS/LDFLAGS,
6-
PTHREAD_SYSTEM_SCHED_SUPPORTED); probes for sendfile, dl, dld
7-
libraries and backtrace/dladdr1 support; checks sem_init, intl,
8-
AIX-specific extensions, and aligned memory access; and probes
9-
whether libatomic is needed for <pyatomic.h>.
5+
probes for sendfile, dl, dld libraries and backtrace/dladdr1 support;
6+
checks sem_init, intl, AIX-specific extensions, and aligned memory access;
7+
probes whether libatomic is needed for <pyatomic.h>; checks for subsecond
8+
timestamps in struct stat; and handles --with-tzpath.
109
"""
1110

1211
from __future__ import annotations
@@ -106,6 +105,7 @@ def detect_dbm(v):
106105
)
107106

108107
if ac_cv_header_gdbm_slash_ndbm_h or ac_cv_header_gdbm_dash_ndbm_h:
108+
r = ""
109109
with pyconf.save_env():
110110
r = pyconf.search_libs("dbm_open", ["gdbm_compat"], required=False)
111111
if r and r is not False:
@@ -298,6 +298,7 @@ def check_libatomic(v):
298298
# anymore. <pyport.h> cannot be included alone, it's designed to be included
299299
# by <Python.h>: it expects other includes and macros to be defined.
300300

301+
libatomic_needed = False
301302
with pyconf.save_env():
302303
v.CPPFLAGS = f"{v.BASECPPFLAGS} -I. -I{pyconf.srcdir}/Include {v.CPPFLAGS}".strip()
303304
libatomic_needed = not pyconf.link_check(

Tools/configure/pyconf.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3170,12 +3170,20 @@ def check_func(
31703170
return found
31713171

31723172

3173-
def check_funcs(funcs: list[str], headers: list[str] | None = None) -> None:
3174-
"""AC_CHECK_FUNCS — check multiple functions; define HAVE_<FUNC> for each found."""
3173+
def check_funcs(funcs: list[str], headers: list[str] | None = None) -> bool:
3174+
"""AC_CHECK_FUNCS — check multiple functions; define HAVE_<FUNC> for each found.
3175+
3176+
Returns True if any function was found (matches AC_CHECK_FUNCS action-if-found
3177+
semantics, where the action runs for each found function).
3178+
"""
3179+
any_found = False
31753180
for f in funcs:
31763181
checking(f"for {f}")
31773182
found = check_func(f, headers=headers)
31783183
result(found)
3184+
if found:
3185+
any_found = True
3186+
return any_found
31793187

31803188

31813189
def check_decl(

Tools/configure/transpiler/pyconf.awk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,14 +762,18 @@ function pyconf_check_func(fname, headers, define, source, inc, cv, rc, cache_ke
762762
return rc
763763
}
764764

765-
function pyconf_check_funcs(funcs, n, i, rc) {
765+
function pyconf_check_funcs(funcs, n, i, rc, any_found) {
766+
# Returns 1 if any function was found (mirrors AC_CHECK_FUNCS action-if-found).
766767
n = funcs[0] + 0
768+
any_found = 0
767769
for (i = 1; i <= n; i++)
768770
if (funcs[i] != "") {
769771
pyconf_checking("for " funcs[i])
770772
rc = pyconf_check_func(funcs[i])
771773
pyconf_result(rc ? "yes" : "no")
774+
if (rc) any_found = 1
772775
}
776+
return any_found
773777
}
774778

775779
function pyconf_replace_funcs(funcs, n, i, rc) {

0 commit comments

Comments
 (0)