Skip to content

Commit e44eebf

Browse files
authored
gh-124613, regrtest: Detect JIT in build info (#124793)
1 parent 35541c4 commit e44eebf

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

Lib/test/libregrtest/utils.py

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,29 +300,78 @@ def get_build_info():
300300

301301
config_args = sysconfig.get_config_var('CONFIG_ARGS') or ''
302302
cflags = sysconfig.get_config_var('PY_CFLAGS') or ''
303-
cflags_nodist = sysconfig.get_config_var('PY_CFLAGS_NODIST') or ''
303+
cflags += ' ' + (sysconfig.get_config_var('PY_CFLAGS_NODIST') or '')
304304
ldflags_nodist = sysconfig.get_config_var('PY_LDFLAGS_NODIST') or ''
305305

306306
build = []
307307

308308
# --disable-gil
309309
if sysconfig.get_config_var('Py_GIL_DISABLED'):
310-
build.append("free_threading")
310+
if not sys.flags.ignore_environment:
311+
PYTHON_GIL = os.environ.get('PYTHON_GIL', None)
312+
if PYTHON_GIL:
313+
PYTHON_GIL = (PYTHON_GIL == '1')
314+
else:
315+
PYTHON_GIL = None
316+
317+
free_threading = "free_threading"
318+
if PYTHON_GIL is not None:
319+
free_threading = f"{free_threading} GIL={int(PYTHON_GIL)}"
320+
build.append(free_threading)
311321

312322
if hasattr(sys, 'gettotalrefcount'):
313323
# --with-pydebug
314324
build.append('debug')
315325

316-
if '-DNDEBUG' in (cflags + cflags_nodist):
326+
if '-DNDEBUG' in cflags:
317327
build.append('without_assert')
318328
else:
319329
build.append('release')
320330

321331
if '--with-assertions' in config_args:
322332
build.append('with_assert')
323-
elif '-DNDEBUG' not in (cflags + cflags_nodist):
333+
elif '-DNDEBUG' not in cflags:
324334
build.append('with_assert')
325335

336+
# --enable-experimental-jit
337+
tier2 = re.search('-D_Py_TIER2=([0-9]+)', cflags)
338+
if tier2:
339+
tier2 = int(tier2.group(1))
340+
341+
if not sys.flags.ignore_environment:
342+
PYTHON_JIT = os.environ.get('PYTHON_JIT', None)
343+
if PYTHON_JIT:
344+
PYTHON_JIT = (PYTHON_JIT != '0')
345+
else:
346+
PYTHON_JIT = None
347+
348+
if tier2 == 1: # =yes
349+
if PYTHON_JIT == False:
350+
jit = 'JIT=off'
351+
else:
352+
jit = 'JIT'
353+
elif tier2 == 3: # =yes-off
354+
if PYTHON_JIT:
355+
jit = 'JIT'
356+
else:
357+
jit = 'JIT=off'
358+
elif tier2 == 4: # =interpreter
359+
if PYTHON_JIT == False:
360+
jit = 'JIT-interpreter=off'
361+
else:
362+
jit = 'JIT-interpreter'
363+
elif tier2 == 6: # =interpreter-off (Secret option!)
364+
if PYTHON_JIT:
365+
jit = 'JIT-interpreter'
366+
else:
367+
jit = 'JIT-interpreter=off'
368+
elif '-D_Py_JIT' in cflags:
369+
jit = 'JIT'
370+
else:
371+
jit = None
372+
if jit:
373+
build.append(jit)
374+
326375
# --enable-framework=name
327376
framework = sysconfig.get_config_var('PYTHONFRAMEWORK')
328377
if framework:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy