From 9c66a91826b56240626cb933abec0092aa499a96 Mon Sep 17 00:00:00 2001 From: Jan Svabenik Date: Thu, 19 Mar 2026 09:08:15 +0100 Subject: [PATCH] docs: clarify Windows CUDA build paths --- build-sdrplay.ps1 | 1 + build-windows-cuda-app.ps1 | 33 +++++++++++++++++++++++++++++++++ docs/build-cuda.md | 3 ++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 build-windows-cuda-app.ps1 diff --git a/build-sdrplay.ps1 b/build-sdrplay.ps1 index c652eea..d2e4e88 100644 --- a/build-sdrplay.ps1 +++ b/build-sdrplay.ps1 @@ -44,6 +44,7 @@ if (Test-Path $cudaMingw) { Write-Host "Building with SDRplay + cuFFT support..." -ForegroundColor Cyan Write-Host "WARNING: this path still performs final Go linking through MinGW GCC." -ForegroundColor Yellow Write-Host "If CUDA kernel artifacts are MSVC-built, final link may fail due to mixed toolchains." -ForegroundColor Yellow +Write-Host "Use build-cuda-windows.ps1 for CUDA artifact prep; use this script for the current MinGW-oriented app build path." -ForegroundColor Yellow $gccHost = Join-Path $gcc 'g++.exe' if (!(Test-Path $gccHost)) { diff --git a/build-windows-cuda-app.ps1 b/build-windows-cuda-app.ps1 new file mode 100644 index 0000000..d540661 --- /dev/null +++ b/build-windows-cuda-app.ps1 @@ -0,0 +1,33 @@ +$ErrorActionPreference = 'Stop' + +$msvcClDir = 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64' +$vcvars = 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat' +$cudaBin = 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.2\bin' +$cudaInc = 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.2\include' +$sdrplayInc = 'C:\PROGRA~1\SDRplay\API\inc' +$sdrplayLib = 'C:\PROGRA~1\SDRplay\API\x64' +$cudaMingw = Join-Path $PSScriptRoot 'cuda-mingw' + +if (!(Test-Path (Join-Path $msvcClDir 'cl.exe'))) { throw "cl.exe not found at $msvcClDir" } +if (!(Test-Path $vcvars)) { throw "vcvars64.bat not found at $vcvars" } +if (!(Test-Path (Join-Path $cudaBin 'nvcc.exe'))) { throw "nvcc.exe not found at $cudaBin" } + +$env:PATH = "$msvcClDir;$cudaBin;" + $env:PATH +$env:CGO_ENABLED = '1' +$env:CC = 'cl.exe' +$env:CXX = 'cl.exe' +$env:CGO_CFLAGS = "-I$cudaInc -I$sdrplayInc" +$env:CGO_LDFLAGS = "-L$sdrplayLib -lsdrplay_api -L$cudaMingw" + +Write-Host "Preparing CUDA kernel artifacts..." -ForegroundColor Cyan +powershell -ExecutionPolicy Bypass -File tools\build-gpudemod-kernel.ps1 +if ($LASTEXITCODE -ne 0) { throw "kernel build failed" } + +Write-Host "Building Windows CUDA app with MSVC-oriented CGO path..." -ForegroundColor Cyan +Write-Host "NOTE: This path is experimental. Go's CGO runtime still emits GCC-style warning flags that MSVC rejects in this environment." -ForegroundColor Yellow +& cmd.exe /c "call `"$vcvars`" && go build -x -tags `"sdrplay,cufft`" ./cmd/sdrd" +if ($LASTEXITCODE -ne 0) { + throw "windows cuda app build failed (current blocker: Go CGO emits GCC-style flags that cl.exe rejects, e.g. -Werror / -Wall / -fno-stack-protector)" +} + +Write-Host "Done." -ForegroundColor Green diff --git a/docs/build-cuda.md b/docs/build-cuda.md index 454f4ff..b6c92ad 100644 --- a/docs/build-cuda.md +++ b/docs/build-cuda.md @@ -43,4 +43,5 @@ Prefer a GCC/NVCC-oriented build path: - `go test ./...` passes - `go test -tags cufft ./internal/demod/gpudemod` passes with NVCC/MSVC setup - `build-sdrplay.ps1` has progressed past the original invalid `#cgo LDFLAGS` issue -- Remaining Windows blocker is now a toolchain mismatch between MSVC-built CUDA artifacts and MinGW final linking +- Remaining Windows blocker in the default path is a toolchain mismatch between MSVC-built CUDA artifacts and MinGW final linking +- Experimental full-MSVC CGO path (`build-windows-cuda-app.ps1`) also currently blocks because Go's CGO runtime emits GCC-style flags (`-Wall`, `-Werror`, `-fno-stack-protector`) that `cl.exe` rejects in this environment