Windows build: generate the OpenCL import library, drop the SDK dependency

Building the `gpu` (OpenCL) backend on Windows no longer needs a vendor OpenCL
SDK. `cl-sys` links `OpenCL` (#[link(name = "OpenCL")]); instead of requiring an
SDK-provided OpenCL.lib, build.rs now generates a vendor-neutral import library
at build time from windows/OpenCL.def (all 118 cl-sys exports) — lib.exe for
MSVC (located via the cc crate), dlltool for MinGW — and puts it on the link
search path. The real OpenCL.dll is supplied at runtime by the GPU driver.

build.rs no-ops on non-Windows targets and when the gpu feature is off, and
warns rather than panics if the toolchain tool is absent so `cargo check` still
works. Combined with the runtime-loaded (dlopen) CUDA/NVML, a Windows build now
needs zero external GPU libraries.

Add BUILD-windows.md (toolchain, build, crt-static packaging, runtime deps, CI)
and link it from the README. Verified the whole crate compiles for
x86_64-pc-windows-gnu (default features and gpu,cuda); Linux is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jackpotincorporated
2026-06-06 12:38:15 -04:00
parent 8a9d98a21d
commit 00531fb591
6 changed files with 335 additions and 0 deletions
+7
View File
@@ -114,6 +114,13 @@ cargo build --release --no-default-features --features cuda # CUDA only
cargo build --release --no-default-features # CPU-only (no GPU)
```
### Windows
Builds with no external GPU SDKs — CUDA/NVML are loaded at runtime and the
OpenCL import library is generated at build time. See
[BUILD-windows.md](BUILD-windows.md) for the toolchain, build, and packaging
steps.
### Portable / distributable builds
The miner's only runtime dependencies are the C library and the OpenCL ICD loader