GH-114809: Add support for macOS multi-arch builds with the JIT enabled (#131751)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
This commit is contained in:
Savannah Ostrowski 2025-04-30 11:03:57 -07:00 committed by GitHub
parent 2b67db7ce3
commit 26c0248b54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 152 additions and 102 deletions

View file

@ -11,7 +11,10 @@ if __name__ == "__main__":
comment = f"$ {shlex.join([pathlib.Path(sys.executable).name] + sys.argv)}"
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"target", type=_targets.get_target, help="a PEP 11 target triple to compile for"
"target",
nargs="+",
type=_targets.get_target,
help="a PEP 11 target triple to compile for",
)
parser.add_argument(
"-d", "--debug", action="store_true", help="compile for a debug build of Python"
@ -23,6 +26,22 @@ if __name__ == "__main__":
"-v", "--verbose", action="store_true", help="echo commands as they are run"
)
args = parser.parse_args()
args.target.debug = args.debug
args.target.verbose = args.verbose
args.target.build(pathlib.Path.cwd(), comment=comment, force=args.force)
for target in args.target:
target.debug = args.debug
target.force = args.force
target.verbose = args.verbose
target.build(
pathlib.Path.cwd(),
comment=comment,
stencils_h=f"jit_stencils-{target.triple}.h",
force=args.force,
)
with open("jit_stencils.h", "w") as fp:
for idx, target in enumerate(args.target):
fp.write(f"#{'if' if idx == 0 else 'elif'} {target.condition}\n")
fp.write(f'#include "jit_stencils-{target.triple}.h"\n')
fp.write("#else\n")
fp.write('#error "unexpected target"\n')
fp.write("#endif\n")