mirror-llvm-project/cross-project-tests/dtlto/local_codegen_and_wait.py
Ben Dunbobbin 1d74db7e8d
[DTLTO] Make temporary file handling consistent (#176807)
DTLTO emits temporary files to allow distribution of archive member
inputs.

It also emits temporary files from the ThinLTO backend, such as the
index files needed for each distributed ThinLTO backend compilation.

This change brings archive member temporary files into line with those
produced by the ThinLTO backend. They are now emitted in the same
location, warnings are emitted if they cannot be deleted, and they are
cleaned up on abnormal exit (e.g. Ctrl-C). All temporary files are
preserved when --save-temps is specified.

The existing signal-handling test has been extended to cover the full
set of DTLTO temporary files, and a new test has been added to exercise
temporary file handling in normal operation. Additionally, a minimal
test has been added to show the COFF behaviour.

SIE Internal tracker: TOOLCHAIN-21022
2026-01-26 17:55:49 +00:00

20 lines
681 B
Python

"""
This simple distributor performs code generation locally, creates the
"send-signal1" file, and then waits for the "send-signal2" file to appear
before exiting. It is intended to be used in tandem with test_temps.py.
Please see test_temps.py for more information.
"""
import json, subprocess, sys, time, os, pathlib
# Load the DTLTO information from the input JSON file.
data = json.loads(pathlib.Path(sys.argv[-1]).read_bytes())
# Iterate over the jobs and execute the codegen tool.
for job in data["jobs"]:
subprocess.check_call(data["common"]["args"] + job["args"])
pathlib.Path("send-signal1").touch()
while not os.path.exists("send-signal2"):
time.sleep(0.05)