Skip to content

Commit cb7bf18

Browse files
committed
Add comments from configure.ac.
The original translation to conf_*.py lost some comments. Add them back.
1 parent 43eb0e9 commit cb7bf18

19 files changed

Lines changed: 574 additions & 106 deletions

Tools/configure/conf_buildopts.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115

116116

117117
def setup_disable_gil(v):
118-
"""Handle --disable-gil option."""
118+
# Check for --disable-gil
119119
if DISABLE_GIL.process_bool(v):
120120
pyconf.define(
121121
"Py_GIL_DISABLED", 1, "Define if you want to disable the GIL"
@@ -125,7 +125,7 @@ def setup_disable_gil(v):
125125

126126

127127
def setup_pydebug(v):
128-
"""Handle --with-pydebug option."""
128+
# Check for --with-pydebug
129129
if WITH_PYDEBUG.process_bool(v):
130130
pyconf.define(
131131
"Py_DEBUG",
@@ -136,7 +136,7 @@ def setup_pydebug(v):
136136

137137

138138
def setup_trace_refs(v):
139-
"""Handle --with-trace-refs option."""
139+
# Check for --with-trace-refs
140140
WITH_TRACE_REFS.process_value(v)
141141

142142
if WITH_TRACE_REFS.is_yes():
@@ -151,7 +151,7 @@ def setup_trace_refs(v):
151151

152152

153153
def setup_pystats(v):
154-
"""Handle --enable-pystats option."""
154+
# Check for --enable-pystats
155155
ENABLE_PYSTATS.process_value(v)
156156

157157
if ENABLE_PYSTATS.is_yes():
@@ -163,7 +163,7 @@ def setup_pystats(v):
163163

164164

165165
def setup_assertions(v):
166-
"""Handle --with-assertions option."""
166+
# Check for --with-assertions (allows enabling assertions without Py_DEBUG)
167167
assertions_bool = WITH_ASSERTIONS.process_bool()
168168
v.assertions = "true" if assertions_bool else "false"
169169

@@ -186,6 +186,7 @@ def setup_optimizations(v):
186186

187187
if v.Py_OPT is True:
188188
if "-O0" in v.CFLAGS:
189+
# Check for conflicting CFLAGS=-O0 and --enable-optimizations
189190
pyconf.warn(
190191
"CFLAGS contains -O0 which may conflict with --enable-optimizations. "
191192
"Consider removing -O0 from CFLAGS for optimal performance."
@@ -215,7 +216,7 @@ def setup_optimizations(v):
215216

216217

217218
def setup_experimental_jit(v):
218-
"""Handle --enable-experimental-jit, compiler-specific flags, NDEBUG, arch flags."""
219+
# Handle --enable-experimental-jit, compiler-specific flags, NDEBUG, arch flags
219220
pyconf.checking("for --enable-experimental-jit")
220221
jit = ENABLE_EXPERIMENTAL_JIT.value
221222
if jit is None or jit is False or jit == "no":
@@ -256,13 +257,16 @@ def setup_experimental_jit(v):
256257
pyconf.result(f"{tier2_flags} {jit_flags}")
257258

258259
if v.disable_gil and jit is not False:
260+
# GH-133171: This configuration builds the JIT but never actually uses it,
261+
# which is surprising (and strictly worse than not building it at all):
259262
pyconf.warn(
260263
"--enable-experimental-jit does not work correctly with --disable-gil."
261264
)
262265

263266
if v.ac_cv_cc_name == "mpicc":
264267
pass
265268
elif v.ac_cv_cc_name == "icc":
269+
# ICC needs -fp-model strict or floats behave badly
266270
v.CFLAGS_NODIST += " -fp-model strict"
267271
elif v.ac_cv_cc_name == "xlc":
268272
v.CFLAGS_NODIST += " -qalias=noansi -qmaxmem=-1"
@@ -275,10 +279,7 @@ def setup_experimental_jit(v):
275279

276280

277281
def check_jit_stencils(v):
278-
# ---------------------------------------------------------------------------
279282
# JIT stencils header selection
280-
# ---------------------------------------------------------------------------
281-
282283
v.JIT_STENCILS_H = ""
283284
if ENABLE_EXPERIMENTAL_JIT.given and not ENABLE_EXPERIMENTAL_JIT.is_no():
284285
host = v.host
@@ -334,10 +335,7 @@ def setup_sanitizers(v):
334335

335336

336337
def check_tail_call_interp(v):
337-
# ---------------------------------------------------------------------------
338-
# --with-tail-call-interp
339-
# ---------------------------------------------------------------------------
340-
338+
# Check for --with-tail-call-interp
341339
if WITH_TAIL_CALL_INTERP.is_yes():
342340
pyconf.define(
343341
"_Py_TAIL_CALL_INTERP",
@@ -353,10 +351,7 @@ def check_tail_call_interp(v):
353351

354352

355353
def check_remote_debug(v):
356-
# ---------------------------------------------------------------------------
357-
# --with-remote-debug
358-
# ---------------------------------------------------------------------------
359-
354+
# Check for --with-remote-debug
360355
with_rd = WITH_REMOTE_DEBUG.value_or("yes")
361356
if with_rd == "yes":
362357
pyconf.define(
@@ -367,10 +362,7 @@ def check_remote_debug(v):
367362

368363

369364
def check_ensurepip(v):
370-
# ---------------------------------------------------------------------------
371-
# --with-ensurepip
372-
# ---------------------------------------------------------------------------
373-
365+
# ensurepip option
374366
default_ensurepip = (
375367
False
376368
if v.ac_sys_system in ("Emscripten", "WASI", "iOS")
@@ -451,6 +443,8 @@ def setup_pymalloc(v):
451443
pyconf.checking("for --with-pymalloc-hugepages")
452444
with_pymalloc_hugepages = WITH_PYMALLOC_HUGEPAGES.value_or("no")
453445
if with_pymalloc_hugepages == "yes":
446+
# configure only runs on Unix-like systems; Windows uses MEM_LARGE_PAGES
447+
# via VirtualAlloc but does not use configure. Only check MAP_HUGETLB here.
454448
if pyconf.compile_check(
455449
preamble="#include <sys/mman.h>",
456450
body="int flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB;\n"
@@ -487,7 +481,7 @@ def setup_valgrind(v):
487481

488482

489483
def setup_dtrace(v):
490-
"""Handle --with-dtrace option."""
484+
# Handle --with-dtrace option
491485
with_dtrace = WITH_DTRACE.process_value(None)
492486

493487
v.export("DTRACE", "")
@@ -505,7 +499,13 @@ def setup_dtrace(v):
505499
)
506500
v.DTRACE_HEADERS = "Include/pydtrace_probes.h"
507501

508-
# Check if DTrace probes require linking (ELF generation via -G flag)
502+
# On OS X, DTrace providers do not need to be explicitly compiled and
503+
# linked into the binary. Correspondingly, dtrace(1) is missing the ELF
504+
# generation flag '-G'. We check for presence of this flag, rather than
505+
# hardcoding support by OS, in the interest of robustness.
506+
#
507+
# NetBSD DTrace requires the -x nolibs flag to avoid system library conflicts
508+
# and uses header generation for testing instead of object generation.
509509
pyconf.checking("whether DTrace probes require linking")
510510
ac_cv_dtrace_link = False
511511
host = v.host
@@ -529,13 +529,14 @@ def setup_dtrace(v):
529529
if ac_cv_dtrace_link:
530530
v.DTRACE_OBJS = "Python/pydtrace.o"
531531

532-
# NetBSD-specific DTrace flags
532+
# Set NetBSD-specific DTrace flags in DFLAGS
533533
if "netbsd" in host.lower():
534534
v.DFLAGS += " -x nolibs"
535535

536536

537537
def setup_perf_trampoline(v):
538-
"""Check and configure perf trampoline support."""
538+
# perf trampoline is Linux and macOS specific and requires an arch-specific
539+
# trampoline in assembly
539540
pyconf.checking("perf trampoline")
540541
if v.PLATFORM_TRIPLET in ("x86_64-linux-gnu", "aarch64-linux-gnu"):
541542
perf_trampoline = True
@@ -557,6 +558,7 @@ def setup_perf_trampoline(v):
557558
)
558559
PERF_TRAMPOLINE_OBJ = "Python/asm_trampoline.o"
559560
if v.Py_DEBUG is True:
561+
# perf needs frame pointers for unwinding, include compiler option in debug builds
560562
v.BASECFLAGS += (
561563
" -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"
562564
)

Tools/configure/conf_compiler.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def setup_cxx(v):
9595

9696

9797
def setup_stack_direction(v):
98-
"""Determine stack growth direction."""
98+
# Guess C stack growth direction
9999
v._Py_STACK_GROWS_DOWN = 0 if v.host.startswith("hppa") else 1
100100
pyconf.define(
101101
"_Py_STACK_GROWS_DOWN",
@@ -115,6 +115,8 @@ def check_compiler_bugs(v):
115115
# ---------------------------------------------------------------------------
116116
# glibc _FORTIFY_SOURCE / memmove bug
117117
# ---------------------------------------------------------------------------
118+
# _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
119+
# http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
118120

119121
memmove_cflags = "-O2 -D_FORTIFY_SOURCE=2" if have_o2 else ""
120122
memmove_result = pyconf.run_check(
@@ -151,6 +153,9 @@ def check_compiler_bugs(v):
151153
# ---------------------------------------------------------------------------
152154
# GCC ipa-pure-const inline asm bug
153155
# ---------------------------------------------------------------------------
156+
# Some versions of gcc miscompile inline asm:
157+
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
158+
# http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
154159

155160
if v.ac_cv_gcc_asm_for_x87 is True:
156161
if v.ac_cv_cc_name == "gcc":
@@ -190,6 +195,8 @@ def check_sign_extension_and_getc(v):
190195
# ---------------------------------------------------------------------------
191196
# Sign-extension / right-shift
192197
# ---------------------------------------------------------------------------
198+
# Check whether right shifting a negative integer extends the sign bit
199+
# or fills with zeros (like the Cray J90, according to Tim Peters).
193200

194201
pyconf.checking("whether right shift extends the sign bit")
195202
ac_cv_rshift_extends_sign = pyconf.run_check(
@@ -208,6 +215,7 @@ def check_sign_extension_and_getc(v):
208215
# ---------------------------------------------------------------------------
209216
# getc_unlocked and friends
210217
# ---------------------------------------------------------------------------
218+
# check for getc_unlocked and related locking functions
211219

212220
pyconf.checking("for getc_unlocked() and friends")
213221
ac_cv_have_getc_unlocked = pyconf.link_check(
@@ -406,6 +414,7 @@ def check_compiler_characteristics(v):
406414
# ---------------------------------------------------------------------------
407415
# Compiler characteristics
408416
# ---------------------------------------------------------------------------
417+
# checks for compiler characteristics
409418

410419
pyconf.check_c_const()
411420

@@ -433,10 +442,10 @@ def check_compiler_characteristics(v):
433442
"Define if your compiler supports function prototype",
434443
)
435444

436-
# socketpair
445+
# check for socketpair
437446
pyconf.check_func("socketpair", includes=["sys/types.h", "sys/socket.h"])
438447

439-
# sockaddr.sa_len
448+
# check if sockaddr has sa_len member
440449
pyconf.checking("if sockaddr has sa_len member")
441450
ac_cv_struct_sockaddr_sa_len = pyconf.compile_check(
442451
preamble="#include <sys/types.h>\n#include <sys/socket.h>",
@@ -454,6 +463,7 @@ def check_mbstowcs(v):
454463
# ---------------------------------------------------------------------------
455464
# mbstowcs bug check
456465
# ---------------------------------------------------------------------------
466+
# Check for broken mbstowcs implementation
457467

458468
if pyconf.run_check(
459469
"for broken mbstowcs",
@@ -484,6 +494,7 @@ def check_computed_gotos(v):
484494
# ---------------------------------------------------------------------------
485495
# --with-computed-gotos
486496
# ---------------------------------------------------------------------------
497+
# Check for --with-computed-gotos
487498

488499
if WITH_COMPUTED_GOTOS.is_yes():
489500
pyconf.define(
@@ -499,6 +510,7 @@ def check_computed_gotos(v):
499510
)
500511

501512
# Runtime probe: does the C compiler support computed gotos?
513+
# ac_cv_computed_gotos: check whether the C compiler supports computed gotos
502514
cg_result = pyconf.run_check(
503515
f"whether {v.CC} supports computed gotos",
504516
"""
@@ -523,7 +535,7 @@ def check_computed_gotos(v):
523535

524536

525537
def check_stdatomic(v):
526-
"""Check for stdatomic.h and builtin atomic functions."""
538+
# Check for stdatomic.h and builtin atomic functions (required for mimalloc)
527539
pyconf.checking("for stdatomic.h")
528540
ac_cv_header_stdatomic_h = pyconf.link_check(
529541
"#include <stdatomic.h>\n"
@@ -568,6 +580,7 @@ def check_stdatomic(v):
568580
# Check for __builtin_shufflevector with 128-bit vector support on an
569581
# architecture where it compiles to worthwhile native SIMD instructions.
570582
# Used for SIMD-accelerated bytes.hex() in Python/pystrhex.c.
583+
# Check if compiler supports __builtin_shufflevector with 128-bit vector support
571584
pyconf.checking("for __builtin_shufflevector")
572585
ac_cv_efficient_builtin_shufflevector = pyconf.link_check(
573586
source=(
@@ -615,6 +628,7 @@ def check_sizes(v):
615628
pyconf.check_alignof("max_align_t")
616629
# AC_TYPE_LONG_DOUBLE: check that long double exists (sizeof >= sizeof(double))
617630
# autoconf uses <=, not >: "sizeof(double) <= sizeof(long double)"
631+
# Check that the C compiler supports long double.
618632
if pyconf.compile_check(
619633
preamble="",
620634
body="typedef int test_array[1 - 2 * !(sizeof(double) <= sizeof(long double))];",
@@ -653,6 +667,7 @@ def check_sizes(v):
653667
elif v.ac_cv_pthread:
654668
v.CC = f"{v.CC} -pthread"
655669

670+
# if have pthread_t then define SIZEOF_PTHREAD_T
656671
ac_cv_have_pthread_t = pyconf.compile_check(
657672
preamble="#include <pthread.h>",
658673
body="pthread_t x; x = *(pthread_t*)0;",
@@ -661,6 +676,7 @@ def check_sizes(v):
661676
pyconf.check_sizeof("pthread_t", headers=["pthread.h"])
662677

663678
pyconf.check_sizeof("pthread_key_t", headers=["pthread.h"])
679+
# Check if pthread_key_t is compatible with int
664680
if pyconf.sizeof("pthread_key_t") == pyconf.sizeof(
665681
"int"
666682
) and pyconf.compile_check(

0 commit comments

Comments
 (0)