diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py index b3b065652e0bb0..bb9f34807ef6fc 100644 --- a/Tools/jit/_targets.py +++ b/Tools/jit/_targets.py @@ -7,6 +7,7 @@ import os import pathlib import re +import shlex import sys import tempfile import typing @@ -42,6 +43,7 @@ class _Target(typing.Generic[_S, _R]): stable: bool = False debug: bool = False verbose: bool = False + cflags: str = "" known_symbols: dict[str, int] = dataclasses.field(default_factory=dict) def _get_nop(self) -> bytes: @@ -115,6 +117,7 @@ async def _compile( ) -> _stencils.StencilGroup: o = tempdir / f"{opname}.o" args = [ + *shlex.split(self.cflags), f"--target={self.triple}", "-DPy_BUILD_CORE_MODULE", "-D_DEBUG" if self.debug else "-DNDEBUG", diff --git a/Tools/jit/build.py b/Tools/jit/build.py index a8cb0f67c36363..663874ad439838 100644 --- a/Tools/jit/build.py +++ b/Tools/jit/build.py @@ -22,7 +22,11 @@ parser.add_argument( "-v", "--verbose", action="store_true", help="echo commands as they are run" ) + parser.add_argument( + "--with-cflags", help="additional flags to pass to the compiler", default="" + ) args = parser.parse_args() args.target.debug = args.debug args.target.verbose = args.verbose + args.target.cflags = args.with_cflags args.target.build(pathlib.Path.cwd(), comment=comment, force=args.force) diff --git a/configure b/configure index 1b75ddfa26dcdd..3c9e550b5d3fd5 100755 --- a/configure +++ b/configure @@ -8399,7 +8399,7 @@ then : else case e in #( e) as_fn_append CFLAGS_NODIST " $jit_flags" - REGEN_JIT_COMMAND="\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py $host" + REGEN_JIT_COMMAND="\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py $host --with-cflags=\"\$(CONFIGURE_CFLAGS)\"" JIT_STENCILS_H="jit_stencils.h" if test "x$Py_DEBUG" = xtrue then : diff --git a/configure.ac b/configure.ac index c449bb5ebb3cd4..5f9d08a4ee70f7 100644 --- a/configure.ac +++ b/configure.ac @@ -1827,7 +1827,7 @@ AS_VAR_IF([jit_flags], [], [AS_VAR_APPEND([CFLAGS_NODIST], [" $jit_flags"]) AS_VAR_SET([REGEN_JIT_COMMAND], - ["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py $host"]) + ["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py $host --with-cflags=\"\$(CONFIGURE_CFLAGS)\""]) AS_VAR_SET([JIT_STENCILS_H], ["jit_stencils.h"]) AS_VAR_IF([Py_DEBUG], [true],