Skip to content

Commit c8700bb

Browse files
lklimekclaude
andauthored
fix(ci): statically link MinGW runtime for Windows builds (#769)
* fix(ci): statically link MinGW runtime for Windows builds Adds -static-libgcc, -static-libstdc++, and static winpthread rustflags for the x86_64-pc-windows-gnu target so the Windows binary no longer depends on MinGW runtime DLLs absent on user machines. Also sets OPENSSL_STATIC=1 on the build step to statically link OpenSSL. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ci): bundle SQLite statically and add Windows binary sanity check - Add `bundled` feature to rusqlite so SQLite is compiled from source and statically linked, eliminating the sqlite3.dll dependency - Remove the Windows libsql CI step that downloaded sqlite3.dll and created an import library with a broken (null) DLL name entry - Add post-build verification step that inspects the PE import table and fails if null DLL imports or MinGW runtime DLLs are found Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: fix wallet UTXO tests for bundled SQLite FK enforcement Insert the wallet record before the address row in `register_test_address` so the `addresses.seed_hash` FK (enforced when SQLite is compiled with `SQLITE_DEFAULT_FOREIGN_KEYS=1` via the `bundled` feature) is satisfied. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 26be625 commit c8700bb

5 files changed

Lines changed: 27 additions & 6 deletions

File tree

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ rustflags = ["-C", "target-feature=-crt-static", "-C", "target-cpu=x86-64"]
1010
[target.x86_64-pc-windows-gnu]
1111
linker = "x86_64-w64-mingw32-gcc-posix"
1212
ar = "x86_64-w64-mingw32-ar"
13+
rustflags = ["-C", "link-args=-static-libgcc -static-libstdc++ -Wl,-Bstatic -lpthread -Wl,-Bdynamic"]
1314

1415
[env]
1516
CC_x86_64_pc_windows_gnu = "x86_64-w64-mingw32-gcc-posix"

.github/workflows/release.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,32 @@ jobs:
9494
env:
9595
PROTOC: /usr/local/bin/protoc
9696

97-
- name: Windows libsql
98-
if: ${{ matrix.target == 'x86_64-pc-windows-gnu' }}
99-
run: curl -OL https://www.sqlite.org/2024/sqlite-dll-win-x64-3460100.zip && sudo unzip -o sqlite-dll-win-x64-3460100.zip -d winlibs && sudo chown -R runner:docker winlibs/ && pwd && ls -lah && cd winlibs && x86_64-w64-mingw32-dlltool -d sqlite3.def -l libsqlite3.a && ls -lah && cd .. && sudo cp winlibs/libsqlite3.a /usr/x86_64-w64-mingw32/lib/libsqlite3.a
100-
10197
- name: Build project
10298
run: |
10399
cargo build --release --target ${{ matrix.target }}
104100
mv target/${{ matrix.target }}/release/dash-evo-tool${{ matrix.ext }} dash-evo-tool/dash-evo-tool${{ matrix.ext }}
105-
if [ -f winlibs/sqlite3.dll ]; then cp winlibs/sqlite3.dll dash-evo-tool/sqlite3.dll; fi
101+
env:
102+
OPENSSL_STATIC: "1"
103+
104+
- name: Verify Windows binary is self-contained
105+
if: ${{ matrix.target == 'x86_64-pc-windows-gnu' }}
106+
run: |
107+
echo "Checking DLL imports..."
108+
IMPORTS=$(x86_64-w64-mingw32-objdump -p dash-evo-tool/dash-evo-tool.exe | grep "DLL Name:" | sort -u)
109+
echo "$IMPORTS"
110+
# Fail if any null DLL imports (broken import table)
111+
if echo "$IMPORTS" | grep -q "(null)"; then
112+
echo "::error::Binary has null DLL imports — broken import table detected"
113+
exit 1
114+
fi
115+
# Fail if MinGW runtime DLLs are dynamically linked
116+
for dll in libgcc_s_seh-1.dll libwinpthread-1.dll libstdc++-6.dll; do
117+
if echo "$IMPORTS" | grep -qi "$dll"; then
118+
echo "::error::Binary dynamically links $dll — must be statically linked"
119+
exit 1
120+
fi
121+
done
122+
echo "✅ Binary is self-contained — no MinGW runtime or null DLL dependencies"
106123
107124
- name: Package release
108125
run: |

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ arboard = { version = "3.6.0", default-features = false, features = [
5252
"windows-sys",
5353
] }
5454
directories = "6.0.0"
55-
rusqlite = { version = "0.38.0", features = ["functions", "fallible_uint"] }
55+
rusqlite = { version = "0.38.0", features = ["bundled", "functions", "fallible_uint"] }
5656
dark-light = "2.0.0"
5757
image = { version = "0.25.6", default-features = false, features = [
5858
"png",

src/model/wallet/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2752,6 +2752,8 @@ mod tests {
27522752
/// Helper: register a wallet address in the test database so that
27532753
/// `update_address_balance` can find the row.
27542754
fn register_test_address(db: &Database, wallet: &Wallet, address: &Address) {
2755+
db.store_wallet(wallet, &Network::Testnet)
2756+
.expect("store test wallet");
27552757
let seed_hash = wallet.seed_hash();
27562758
let path = DerivationPath::from(vec![
27572759
ChildNumber::Hardened { index: 44 },

0 commit comments

Comments
 (0)