mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 21:15:56 +08:00
CI: statically link the runtime and bundle imported DLLs
- ci: build with -static-libgcc -static-libstdc++ (matching w64devkit, the local toolchain) so the DLLs do not depend on a libstdc++-6.dll that could be shadowed by an incompatible one on the runner - ci: bundle only the non-system DLLs actually imported, taken from the compiler that built them, and print the import list for diagnosis
This commit is contained in:
1 parent
08fe3a8815
commit
e6da1d6fff
1 file changed
+32
-9
@@ -28,33 +28,56 @@ jobs:
|
|||||||
update: false
|
update: false
|
||||||
install: >-
|
install: >-
|
||||||
mingw-w64-x86_64-gcc
|
mingw-w64-x86_64-gcc
|
||||||
|
mingw-w64-x86_64-binutils
|
||||||
mingw-w64-x86_64-cmake
|
mingw-w64-x86_64-cmake
|
||||||
mingw-w64-x86_64-ninja
|
mingw-w64-x86_64-ninja
|
||||||
|
|
||||||
- name: Configure
|
- name: Configure
|
||||||
shell: msys2 {0}
|
shell: msys2 {0}
|
||||||
run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
|
run: |
|
||||||
|
# Link the C/C++ runtime statically, like w64devkit (the toolchain the
|
||||||
|
# project is built with locally). Without this the DLLs depend on
|
||||||
|
# libstdc++-6/libgcc_s_seh-1, which can be shadowed by a different
|
||||||
|
# version elsewhere on the machine and fail to load.
|
||||||
|
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" \
|
||||||
|
-DCMAKE_SHARED_LINKER_FLAGS="-static-libgcc -static-libstdc++"
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
shell: msys2 {0}
|
shell: msys2 {0}
|
||||||
run: |
|
run: |
|
||||||
cmake --build build
|
cmake --build build
|
||||||
|
|
||||||
# Bundle the MinGW runtime DLLs next to the binaries. The integration
|
echo "compiler: $(command -v g++)"
|
||||||
# tests load libagent.dll through System.load, and its dependencies
|
echo "target: $(gcc -dumpmachine)"
|
||||||
# (libstdc++/libgcc/libwinpthread) are otherwise only found via PATH.
|
|
||||||
# copy-bin.bat then carries them into tests/resources as well.
|
echo "--- imports (non-system DLLs) ---"
|
||||||
for dll in libstdc++-6.dll libgcc_s_seh-1.dll libwinpthread-1.dll; do
|
objdump -p build/bin/libagent.dll build/bin/libloader.dll build/bin/libinject.dll \
|
||||||
if [ -f "/mingw64/bin/$dll" ]; then
|
| grep 'DLL Name:' | sed 's/.*DLL Name:[[:space:]]*//' | sort -u
|
||||||
cp -f "/mingw64/bin/$dll" build/bin/
|
|
||||||
|
# Bundle whatever non-system DLLs are still imported, taken from the
|
||||||
|
# toolchain that built them, so the tests can load libagent.dll
|
||||||
|
# without depending on PATH.
|
||||||
|
GCC_BIN="$(dirname "$(command -v gcc)")"
|
||||||
|
deps="$(objdump -p build/bin/libagent.dll build/bin/libloader.dll build/bin/libinject.dll \
|
||||||
|
| grep 'DLL Name:' | sed 's/.*DLL Name:[[:space:]]*//' | sort -u \
|
||||||
|
| grep -viE '^(kernel32|user32|advapi32|ws2_32|shell32|ole32|gdi32|msvcrt|ucrtbase|ntdll|comdlg32|comctl32|psapi|version|iphlpapi|bcrypt|secur32|crypt32|winmm|imm32|netapi32|userenv|rpcrt4|setupapi|mswsock|dnsapi|normaliz)[.]dll$' \
|
||||||
|
| grep -viE '^api-ms-win-')"
|
||||||
|
for dll in $deps; do
|
||||||
|
if [ -f "$GCC_BIN/$dll" ]; then
|
||||||
|
cp -f "$GCC_BIN/$dll" build/bin/
|
||||||
|
echo "bundled $dll"
|
||||||
|
else
|
||||||
|
echo "MISSING $dll (not found in $GCC_BIN)"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "--- build/bin ---"
|
echo "--- build/bin ---"
|
||||||
ls -1 build/bin
|
ls -1 build/bin
|
||||||
|
|
||||||
- name: Run integration tests
|
- name: Run integration tests
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
# Prepend the toolchain bin as a fallback for the runtime DLLs.
|
# Fallback for any remaining runtime DLLs.
|
||||||
$env:PATH = "C:\msys64\mingw64\bin;$env:PATH"
|
$env:PATH = "C:\msys64\mingw64\bin;$env:PATH"
|
||||||
./tests/run-tests.ps1
|
./tests/run-tests.ps1
|
||||||
Reference in new issue
Block a user