github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r origin/main...HEAD
clang/test/Driver/Inputs/clang-offload-bundler-magic-collision.py
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- clang-offload-bundler-magic-collision.py 2026-06-24 15:59:41.000000 +0000
+++ clang-offload-bundler-magic-collision.py 2026-06-24 16:05:50.343061 +0000
@@ -34,28 +34,40 @@
def main():
if len(sys.argv) < 2:
sys.exit("usage: %s <clang-offload-bundler> [output.co]" % sys.argv[0])
bundler = sys.argv[1]
- out = sys.argv[2] if len(sys.argv) > 2 else \
- os.path.join(os.path.dirname(os.path.abspath(__file__)),
- "clang-offload-bundler-magic-collision.co")
+ out = (
+ sys.argv[2]
+ if len(sys.argv) > 2
+ else os.path.join(
+ os.path.dirname(os.path.abspath(__file__)),
+ "clang-offload-bundler-magic-collision.co",
+ )
+ )
with tempfile.TemporaryDirectory() as d:
dev1 = os.path.join(d, "dev1")
dev2 = os.path.join(d, "dev2")
with open(dev1, "wb") as f:
f.write(b"Content of device file 1\n")
with open(dev2, "wb") as f:
f.write(b"Content of device file 2\n")
base = os.path.join(d, "base.co")
subprocess.run(
- [bundler, "-compress", "-type=bc",
- "-targets=hip-amdgcn-amd-amdhsa--gfx906,"
- "hip-amdgcn-amd-amdhsa--gfx908",
- "-input=" + dev1, "-input=" + dev2, "-output=" + base],
- check=True)
+ [
+ bundler,
+ "-compress",
+ "-type=bc",
+ "-targets=hip-amdgcn-amd-amdhsa--gfx906,"
+ "hip-amdgcn-amd-amdhsa--gfx908",
+ "-input=" + dev1,
+ "-input=" + dev2,
+ "-output=" + base,
+ ],
+ check=True,
+ )
data = bytearray(open(base, "rb").read())
if data[:4] != b"CCOB":
sys.exit("unexpected magic in compressed bundle")
version = struct.unpack_from("<H", data, 4)[0]
@@ -70,22 +82,23 @@
if file_size != len(data):
sys.exit("FileSize %d != file length %d" % (file_size, len(data)))
# Splice a zstd skippable frame carrying "CCOB" right after the header, so
# the planted magic lands inside the compressed region.
- skip = struct.pack("<II", ZSTD_SKIPPABLE_MAGIC, len(PLANTED_MAGIC)) \
- + PLANTED_MAGIC
+ skip = struct.pack("<II", ZSTD_SKIPPABLE_MAGIC, len(PLANTED_MAGIC)) +
PLANTED_MAGIC
data = data[:header_size] + skip + data[header_size:]
struct.pack_into(fs_fmt, data, fs_off, file_size + len(skip))
planted = bytes(data).find(PLANTED_MAGIC, 4)
if planted != header_size + 8:
sys.exit("planted magic at unexpected offset %d" % planted)
with open(out, "wb") as f:
f.write(data)
- print("wrote %s: version=%d header=%d FileSize=%d planted 'CCOB' at %d" %
- (out, version, header_size, file_size + len(skip), planted))
+ print(
+ "wrote %s: version=%d header=%d FileSize=%d planted 'CCOB' at %d"
+ % (out, version, header_size, file_size + len(skip), planted)
+ )
if __name__ == "__main__":
main()
``````````
</details>
https://github.com/llvm/llvm-project/pull/205587
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits