Skip to content

build(win): pin pkg-config to the cvcpkg prefixes, unbreaking libcvc-cuda on Windows - #310

Merged
transfix merged 1 commit into
masterfrom
fix/windows-cuda-pkgconfig
Sep 2, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/windows-cuda-pkgconfig

Conversation

@transfix

@transfix transfix commented Sep 2, 2026

Copy link
Copy Markdown
Owner

libcvc-cuda on Windows has been failing to build. Every CUDA translation unit — drive.cu, coef_train.cu, material_rollout.cu, coef_energy_net.cu, material_train.cu, voxels_kernels.cu — dies with ~100 errors each, all inside MSYS2 headers:

C:/msys64/mingw64/include/corecrt.h(159): error : identifier "__UINTPTR_TYPE__" is undefined
C:/msys64/mingw64/include/stdlib.h(274):  error : expected a "{"

The nvcc line carried -IC:\msys64\mingw64\bin\..\include\libpng16 and -IC:\msys64\mingw64\bin\..\include, so MinGW's <stdlib.h>/<corecrt.h> shadowed the MSVC CRT and nvcc's EDG frontend — which predefines neither GCC's nor MinGW's macros — collapsed.

Where those flags came from

When find_package(ImageMagick) fails on Windows, the cvcpkg-prefix fallback sets ImageMagick_FOUND with raw library paths and no imported targets, which is exactly the condition that enables the _im_dep_ delegate loop. That loop calls pkg_check_modules() with nothing scoping the search path. A box with MSYS2 installed has C:\msys64\mingw64\bin on PATH, so find_package(PkgConfig) picks up MSYS2's pkg-config.exe, which searches MSYS2's own .pc tree; libpng resolves there, and PkgConfig::_im_dep_libpng's INTERFACE_INCLUDE_DIRECTORIES land on cvc's own compiles — .cu files included.

The loop's own comment already claims to "probe pkg-config against the SAME prefix". Nothing enforced it.

The fix

PKG_CONFIG_LIBDIR is pinned to CMAKE_PREFIX_PATH's pkgconfig dirs on WIN32, before the first find_package(PkgConfig). It replaces pkg-config's built-in default (PKG_CONFIG_PATH only prepends), so the MSYS2 tree becomes unreachable — and it covers all four probe sites, not just the one that happened to bite.

Plus an MSVC-only configure-time guard rejecting any MinGW include directory on the cvc target. This class of failure has no good symptom — a wall of errors inside system headers, nothing naming the cause — so it's worth failing early with a message that says what to fix.

Why the ordinary Windows lane was green

Not a compiler difference — a runner difference. build-cuda-windows runs on [self-hosted, windows, cuda]; the plain lane runs on GitHub-hosted windows-2022, which has no MSYS2 pkg-config on PATH, so every delegate falls through to find_library. Had cl.exe been handed these flags it would very likely have broken too — so the fix acts on discovery, not on nvcc.

History

This lane has been green exactly once (2026-08-05, run 30974275698) and for the wrong reason: CVC_ENABLE_IMAGEMAGICK was OFF, so the block was skipped entirely. The regression landed 2026-08-28 (#251 broadened the ImageMagick fallback; #252 added the delegate loop gated on precisely that path). It stayed invisible for days because publish_cuda defaults to 'false' on a workflow_dispatch, so the job was skipped in every intervening run — the v3.3.0 tag push was the first to force it on.

Risk

WIN32/MSVC-gated by construction, so the green Linux/macOS/wasm lanes cannot regress — and the delegate loop doesn't run there anyway (stock FindImageMagick supplies the imported targets). Worst case on the CUDA box: a delegate stops resolving via pkg-config and falls through to find_library, which is exactly what the already-green Windows lane does today.

Verified locally: Linux reconfigures clean, no pin applied, ImageMagick still found, nav_material_test 19/19.

Separately noted, not fixed here: the Linux build-cuda lane fails at a different point — Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR python) in the pycvc-cp311-cuda sub-build.

…cuda on Windows

Every CUDA translation unit failed on the self-hosted Windows CUDA runner with
~100 errors each, all inside MSYS2 headers:

    C:/msys64/mingw64/include/corecrt.h(159): error : identifier "__UINTPTR_TYPE__" is undefined
    C:/msys64/mingw64/include/stdlib.h(274):  error : expected a "{"

The nvcc command line carried -IC:\msys64\mingw64\bin\..\include\libpng16 and
-IC:\msys64\mingw64\bin\..\include, so MinGW's <stdlib.h>/<corecrt.h> shadowed
the MSVC CRT and nvcc's EDG frontend — which predefines neither GCC's nor
MinGW's macros — collapsed.

Where they came from: when find_package(ImageMagick) fails on Windows, the
cvcpkg-prefix fallback sets ImageMagick_FOUND with raw library paths and creates
no imported targets, which enables the _im_dep_ delegate loop. That loop calls
pkg_check_modules() with nothing scoping the search path. A box with MSYS2
installed has C:\msys64\mingw64\bin on PATH, so find_package(PkgConfig) picks up
MSYS2's pkg-config.exe and it searches MSYS2's own .pc tree; libpng resolves
there, and PkgConfig::_im_dep_libpng's INTERFACE_INCLUDE_DIRECTORIES land on
cvc's own compiles — .cu files included. The loop's own comment already claimed
to "probe pkg-config against the SAME prefix"; nothing enforced it.

PKG_CONFIG_LIBDIR is now pinned to CMAKE_PREFIX_PATH's pkgconfig dirs on WIN32
before the first find_package(PkgConfig). It REPLACES pkg-config's built-in
default (PKG_CONFIG_PATH only prepends), so the MSYS2 tree becomes unreachable,
and it covers all four probe sites rather than the one that happened to fail.

Also adds an MSVC-only configure-time guard that rejects any MinGW include
directory on the cvc target. This class of failure has no good symptom — it
surfaces as a wall of errors inside system headers with nothing naming the
cause — so it is worth failing early with a message that says what to fix.

Not a compiler difference: the ordinary Windows lane is green only because the
GitHub-hosted windows-2022 image has no MSYS2 pkg-config on PATH, so every
delegate falls through to find_library. Had cl.exe been handed these flags it
would very likely have broken too.

Windows-only by construction, so the green Linux/macOS/wasm lanes cannot regress
— and the delegate loop does not run there anyway (stock FindImageMagick
supplies the imported targets). Verified locally: Linux reconfigures clean, no
pin applied, ImageMagick still found, nav_material_test 19/19.
@transfix
transfix merged commit 46f4d4b into master Sep 2, 2026
13 checks passed
@transfix
transfix deleted the fix/windows-cuda-pkgconfig branch October 29, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant