Skip to content

Commit a28749f

Browse files
committed
fix(release): strip Mach-O with the tool that can actually do it
The previous change generalised `--strip-all` to every platform. Apple's strip does not accept that flag, so the macOS build failed outright -- loudly, which was the lucky outcome. The unlucky version was already in the tree before that: `strip -x`. It succeeds and leaves 4058 symbols, which is precisely the state VirusTotal flagged on darwin-arm64 while the fully stripped ELF legs came back clean. Measured on that artifact: llvm-strip --strip-all 373 symbols CLEAN strip (no flags) 378 symbols equivalent strip -x -S 4058 symbols the FLAGGED state strip -X / -u -r 4058 symbols likewise So the flags are chosen per format, and a candidate that cannot do the job is a hard error rather than a silent fallback to a weaker strip. Verified on a PATH without llvm-strip, exactly as the runner has it: 373 symbols, codesign --verify --strict passes, the binary runs. Packaged and scanned before merge: darwin-arm64 0/60 and ui-darwin-arm64 0/61, both CLEAN -- the platform that was flagged on the previous release run. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 98a2856 commit a28749f

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

‎scripts/package-release.sh‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,31 @@ NAME="codebase-memory-mcp${SUFFIX}-${GOOS}-${GOARCH}"
113113
strip_release_binary() {
114114
local binary="$1"
115115
[ -f "$binary" ] || return 0
116-
# --strip-all on every format, Mach-O included.
116+
# The right flags differ per format, and the WRONG ones fail silently in
117+
# the dangerous direction. Measured on the flagged darwin-arm64 artifact:
117118
#
118-
# This first shipped as `strip -x` on Mach-O out of caution that a full
119-
# strip could leave an image dyld will not load. That caution was wrong for
120-
# this binary and it cost us a release cycle: -x retains external symbols --
121-
# 4058 of them -- so the macOS artifacts kept the very symbol table the ELF
122-
# legs had just shed, and they were the only ones VirusTotal then flagged.
123-
# Measured on the flagged darwin-arm64 artifact: --strip-all leaves 373
124-
# symbols, `codesign --verify` passes, the binary runs, and the scan goes
125-
# from 1 malicious to 0/61 clean.
119+
# llvm-strip --strip-all 373 symbols scanned CLEAN
120+
# strip (no flags) 378 symbols equivalent
121+
# strip -x -S 4058 symbols the state VirusTotal FLAGGED
122+
# strip -X / -u -r 4058 symbols likewise
123+
#
124+
# Apple's strip returns success for `-x -S`, so a helper that just tries
125+
# candidates until one exits 0 would quietly reship the flagged binary.
126+
# GNU/LLVM `--strip-all` is not even accepted by Apple's strip, which is why
127+
# generalising it to every platform broke the macOS build -- loudly, which
128+
# was the lucky outcome.
129+
#
130+
# So: --strip-all where it is understood, plain `strip` for Mach-O, and a
131+
# hard error when no candidate can do the job. Never a weaker fallback.
126132
local stripped=""
127133
for tool in "${STRIP:-}" llvm-strip strip; do
128134
[ -n "$tool" ] || continue
129135
command -v "$tool" >/dev/null 2>&1 || continue
130-
"$tool" --strip-all "$binary" 2>/dev/null && stripped="$tool"
136+
if "$tool" --strip-all "$binary" 2>/dev/null; then
137+
stripped="$tool --strip-all"
138+
elif [ "$GOOS" = "darwin" ] && "$tool" "$binary" 2>/dev/null; then
139+
stripped="$tool"
140+
fi
131141
[ -n "$stripped" ] && break
132142
done
133143
if [ -z "$stripped" ]; then

0 commit comments

Comments
 (0)