Skip to content

Commit 7d12a8a

Browse files
committed
gh-134273: Propagate CFLAGS to the JIT
1 parent 42d03f3 commit 7d12a8a

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
@@ -10,6 +10,7 @@
1010
import sys
1111
import tempfile
1212
import typing
13+
import shlex
1314

1415
import _llvm
1516
import _schema
@@ -46,6 +47,7 @@ class _Target(typing.Generic[_S, _R]):
4647
stable: bool = False
4748
debug: bool = False
4849
verbose: bool = False
50+
cflags: str = ""
4951
known_symbols: dict[str, int] = dataclasses.field(default_factory=dict)
5052

5153
def _get_nop(self) -> bytes:
@@ -119,6 +121,7 @@ async def _compile(
119121
) -> _stencils.StencilGroup:
120122
o = tempdir / f"{opname}.o"
121123
args = [
124+
*shlex.split(self.cflags),
122125
f"--target={self.triple}",
123126
"-DPy_BUILD_CORE_MODULE",
124127
"-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
@@ -26,11 +26,15 @@
2626
parser.add_argument(
2727
"-v", "--verbose", action="store_true", help="echo commands as they are run"
2828
)
29+
parser.add_argument(
30+
"--with-cflags", help="additional flags to pass to the compiler", default=""
31+
)
2932
args = parser.parse_args()
3033
for target in args.target:
3134
target.debug = args.debug
3235
target.force = args.force
3336
target.verbose = args.verbose
37+
target.cflags = args.with_cflags
3438
target.build(
3539
out,
3640
comment=comment,

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
@@ -2776,7 +2776,7 @@ AS_VAR_IF([jit_flags],
27762776
[],
27772777
[AS_VAR_APPEND([CFLAGS_NODIST], [" $jit_flags"])
27782778
AS_VAR_SET([REGEN_JIT_COMMAND],
2779-
["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py ${ARCH_TRIPLES:-$host}"])
2779+
["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py ${ARCH_TRIPLES:-$host} --with-cflags=\"\$(CONFIGURE_CFLAGS)\""])
27802780
AS_VAR_SET([JIT_STENCILS_H], ["jit_stencils.h"])
27812781
AS_VAR_IF([Py_DEBUG],
27822782
[true],

0 commit comments

Comments
 (0)