Skip to content

Commit 8171b41

Browse files
committed
macOS 那条腿静默退 1:一个没匹配到的 grep 被 pipefail 提升成了失败
构建报到 1564/1564 之后**没有任何输出**就退了 1。成因是捆绑块里每条流水线都以 grep 结尾,而**一个没匹配到东西的 grep 返回 1** —— pipefail 把它提升为整条流水线的状态, errexit 再把它变成退出。 Linux 那条活了下来,因为它的第二个循环里没有 grep;macOS 的有:已经捆绑进来的 dylib 可能一个 /opt 依赖都不剩,于是 grep 空手而归。 ⭐ 「捆绑步骤没找到东西要捆绑」不是错误;「载荷仍然指向自身之外」才是,而后者由下面 那条断言来说。所以这一段改为 set +e,并在结尾回报捆绑了几个库。 ⚠️ 这是本项目已经记过一次的形状:pipefail 把一次成功的匹配读成失败(那次是 grep -q 被 SIGPIPE 打断读成 141)。同一条管道,反方向。
1 parent 9102ff5 commit 8171b41

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ jobs:
315315
# carrying a second libc into a process is the two-glibcs shape this
316316
# index's own contract text names as a SIGSEGV source.
317317
if [ "$RUNNER_OS" = "Linux" ]; then
318+
set +e # same reason as the macOS branch below
318319
ldd qemu-system-x86_64 \
319320
| awk '/=> \// {print $3}' \
320321
| grep -vE '/(libc|libm|libdl|librt|libpthread|libresolv|ld-linux[^ ]*)\.so' \
@@ -326,7 +327,19 @@ jobs:
326327
sudo apt-get install -y -qq patchelf
327328
patchelf --set-rpath '$ORIGIN/../lib' ../out/bin/qemu-system-x86_64
328329
for so in ../out/lib/*.so*; do patchelf --set-rpath '$ORIGIN' "$so" 2>/dev/null || true; done
330+
echo "bundled: $(ls -1 ../out/lib 2>/dev/null | wc -l) libraries"
331+
set -e
329332
elif [ "$RUNNER_OS" = "macOS" ]; then
333+
# ⚠️ `set +e` FOR THIS BLOCK, AND THE REASON IS A SILENT KILL.
334+
#
335+
# The first version ran under `set -euo pipefail` and died with exit
336+
# 1 and NO output, right after ninja reported 1564/1564. Every
337+
# command here is in a pipeline ending in `grep`, and a `grep` that
338+
# matches nothing returns 1 — which `pipefail` promotes to the
339+
# pipeline's status and `-e` turns into an exit. A bundling step
340+
# that finds nothing to bundle is not an error; a payload that still
341+
# points outside itself is, and the assertion below is what says so.
342+
set +e
330343
# Mach-O records each dependency by the install name the LIBRARY
331344
# carries, so copying is not enough: every reference has to be
332345
# rewritten, and so does each bundled library's own id.
@@ -350,6 +363,8 @@ jobs:
350363
# binary is killed by the kernel rather than merely warned about.
351364
codesign --force -s - ../out/bin/qemu-system-x86_64 2>/dev/null || true
352365
for dy in ../out/lib/*.dylib; do codesign --force -s - "$dy" 2>/dev/null || true; done
366+
echo "bundled: $(ls -1 ../out/lib 2>/dev/null | wc -l) libraries"
367+
set -e
353368
fi
354369
rmdir ../out/lib 2>/dev/null || true
355370

0 commit comments

Comments
 (0)