115115
116116
117117def 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
127127def 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
138138def 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
153153def 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
165165def 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
217218def 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
277281def 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
336337def 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
355353def 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
369364def 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
489483def 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
537537def 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 )
0 commit comments