Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
class _StubLinker:
def __init__(self):
self.calls = []
self.input_types = []

def __call__(self, objFiles, coFileRaw):
self.input_types.append(type(objFiles))
self.calls.append((list(objFiles), coFileRaw))
Path(coFileRaw).write_text("raw") # create the raw file for the move path

Expand Down Expand Up @@ -73,3 +75,24 @@ def test_build_empty_kernels(tmp_path, snapshot):
asmDir.mkdir(); destDir.mkdir()
out = buildAssemblyCodeObjectFiles(_StubLinker(), _StubBundler(), [], destDir, asmDir)
assert out == snapshot


def test_explicit_code_object_link_inputs_are_sorted_and_stable(tmp_path):
asmDir, destDir = tmp_path / "asm", tmp_path / "dest"
asmDir.mkdir(); destDir.mkdir()
observed = []
observed_types = []

for bases in (("z", "a", "m"), ("m", "z", "a")):
linker = _StubLinker()
kernels = [_kernel(base, coFile="CustomCO") for base in bases]
buildAssemblyCodeObjectFiles(
linker, _StubBundler(), kernels, destDir, asmDir, compress=True
)
assert len(linker.calls) == 1
observed.append(linker.calls[0][0])
observed_types.append(linker.input_types[0])

expected = [str(asmDir / f"{base}.o") for base in ("a", "m", "z")]
assert observed == [expected, expected]
assert observed_types == [list, list]
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def buildAssemblyCodeObjectFiles(
coFileMap[asmDir / (coName + extCoRaw)].add(str(asmDir / (kernel["BaseName"] + extObj)))

for coFileRaw, objFiles in coFileMap.items():
linker(objFiles, str(coFileRaw))
linker(sorted(objFiles), str(coFileRaw))
coFile = destDir / coFileRaw.name.replace(extCoRaw, extCo)
if compress:
bundler.compress(str(coFileRaw), str(coFile), gfx)
Expand Down
Loading