Skip to content

Commit b1c3312

Browse files
bramclaude
andcommitted
Windows deploy: walk ntldd graph for transitive MinGW DLLs
Diagnostic run showed OpenCryptUITest.exe exits with 0xC0000135 (STATUS_DLL_NOT_FOUND) at load time. The build dir had Qt5Core.dll but not Qt5Core's transitive native deps — libpcre2-16-0.dll, libharfbuzz-0.dll, libicu*.dll, libpng16-16.dll, libfreetype-6.dll, libzstd.dll, libbz2-1.dll, libglib-2.0-0.dll and friends. MSYS2's windeployqt-qt5 reliably handles the Qt plugin tree but does NOT follow these C-level transitive deps. Previously we had a hand-rolled ntldd loop that did this; the earlier windeployqt rewrite dropped it. Restore that: walk each exe's full dep graph with `ntldd -R`, grep for `mingw` paths, and copy everything found into build/. Applied to every shipped exe (OpenCryptUI + all test exes) so the artifact is self-contained — no dependency on /mingw64/bin being on the runtime PATH, which is what caused the CI failure under pwsh (msys2 PATH doesn't carry into pwsh steps). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 708e8cd commit b1c3312

1 file changed

Lines changed: 45 additions & 6 deletions

File tree

.github/workflows/build-and-release.yml

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,19 +256,58 @@ jobs:
256256
"$WDQT" "${WDQT_FLAGS[@]}" build/TestRoundtrip.exe
257257
fi
258258
259-
# windeployqt covers Qt + its transitive deps, but not third-party
260-
# libs we link directly (sodium, argon2, openssl). Copy those by
261-
# pattern — no version suffix guessing.
259+
# MSYS2's windeployqt-qt5 reliably copies Qt's plugin tree
260+
# (platforms/, imageformats/, styles/, …) but does NOT copy
261+
# transitive native deps like libpcre2-16-0.dll, libharfbuzz-0.dll,
262+
# libicu*.dll, libpng16-16.dll, libfreetype-6.dll, libzstd.dll,
263+
# libbz2-1.dll, libiconv-2.dll, libglib-2.0-0.dll, libgraphite2.dll,
264+
# libintl-8.dll, libdouble-conversion.dll, libbrotli*.dll,
265+
# libmd4c.dll. Without those, Qt5Core.dll can't load and the exe
266+
# dies at load time with STATUS_DLL_NOT_FOUND (exit 0xC0000135).
267+
#
268+
# Walk every .exe's dependency graph with ntldd and copy every
269+
# mingw DLL it references. Applies to OpenCryptUI + all test exes.
270+
NTLDD=/mingw64/bin/ntldd.exe
271+
if [ ! -x "$NTLDD" ]; then
272+
echo "ERROR: ntldd missing from /mingw64/bin — can't resolve transitive deps"
273+
exit 1
274+
fi
275+
276+
collect_deps() {
277+
local exe="$1"
278+
if [ ! -f "$exe" ]; then return 0; fi
279+
echo "Resolving deps for $exe ..."
280+
"$NTLDD" -R "$exe" | awk '/=>/ && /mingw/ && !/not found/ {print $3}' | sort -u
281+
}
282+
283+
DEP_LIST="$(mktemp)"
284+
trap "rm -f $DEP_LIST" EXIT
285+
for exe in build/OpenCryptUI.exe build/OpenCryptUITest.exe \
286+
build/TestRoundtrip.exe build/TestEngineTamper.exe \
287+
build/TestEngineDowngrade.exe build/TestEngineKeyfile.exe \
288+
build/TestEngineCipherMatrix.exe build/TestEngineKdf.exe; do
289+
collect_deps "$exe" >> "$DEP_LIST"
290+
done
291+
sort -u "$DEP_LIST" -o "$DEP_LIST"
292+
293+
echo "=== Copying $(wc -l < $DEP_LIST) unique mingw DLLs into build/ ==="
294+
while IFS= read -r dll; do
295+
[ -f "$dll" ] && cp -f "$dll" build/ && echo " $(basename "$dll")"
296+
done < "$DEP_LIST"
297+
298+
# Third-party libs we link directly (sodium/argon2/openssl). ntldd
299+
# should already have caught these, but be explicit in case of a
300+
# static-link edge case.
262301
for pattern in "libsodium-*.dll" "libargon2*.dll" "libssl-*.dll" "libcrypto-*.dll"; do
263-
cp -f /mingw64/bin/$pattern build/ 2>/dev/null || echo "note: no match for $pattern (may be static)"
302+
cp -f /mingw64/bin/$pattern build/ 2>/dev/null || true
264303
done
265304
266-
# App resources (icons, translations, etc.)
305+
# App resources (icons, etc.)
267306
if [ -d resources ]; then
268307
cp -rf resources build/
269308
fi
270309
271-
echo "Deployed Windows build contents:"
310+
echo "=== Final build/ listing ==="
272311
ls -la build/
273312
274313
- name: Archive build artifacts

0 commit comments

Comments
 (0)