|
| 1 | +diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py |
| 2 | +index 50b5d923a35..4a71476026f 100644 |
| 3 | +--- a/Tools/jit/_targets.py |
| 4 | ++++ b/Tools/jit/_targets.py |
| 5 | +@@ -10,6 +10,7 @@ |
| 6 | + import sys |
| 7 | + import tempfile |
| 8 | + import typing |
| 9 | ++import shlex |
| 10 | + |
| 11 | + import _llvm |
| 12 | + import _schema |
| 13 | +@@ -44,6 +45,17 @@ class _Target(typing.Generic[_S, _R]): |
| 14 | + stable: bool = False |
| 15 | + debug: bool = False |
| 16 | + verbose: bool = False |
| 17 | ++ cflags: str = "" |
| 18 | ++ known_symbols: dict[str, int] = dataclasses.field(default_factory=dict) |
| 19 | ++ |
| 20 | ++ def _get_nop(self) -> bytes: |
| 21 | ++ if re.fullmatch(r"aarch64-.*", self.triple): |
| 22 | ++ nop = b"\x1f\x20\x03\xD5" |
| 23 | ++ elif re.fullmatch(r"x86_64-.*|i686.*", self.triple): |
| 24 | ++ nop = b"\x90" |
| 25 | ++ else: |
| 26 | ++ raise ValueError(f"NOP not defined for {self.triple}") |
| 27 | ++ return nop |
| 28 | + |
| 29 | + def _compute_digest(self, out: pathlib.Path) -> str: |
| 30 | + hasher = hashlib.sha256() |
| 31 | +@@ -114,6 +126,7 @@ async def _compile( |
| 32 | + return _stencils.StencilGroup() |
| 33 | + o = tempdir / f"{opname}.o" |
| 34 | + args = [ |
| 35 | ++ *shlex.split(self.cflags), |
| 36 | + f"--target={self.triple}", |
| 37 | + "-DPy_BUILD_CORE_MODULE", |
| 38 | + "-D_DEBUG" if self.debug else "-DNDEBUG", |
| 39 | +diff --git a/Tools/jit/build.py b/Tools/jit/build.py |
| 40 | +index 4a23c6f0afa..618b53804db 100644 |
| 41 | +--- a/Tools/jit/build.py |
| 42 | ++++ b/Tools/jit/build.py |
| 43 | +@@ -22,7 +22,11 @@ |
| 44 | + parser.add_argument( |
| 45 | + "-v", "--verbose", action="store_true", help="echo commands as they are run" |
| 46 | + ) |
| 47 | ++ parser.add_argument( |
| 48 | ++ "--with-cflags", help="additional flags to pass to the compiler", default="" |
| 49 | ++ ) |
| 50 | + args = parser.parse_args() |
| 51 | + args.target.debug = args.debug |
| 52 | + args.target.verbose = args.verbose |
| 53 | ++ args.target.cflags = args.with_cflags |
| 54 | + args.target.build(pathlib.Path.cwd(), comment=comment, force=args.force) |
| 55 | +diff --git a/configure b/configure |
| 56 | +index 1cd1f690f7b..7fb6c4adfea 100755 |
| 57 | +--- a/configure |
| 58 | ++++ b/configure |
| 59 | +@@ -8326,7 +8326,7 @@ then : |
| 60 | + |
| 61 | + else $as_nop |
| 62 | + as_fn_append CFLAGS_NODIST " $jit_flags" |
| 63 | +- REGEN_JIT_COMMAND="\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py $host" |
| 64 | ++ REGEN_JIT_COMMAND="\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py $host --with-cflags=\"\$(CONFIGURE_CFLAGS)\"" |
| 65 | + JIT_STENCILS_H="jit_stencils.h" |
| 66 | + if test "x$Py_DEBUG" = xtrue |
| 67 | + then : |
| 68 | +diff --git a/configure.ac b/configure.ac |
| 69 | +index 3fcb18922c5..616999a96b2 100644 |
| 70 | +--- a/configure.ac |
| 71 | ++++ b/configure.ac |
| 72 | +@@ -1846,7 +1846,7 @@ AS_VAR_IF([jit_flags], |
| 73 | + [], |
| 74 | + [AS_VAR_APPEND([CFLAGS_NODIST], [" $jit_flags"]) |
| 75 | + AS_VAR_SET([REGEN_JIT_COMMAND], |
| 76 | +- ["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py $host"]) |
| 77 | ++ ["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py $host --with-cflags=\"\$(CONFIGURE_CFLAGS)\""]) |
| 78 | + AS_VAR_SET([JIT_STENCILS_H], ["jit_stencils.h"]) |
| 79 | + AS_VAR_IF([Py_DEBUG], |
| 80 | + [true], |
0 commit comments