diff options
Diffstat (limited to 'Tools/jit')
-rw-r--r-- | Tools/jit/_targets.py | 5 | ||||
-rw-r--r-- | Tools/jit/build.py | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py index d0a1c081ffe..b383e39da19 100644 --- a/Tools/jit/_targets.py +++ b/Tools/jit/_targets.py @@ -10,6 +10,7 @@ import re import sys import tempfile import typing +import shlex import _llvm import _schema @@ -46,6 +47,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) pyconfig_dir: pathlib.Path = pathlib.Path.cwd().resolve() @@ -62,6 +64,7 @@ class _Target(typing.Generic[_S, _R]): hasher = hashlib.sha256() hasher.update(self.triple.encode()) hasher.update(self.debug.to_bytes()) + hasher.update(self.cflags.encode()) # These dependencies are also reflected in _JITSources in regen.targets: hasher.update(PYTHON_EXECUTOR_CASES_C_H.read_bytes()) hasher.update((self.pyconfig_dir / "pyconfig.h").read_bytes()) @@ -155,6 +158,8 @@ class _Target(typing.Generic[_S, _R]): f"{o}", f"{c}", *self.args, + # Allow user-provided CFLAGS to override any defaults + *shlex.split(self.cflags), ] await _llvm.run("clang", args, echo=self.verbose) return await self._parse(o) diff --git a/Tools/jit/build.py b/Tools/jit/build.py index 1afd0c76bad..a0733005929 100644 --- a/Tools/jit/build.py +++ b/Tools/jit/build.py @@ -39,11 +39,15 @@ if __name__ == "__main__": parser.add_argument( "-v", "--verbose", action="store_true", help="echo commands as they are run" ) + parser.add_argument( + "--cflags", help="additional flags to pass to the compiler", default="" + ) args = parser.parse_args() for target in args.target: target.debug = args.debug target.force = args.force target.verbose = args.verbose + target.cflags = args.cflags target.pyconfig_dir = args.pyconfig_dir target.build( comment=comment, |