Merge bitcoin/bitcoin#35931: ci: Check DLL imports of cross-built bitcoind.exe

67fee5bf44 ci: Check DLL imports of cross-built `bitcoind.exe` (Hennadii Stepanov)

Pull request description:

  Run `dumpbin.exe /imports` on the cross-built `bitcoind.exe` in the "Windows, test cross-built" jobs to list the imported DLLs and to ensure the executable is linked against the expected C runtime.

  This came up during a discussion in https://github.com/bitcoin/bitcoin/pull/35877 ([here](https://github.com/bitcoin/bitcoin/pull/35877#pullrequestreview-4882577358) and [here](https://github.com/bitcoin/bitcoin/pull/35877#issuecomment-5217049246)). Inspired by the analogous CI steps in https://github.com/hebasto/bitcoin-core-nightly.

ACKs for top commit:
  maflcko:
    lgtm ACK 67fee5bf44
  jeanpablojp:
    ACK 67fee5bf44

Tree-SHA512: 3cf054b5c76d5e536f7419ab87e3bc30afea30760fbb3112789a9930098350c0f40ea2c2de4c5b2d1123f1eb58a02aeca28c87461966cf072c3dc86e1b1f106f
This commit is contained in:
Hennadii Stepanov
2026-08-12 09:55:57 +01:00
2 changed files with 32 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
import argparse
import os
import re
import shlex
import subprocess
import sys
@@ -28,6 +29,31 @@ def print_version():
run([str(bitcoind), "-version"])
def check_imports():
bitcoind = Path.cwd() / "bin" / "bitcoind.exe"
output = run(
["dumpbin.exe", "/imports", str(bitcoind)],
capture_output=True,
text=True,
).stdout
dlls = re.findall(r"^\s*(\S+\.dll)\s*$", output, re.IGNORECASE | re.MULTILINE)
print("\n".join(dlls))
# Ensure the executable is linked against the expected C runtime.
dlls = {name.lower() for name in dlls}
uses_msvcrt = "msvcrt.dll" in dlls
uses_ucrt = any(name.startswith("api-ms-win-crt-") for name in dlls)
crt = os.environ["CRT"]
if crt == "msvcrt":
crt_ok = uses_msvcrt and not uses_ucrt
elif crt == "ucrt":
crt_ok = uses_ucrt and not uses_msvcrt
else:
sys.exit(f"Unexpected CRT value: {crt!r}")
if not crt_ok:
sys.exit(f"Imported DLLs do not match the expected {crt!r} C runtime.")
def check_manifests():
release_dir = Path.cwd() / "bin"
manifest_path = release_dir / "bitcoind.manifest"
@@ -143,6 +169,7 @@ def main():
parser = argparse.ArgumentParser(description="Utility to run Windows CI steps.")
steps = list(map(lambda f: f.__name__, [
print_version,
check_imports,
check_manifests,
prepare_tests,
run_unit_tests,

View File

@@ -403,6 +403,11 @@ jobs:
- *IMPORT_VS_ENV
- name: Check imported DLLs
env:
CRT: ${{ matrix.crt }}
run: py -3 .github/ci-windows-cross.py check_imports
- name: Check executable manifests
run: py -3 .github/ci-windows-cross.py check_manifests