Skip to content

Commit a7557a2

Browse files
committed
gh-134273: Propagate CFLAGS to the JIT
1 parent 29af6ce commit a7557a2

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

Tools/jit/_targets.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import pathlib
99
import re
10+
import shlex
1011
import sys
1112
import tempfile
1213
import typing
@@ -42,6 +43,7 @@ class _Target(typing.Generic[_S, _R]):
4243
stable: bool = False
4344
debug: bool = False
4445
verbose: bool = False
46+
cflags: str = ""
4547
known_symbols: dict[str, int] = dataclasses.field(default_factory=dict)
4648

4749
def _get_nop(self) -> bytes:
@@ -115,6 +117,7 @@ async def _compile(
115117
) -> _stencils.StencilGroup:
116118
o = tempdir / f"{opname}.o"
117119
args = [
120+
*shlex.split(self.cflags),
118121
f"--target={self.triple}",
119122
"-DPy_BUILD_CORE_MODULE",
120123
"-D_DEBUG" if self.debug else "-DNDEBUG",

Tools/jit/build.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
parser.add_argument(
2323
"-v", "--verbose", action="store_true", help="echo commands as they are run"
2424
)
25+
parser.add_argument(
26+
"--with-cflags", help="additional flags to pass to the compiler", default=""
27+
)
2528
args = parser.parse_args()
2629
args.target.debug = args.debug
2730
args.target.verbose = args.verbose
31+
args.target.cflags = args.with_cflags
2832
args.target.build(pathlib.Path.cwd(), comment=comment, force=args.force)

configure

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ AS_VAR_IF([jit_flags],
18271827
[],
18281828
[AS_VAR_APPEND([CFLAGS_NODIST], [" $jit_flags"])
18291829
AS_VAR_SET([REGEN_JIT_COMMAND],
1830-
["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py $host"])
1830+
["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py $host --with-cflags=\"\$(CONFIGURE_CFLAGS)\""])
18311831
AS_VAR_SET([JIT_STENCILS_H], ["jit_stencils.h"])
18321832
AS_VAR_IF([Py_DEBUG],
18331833
[true],

0 commit comments

Comments
 (0)