Skip to content

Commit 0bad319

Browse files
authored
fix(pipelines/strip): Don't try to strip ELFs for non-native platforms (#2542)
strip only supports the architecture it was built for so when we intentionally package non-native binaries (I.E. cubins), strip fails loudly We still want to strip the binaries we can so skip when the platform isn't the platform strip is being used on Signed-off-by: RJ Sampson <rj.sampson@chainguard.dev>
1 parent 0f1394e commit 0bad319

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

pkg/build/pipelines/strip.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,20 @@ inputs:
1414
pipeline:
1515
- working-directory: ${{targets.contextdir}}
1616
runs: |
17-
scanelf --recursive --nobanner --osabi --etype "ET_DYN,ET_EXEC" . \
18-
| while read type osabi filename; do
17+
# strip does not support stripping files for non-native platforms
18+
case "${{build.arch}}" in
19+
x86_64) native_mach="EM_X86_64" ;;
20+
aarch64) native_mach="EM_AARCH64" ;;
21+
*) echo "strip: unsupported architecture: ${{build.arch}}" >&2; exit 1 ;;
22+
esac
23+
24+
scanelf --recursive --nobanner --osabi --format "%a %o %F" --etype "ET_DYN,ET_EXEC" . \
25+
| while read mach osabi filename; do
1926
2027
[ "$osabi" != "STANDALONE" ] || continue
28+
[ "$mach" = "$native_mach" ] || continue
29+
2130
# scanelf may have picked up a temp file so verify that file still exists
22-
strip ${{inputs.opts}} "${filename}" || [ ! -e "$filename" ]
31+
[ -e "$filename" ] || continue
32+
strip ${{inputs.opts}} "${filename}"
2333
done

0 commit comments

Comments
 (0)