Skip to content

Commit de3bff2

Browse files
committed
Fix install guard glob check and tighten Docker ldd verification
Three follow-up cleanups from re-reviewing the previous three fix commits: 1. ci.yml install guard. The previous guard used ! ls /usr/bin/clang-format-diff-* 2>/dev/null | head -1 which always evaluated as "tool present" because the pipeline exit code is dominated by `head` (returns 0 even on empty input). The guard would never trip even when no clang-format-diff binary existed; the fast-fail intent was lost (the runtime DIFFCMD lookup would still catch it, but later in the workflow). Replace with `compgen -G` which actually fails on a glob miss. 2. Dockerfile ldd verification. `ldd` returns 0 even when shared libraries are reported as "not found", so the previous step proved nothing. Grep for "not found" and exit 1 on hit. Also clarify the slang-static-by-default note since the libslang*.so* glob may legitimately match nothing. 3. fuzz_sdc.cpp had an unused <cstring> include left over from an earlier draft. Remove it. No regression -- ctest 504/504 still passes.
1 parent bc04244 commit de3bff2

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ jobs:
2020
run: |
2121
sudo apt-get update
2222
# Ubuntu's clang-format package ships /usr/bin/clang-format-diff,
23-
# but we install the version-suffixed -diff tool too in case the
24-
# runner image rotates the unversioned symlink.
23+
# but the version-suffixed binaries (clang-format-diff-NN) come
24+
# with the corresponding clang-format-NN package on some images.
2525
sudo apt-get install -y clang-format
2626
# Locate clang-format-diff; fail loudly if absent so the format
2727
# gate cannot silently succeed when the tool is missing.
28+
# Using compgen -G avoids the "ls | head" pipeline whose exit code
29+
# is dominated by `head` (always 0), which would mask a glob miss.
2830
if ! command -v clang-format-diff >/dev/null 2>&1 \
29-
&& ! ls /usr/bin/clang-format-diff-* 2>/dev/null | head -1; then
31+
&& ! compgen -G '/usr/bin/clang-format-diff-*' >/dev/null; then
3032
echo "::error::clang-format-diff not found after apt install; the format gate cannot run."
3133
exit 1
3234
fi

Dockerfile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,26 @@ RUN cmake -B build \
4141
-DSVLENS_FETCH_DEPS=OFF \
4242
&& cmake --build build -j"$(nproc)" \
4343
&& cmake --install build --prefix /usr/local \
44-
&& ldd /usr/local/bin/svlens \
45-
&& /usr/local/bin/svlens --version
44+
&& /usr/local/bin/svlens --version \
45+
&& if ldd /usr/local/bin/svlens | grep -q 'not found'; then \
46+
echo 'ERROR: svlens has unresolved dynamic dependencies'; \
47+
ldd /usr/local/bin/svlens; \
48+
exit 1; \
49+
fi
4650

4751
# Stage the runtime payload at a known path so the final stage uses an
48-
# explicit allow-list rather than copying /usr/local/lib wholesale.
52+
# explicit allow-list rather than copying /usr/local/lib wholesale. With
53+
# scripts/setup-deps.sh's default config slang builds STATIC, so the
54+
# libslang*.so* glob may not match anything; that is expected and the
55+
# binary is self-contained for slang. The libsvlens*.so* glob is kept as
56+
# a forward guard in case a future cmake target ever produces a shared
57+
# library.
4958
RUN install -d /runtime/usr/local/bin /runtime/usr/local/lib \
5059
&& install -m 0755 /usr/local/bin/svlens /runtime/usr/local/bin/svlens \
5160
&& for lib in /usr/local/lib/libslang*.so* /usr/local/lib/libsvlens*.so*; do \
5261
[ -e "$lib" ] && cp -a "$lib" /runtime/usr/local/lib/ || true; \
5362
done \
54-
&& ls -la /runtime/usr/local/lib/
63+
&& ls -la /runtime/usr/local/bin/ /runtime/usr/local/lib/
5564

5665
# ---- runtime ---------------------------------------------------------------
5766
FROM ${DEBIAN_BASE} AS runtime

fuzz/fuzz_sdc.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <cstddef>
1717
#include <cstdint>
1818
#include <cstdlib>
19-
#include <cstring>
2019
#include <filesystem>
2120
#include <string>
2221
#include <unistd.h>

0 commit comments

Comments
 (0)