Repository navigation
make-binary-drop: count embedded AMDGPU code objects, not a target-triple string - #1448
bong-water-water-bong wants to merge 1 commit into
Conversation
…amd-amdhsa string The drop accepted libggml-hrx.so only if strings found the target triple. The release build's library carries 54 embedded AMDGPU code objects and no such string, so the drop refused every real build, while a 2-object partial build carried it and passed. pack_amdgpu_objects (scripts/pack-elf.sh) counts ELF64 headers whose e_machine is EM_AMDGPU (224). It matches a full header parse on five real libraries (50, 54, 2, 0, 35), and a build with no kernels still counts 0. New fixture test: pack_amdgpu_objects_test.sh. Fixes #1443 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
ready for review at b613985 |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at b613985e.
The counting rule is the property, not a string, and it is the one that is right: \x7fELF, ELFCLASS64, little-endian, then e_machine at
offset 18 equal \xe0\x00 (EM_AMDGPU = 224) — which excludes the outer x86-64 ELF by e_machine 62, precisely the mistake the sibling
implementation makes. My own check on that sibling: a plain gcc executable with zero AMDGPU objects returns 1 there, because it counts the
container's own ELF magic; this rule returns 0, and on a real library it reports 54 where that one reports 56.
Two details that make this more than a regex:
tr '\n' '\377'before the grep, with the reason in the comment: grep is line-oriented, so a header whose skipped bytes contain0x0awould
be split and missed. That is the kind of byte-level bug that makes a count under-report on some libraries and not others.- "Measured equal to a full header parse on five shipped/built libraries" — the pattern is validated against the thing it approximates, which is
the only way a magic-number scan should be trusted.
It also lives where the repo's other pack helpers live (pack_elf.sh, beside pack_normalise_modes/pack_writable_files), is used by
make-binary-drop.sh in the same commit, and has its own test (tests/pack_amdgpu_objects_test.sh, 66 lines).
One thing the test should pin now that the rule is right: the sibling's failure was invisible because its test only asserted non-zero. A case
asserting 0 for a plain x86-64 executable (or a build with no amdgcn objects) would make the "counts the container" bug impossible to
reintroduce — and would have caught the other PR.
Duplicate: #1447 fixes the same make-binary-drop.sh count with the weaker rule; merge-tree reports a conflict between the two. This one is
the one to land.
|
Closing as superseded by #1452, which merged at 11:49Z and closed #1443. I am not rebasing this, because this PR has a real false negative that #1452 does not. While rebasing I measured both rules on six real
Cause: to catch a header containing a 0x0a byte, this PR maps every newline to 0xff before This also corrects what I wrote above: the claims that "a build with no kernels counts 0" and that rlk-build "rightly" counts 0 came from this broken helper. rlk-build has 49 code objects and the add-on export, and main's rule accepts it correctly. #1452's rule ( |
Fixes #1443
make-binary-drop.shacceptedlibggml-hrx.soonly ifstringsfoundamdgcn-amd-amdhsa, so it tested a spelling, not a property. HRX embeds its kernels as raw AMDGPU code objects, and how the library was assembled decides whether that string appears. The release build's library carries 54 code objects and not one copy of the string.Change:
scripts/pack-elf.shgetspack_amdgpu_objects <file>, which counts the ELF64 headers embedded in the file whosee_machineis EM_AMDGPU (224). The outer x86-64 ELF has e_machine 62 and is not counted. The drop now fails only when that count is 0. It needs no new tool:trplusgrep -P. Newlines are mapped to 0xff first, because grep is line-oriented and would otherwise miss a header that holds a 0x0a byte. The fixture test caught that case on the first version.Measured
The count, against a full ELF-header parse in Python, on real libraries on this box:
libggml-hrx.so.0.18.0pack_amdgpu_objectsrelease-rc/work/build)1bit-hrx-41ff9df1bit-canonical(no HIP add-on)A build with no kernels is still refused; it also fails the separate
ggml_hrx_hip_addon_registercheck, which is unchanged.The drop itself, end to end, on the release build:
make-binary-drop.sh <checkout> <out> --build release-rc/work/build --npu-lib <libnpu_rt_api.a>, underthermal-run, output to a scratch dir.origin/mainFAIL libggml-hrx.so carries no HIP code objects,checks failed, nothing written, rc 1checks: ok,drop … written: 21 files. Nothing published., rc 0Test:
tests/pack_amdgpu_objects_test.sh(ctestpack_amdgpu_objects) runs on fixture bytes; it needs no build and no tar. Its rows:On this branch: 8/8 ok. Against
origin/main'smake-binary-drop.sh: the two script rows fail, as they should.pack_modesis still ok, andtools/copyright.py --checkis ok.docs/releases.md("The public binary drop") now says how the kernels-in check counts.Nothing was published or tagged, and no device was used.
🤖 Generated with Claude Code