FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.10] bpo-46576: bpo-46524: Disable compiler optimization within test_peg_generator by gpshead · Pull Request #31089 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test_peg_generator now disables compiler optimization when testing
compilation of its own C extensions to significantly speed up the
testing on non-debug builds of CPython.
10 changes: 10 additions & 0 deletions Tools/peg_generator/pegen/build.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pathlib
import shutil
import tokenize
import sys
import sysconfig
import tempfile
import itertools
Expand Down Expand Up @@ -33,6 +34,7 @@ def compile_c_extension(
build_dir: Optional[str] = None,
verbose: bool = False,
keep_asserts: bool = True,
disable_optimization: bool = True, # Significant test_peg_generator speedup.
) -> str:
"""Compile the generated source for a parser generator into an extension module.

Expand Down Expand Up @@ -62,6 +64,14 @@ def compile_c_extension(
extra_link_args = get_extra_flags("LDFLAGS", "PY_LDFLAGS_NODIST")
if keep_asserts:
extra_compile_args.append("-UNDEBUG")
if disable_optimization:
if sys.platform == 'win32':
extra_compile_args.append("/Od")
extra_link_args.append("/LTCG:OFF")
else:
extra_compile_args.append("-O0")
if sysconfig.get_config_var("GNULD") == "yes":
extra_link_args.append("-fno-lto")
extension = [
Extension(
extension_name,
Expand Down

Back | FazBrowse Home | New Git URL