Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7ad9046

Browse files
authored
GH-133779: Fix finding pyconfig.h on Windows JIT builds (GH-134349)
1 parent6b73502 commit7ad9046

File tree

5 files changed

+28
-16
lines changed

5 files changed

+28
-16
lines changed

‎PCbuild/regen.targets

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@
125125
<JITArgsCondition="$(Platform) == 'x64'">x86_64-pc-windows-msvc</JITArgs>
126126
<JITArgsCondition="$(Configuration) == 'Debug'">$(JITArgs) --debug</JITArgs>
127127
</PropertyGroup>
128-
<ExecCommand='$(PythonForBuild) "$(PySourcePath)Tools\jit\build.py" $(JITArgs)'
129-
WorkingDirectory="$(GeneratedJitStencilsDir)"/>
128+
<ExecCommand='$(PythonForBuild) "$(PySourcePath)Tools\jit\build.py" $(JITArgs) --output-dir "$(GeneratedJitStencilsDir)" --pyconfig-dir "$(PySourcePath)PC"'/>
130129
</Target>
131130
<TargetName="_CleanJIT"AfterTargets="Clean">
132131
<DeleteFiles="@(_JITOutputs)"/>

‎Tools/jit/_targets.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class _Target(typing.Generic[_S, _R]):
4747
debug:bool=False
4848
verbose:bool=False
4949
known_symbols:dict[str,int]=dataclasses.field(default_factory=dict)
50+
pyconfig_dir:pathlib.Path=pathlib.Path.cwd().resolve()
5051

5152
def_get_nop(self)->bytes:
5253
ifre.fullmatch(r"aarch64-.*",self.triple):
@@ -57,13 +58,13 @@ def _get_nop(self) -> bytes:
5758
raiseValueError(f"NOP not defined for{self.triple}")
5859
returnnop
5960

60-
def_compute_digest(self,out:pathlib.Path)->str:
61+
def_compute_digest(self)->str:
6162
hasher=hashlib.sha256()
6263
hasher.update(self.triple.encode())
6364
hasher.update(self.debug.to_bytes())
6465
# These dependencies are also reflected in _JITSources in regen.targets:
6566
hasher.update(PYTHON_EXECUTOR_CASES_C_H.read_bytes())
66-
hasher.update((out/"pyconfig.h").read_bytes())
67+
hasher.update((self.pyconfig_dir/"pyconfig.h").read_bytes())
6768
fordirpath,_,filenamesinsorted(os.walk(TOOLS_JIT)):
6869
forfilenameinfilenames:
6970
hasher.update(pathlib.Path(dirpath,filename).read_bytes())
@@ -125,7 +126,7 @@ async def _compile(
125126
f"-D_JIT_OPCODE={opname}",
126127
"-D_PyJIT_ACTIVE",
127128
"-D_Py_JIT",
128-
"-I.",
129+
f"-I{self.pyconfig_dir}",
129130
f"-I{CPYTHON/'Include'}",
130131
f"-I{CPYTHON/'Include'/'internal'}",
131132
f"-I{CPYTHON/'Include'/'internal'/'mimalloc'}",
@@ -193,28 +194,27 @@ async def _build_stencils(self) -> dict[str, _stencils.StencilGroup]:
193194

194195
defbuild(
195196
self,
196-
out:pathlib.Path,
197197
*,
198198
comment:str="",
199199
force:bool=False,
200-
stencils_h:str="jit_stencils.h",
200+
jit_stencils:pathlib.Path,
201201
)->None:
202202
"""Build jit_stencils.h in the given directory."""
203+
jit_stencils.parent.mkdir(parents=True,exist_ok=True)
203204
ifnotself.stable:
204205
warning=f"JIT support for{self.triple} is still experimental!"
205206
request="Please report any issues you encounter.".center(len(warning))
206207
outline="="*len(warning)
207208
print("\n".join(["",outline,warning,request,outline,""]))
208-
digest=f"//{self._compute_digest(out)}\n"
209-
jit_stencils=out/stencils_h
209+
digest=f"//{self._compute_digest()}\n"
210210
if (
211211
notforce
212212
andjit_stencils.exists()
213213
andjit_stencils.read_text().startswith(digest)
214214
):
215215
return
216216
stencil_groups=ASYNCIO_RUNNER.run(self._build_stencils())
217-
jit_stencils_new=out/"jit_stencils.h.new"
217+
jit_stencils_new=jit_stencils.parent/"jit_stencils.h.new"
218218
try:
219219
withjit_stencils_new.open("w")asfile:
220220
file.write(digest)

‎Tools/jit/build.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import_targets
99

1010
if__name__=="__main__":
11-
out=pathlib.Path.cwd().resolve()
1211
comment=f"${shlex.join([pathlib.Path(sys.executable).name]+sys.argv)}"
1312
parser=argparse.ArgumentParser(description=__doc__)
1413
parser.add_argument(
@@ -23,6 +22,20 @@
2322
parser.add_argument(
2423
"-f","--force",action="store_true",help="force the entire JIT to be rebuilt"
2524
)
25+
parser.add_argument(
26+
"-o",
27+
"--output-dir",
28+
help="where to output generated files",
29+
required=True,
30+
type=lambdap:pathlib.Path(p).resolve(),
31+
)
32+
parser.add_argument(
33+
"-p",
34+
"--pyconfig-dir",
35+
help="where to find pyconfig.h",
36+
required=True,
37+
type=lambdap:pathlib.Path(p).resolve(),
38+
)
2639
parser.add_argument(
2740
"-v","--verbose",action="store_true",help="echo commands as they are run"
2841
)
@@ -31,13 +44,13 @@
3144
target.debug=args.debug
3245
target.force=args.force
3346
target.verbose=args.verbose
47+
target.pyconfig_dir=args.pyconfig_dir
3448
target.build(
35-
out,
3649
comment=comment,
37-
stencils_h=f"jit_stencils-{target.triple}.h",
3850
force=args.force,
51+
jit_stencils=args.output_dir/f"jit_stencils-{target.triple}.h",
3952
)
40-
jit_stencils_h=out/"jit_stencils.h"
53+
jit_stencils_h=args.output_dir/"jit_stencils.h"
4154
lines= [f"//{comment}\n"]
4255
guard="#if"
4356
fortargetinargs.target:

‎configure

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing 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} --output-dir . --pyconfig-dir ."])
27802780
AS_VAR_SET([JIT_STENCILS_H],["jit_stencils.h"])
27812781
AS_VAR_IF([Py_DEBUG],
27822782
[true],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp