| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2cc75b6 commit c5bfed5
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,8 @@ | |||
| 17 | 17 | ChildError, DidNotRun) | |
| 18 | 18 | from test.libregrtest.setup import setup_tests | |
| 19 | 19 | from test.libregrtest.pgo import setup_pgo_tests | |
| 20 | - from test.libregrtest.utils import removepy, count, format_duration, printlist | ||
| 20 | + from test.libregrtest.utils import (removepy, count, format_duration, | ||
| 21 | + printlist, get_build_info) | ||
| 21 | 22 | from test import support | |
| 22 | 23 | from test.support import os_helper | |
| 23 | 24 | from test.support import threading_helper | |
@@ -491,6 +492,7 @@ def display_header(self): | |||
| 491 | 492 | print("==", platform.python_implementation(), *sys.version.split()) | |
| 492 | 493 | print("==", platform.platform(aliased=True), | |
| 493 | 494 | "%s-endian" % sys.byteorder) | |
| 495 | + print("== Python build:", ' '.join(get_build_info())) | ||
| 494 | 496 | print("== cwd:", os.getcwd()) | |
| 495 | 497 | cpu_count = os.cpu_count() | |
| 496 | 498 | if cpu_count: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | import math | |
| 2 | 2 | import os.path | |
| 3 | 3 | import sys | |
| 4 | + import sysconfig | ||
| 4 | 5 | import textwrap | |
| 5 | 6 | from test import support | |
| 6 | 7 | ||
@@ -217,3 +218,87 @@ def clear_caches(): | |||
| 217 | 218 | pass | |
| 218 | 219 | else: | |
| 219 | 220 | fractions._hash_algorithm.cache_clear() | |
| 221 | + | ||
| 222 | + | ||
| 223 | + def get_build_info(): | ||
| 224 | + # Get most important configure and build options as a list of strings. | ||
| 225 | + # Example: ['debug', 'ASAN+MSAN'] or ['release', 'LTO+PGO']. | ||
| 226 | + | ||
| 227 | + config_args = sysconfig.get_config_var('CONFIG_ARGS') or '' | ||
| 228 | + cflags = sysconfig.get_config_var('PY_CFLAGS') or '' | ||
| 229 | + cflags_nodist = sysconfig.get_config_var('PY_CFLAGS_NODIST') or '' | ||
| 230 | + ldflags_nodist = sysconfig.get_config_var('PY_LDFLAGS_NODIST') or '' | ||
| 231 | + | ||
| 232 | + build = [] | ||
| 233 | + if hasattr(sys, 'gettotalrefcount'): | ||
| 234 | + # --with-pydebug | ||
| 235 | + build.append('debug') | ||
| 236 | + | ||
| 237 | + if '-DNDEBUG' in (cflags + cflags_nodist): | ||
| 238 | + build.append('without_assert') | ||
| 239 | + else: | ||
| 240 | + build.append('release') | ||
| 241 | + | ||
| 242 | + if '--with-assertions' in config_args: | ||
| 243 | + build.append('with_assert') | ||
| 244 | + elif '-DNDEBUG' not in (cflags + cflags_nodist): | ||
| 245 | + build.append('with_assert') | ||
| 246 | + | ||
| 247 | + # --enable-framework=name | ||
| 248 | + framework = sysconfig.get_config_var('PYTHONFRAMEWORK') | ||
| 249 | + if framework: | ||
| 250 | + build.append(f'framework={framework}') | ||
| 251 | + | ||
| 252 | + # --enable-shared | ||
| 253 | + shared = int(sysconfig.get_config_var('PY_ENABLE_SHARED') or '0') | ||
| 254 | + if shared: | ||
| 255 | + build.append('shared') | ||
| 256 | + | ||
| 257 | + # --with-lto | ||
| 258 | + optimizations = [] | ||
| 259 | + if '-flto=thin' in ldflags_nodist: | ||
| 260 | + optimizations.append('ThinLTO') | ||
| 261 | + elif '-flto' in ldflags_nodist: | ||
| 262 | + optimizations.append('LTO') | ||
| 263 | + | ||
| 264 | + # --enable-optimizations | ||
| 265 | + pgo_options = ( | ||
| 266 | + # GCC | ||
| 267 | + '-fprofile-use', | ||
| 268 | + # clang: -fprofile-instr-use=code.profclangd | ||
| 269 | + '-fprofile-instr-use', | ||
| 270 | + # ICC | ||
| 271 | + "-prof-use", | ||
| 272 | + ) | ||
| 273 | + if any(option in cflags_nodist for option in pgo_options): | ||
| 274 | + optimizations.append('PGO') | ||
| 275 | + if optimizations: | ||
| 276 | + build.append('+'.join(optimizations)) | ||
| 277 | + | ||
| 278 | + # --with-address-sanitizer | ||
| 279 | + sanitizers = [] | ||
| 280 | + if support.check_sanitizer(address=True): | ||
| 281 | + sanitizers.append("ASAN") | ||
| 282 | + # --with-memory-sanitizer | ||
| 283 | + if support.check_sanitizer(memory=True): | ||
| 284 | + sanitizers.append("MSAN") | ||
| 285 | + # --with-undefined-behavior-sanitizer | ||
| 286 | + if support.check_sanitizer(ub=True): | ||
| 287 | + sanitizers.append("UBSAN") | ||
| 288 | + if sanitizers: | ||
| 289 | + build.append('+'.join(sanitizers)) | ||
| 290 | + | ||
| 291 | + # --with-trace-refs | ||
| 292 | + if hasattr(sys, 'getobjects'): | ||
| 293 | + build.append("TraceRefs") | ||
| 294 | + # --enable-pystats | ||
| 295 | + if hasattr(sys, '_stats_on'): | ||
| 296 | + build.append("pystats") | ||
| 297 | + # --with-valgrind | ||
| 298 | + if sysconfig.get_config_var('WITH_VALGRIND'): | ||
| 299 | + build.append("valgrind") | ||
| 300 | + # --with-dtrace | ||
| 301 | + if sysconfig.get_config_var('WITH_DTRACE'): | ||
| 302 | + build.append("dtrace") | ||
| 303 | + | ||
| 304 | + return build | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + The Python test runner (libregrtest) now logs Python build information like | ||
| 2 | + "debug" vs "release" build, or LTO and PGO optimizations. Patch by Victor | ||
| 3 | + Stinner. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments