Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
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.
18 changes: 11 additions & 7 deletions Tools/jit/_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,17 @@ 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("")
Copy link
Contributor

@hroncok hroncok May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure what was the purpose of this line, but it is no longer there. I guess it did nothing, correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Yeah, I think this was originally intended to write a newline, but it was really doing nothing. But I think we do want to add a newline whether or not there's a comment, so I'll move one of them from the comment line to here.

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\n")
for line in _writer.dump(stencil_groups):
file.write(f"{line}\n")
jit_stencils_new.replace(jit_stencils)
finally:
jit_stencils_new.unlink(True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to guess (and look up) what the boolean stands for. Would you mind using a keyword argument instead?

Suggested change
jit_stencils_new.unlink(True)
jit_stencils_new.unlink(missing_ok=True)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good suggestion.



class _COFF(
Expand Down