Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
GH-118943: Fix a race condition when generating jit_stencils.h (GH-11…
…8957)

(cherry picked from commit 4702b7b)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
  • Loading branch information
brandtbucher authored and miss-islington committed May 16, 2024
commit e6bf1a830cc0d217ec341db9d5a6cbe581880379
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix a possible race condition affecting parallel builds configured with
``--enable-experimental-jit``, in which compilation errors could be caused
by an incompletely-generated header file.
19 changes: 12 additions & 7 deletions Tools/jit/_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,18 @@ def build(
):
return
stencil_groups = asyncio.run(self._build_stencils())
with jit_stencils.open("w") as file:
file.write(digest)
if comment:
file.write(f"// {comment}\n\n")
file.write("")
for line in _writer.dump(stencil_groups):
file.write(f"{line}\n")
jit_stencils_new = out / "jit_stencils.h.new"
try:
with jit_stencils_new.open("w") as file:
file.write(digest)
if comment:
file.write(f"// {comment}\n")
file.write("\n")
for line in _writer.dump(stencil_groups):
file.write(f"{line}\n")
jit_stencils_new.replace(jit_stencils)
finally:
jit_stencils_new.unlink(missing_ok=True)


class _COFF(
Expand Down