From bfeea66e7a462fda06cfd84e21e1a2a607b3cd44 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 3 Jul 2026 22:06:09 +0000 Subject: [PATCH 1/2] Initial plan From 66f4c77167aea839fb2947974c9ed2d5536a0a0f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 3 Jul 2026 22:35:26 +0000 Subject: [PATCH 2/2] fix: disable HDF5, NetCDF, Poppler in GDAL build to fix DLL init failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ROOT CAUSE: ERROR_DLL_INIT_FAILED (Windows error 1114) when loading libgdal-*.dll in an R session. The HDF5 driver's dependency chain (libhdf5 → libsuperlu → libopenblas → libgfortran-5/libgomp-1/libquadmath-0) conflicts with Rtools45's copies of these same DLLs already loaded by R at startup. Windows' loaded-module list rule reuses the Rtools copy of libgfortran/libgomp for all subsequent DLL loads, regardless of what is in the bundle's bin/. When Rtools45 GCC and MSYS2 UCRT64 GCC versions diverge, libopenblas DllMain returns FALSE → ERROR_DLL_INIT_FAILED. FIX: Set GDAL_USE_HDF5=OFF, GDAL_USE_NETCDF=OFF, GDAL_USE_POPPLER=OFF in cmake configure. Remove corresponding MSYS2 packages from the explicit install list. Update comments and release body table to document the rationale. The build cache key (hashing build_gdal.sh) auto-busts on this change so the next workflow run produces a fresh bundle." --- .github/workflows/build.yml | 14 +++++++++++--- tools/build_gdal.sh | 20 ++++++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 317e5cc..d05b24c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -196,6 +196,14 @@ jobs: # muparser — Algorithmic API (gdal_global_reg_names fix) # pkgconf — pkg-config shim used by cmake find-modules # ntldd — walk PE import tree to find transitive DLL deps + # + # Intentionally omitted (see build_gdal.sh Key build decisions): + # hdf5 — pulls in libopenblas/libgfortran/libgomp which conflict with + # Rtools DLLs in the R process (ERROR_DLL_INIT_FAILED). + # GDAL_USE_HDF5=OFF in cmake configure. + # netcdf — depends on hdf5; same issue. GDAL_USE_NETCDF=OFF. + # poppler — pulls in NSS/NSPR which can fail DllMain on restricted + # Windows environments. GDAL_USE_POPPLER=OFF. - name: Setup MSYS2 UCRT64 id: msys2 uses: msys2/setup-msys2@v2 @@ -220,11 +228,8 @@ jobs: mingw-w64-ucrt-x86_64-zlib mingw-w64-ucrt-x86_64-muparser mingw-w64-ucrt-x86_64-arrow - mingw-w64-ucrt-x86_64-hdf5 - mingw-w64-ucrt-x86_64-netcdf mingw-w64-ucrt-x86_64-geos mingw-w64-ucrt-x86_64-libspatialite - mingw-w64-ucrt-x86_64-poppler mingw-w64-ucrt-x86_64-openjpeg2 mingw-w64-ucrt-x86_64-libwebp mingw-w64-ucrt-x86_64-libjxl @@ -375,6 +380,9 @@ jobs: | `GDAL_HIDE_INTERNAL_SYMBOLS` | `ON` | Cleaner export table | | `--kill-at` | (linker) | Correct stdcall symbol decoration for MinGW DLLs | | Static GCC/stdc++/winpthread | (linker) | No Rtools or MSYS2 required at runtime | + | `GDAL_USE_HDF5` | `OFF` | Eliminates libopenblas/libgfortran/libgomp chain that conflicts with Rtools DLLs already loaded by R (ERROR_DLL_INIT_FAILED) | + | `GDAL_USE_NETCDF` | `OFF` | NetCDF depends on HDF5; disabled for the same reason | + | `GDAL_USE_POPPLER` | `OFF` | Poppler links NSS/NSPR which can fail DllMain initialization on restricted Windows environments | ### Runtime bundle asset Download: diff --git a/tools/build_gdal.sh b/tools/build_gdal.sh index 0dd6fbe..85eb003 100644 --- a/tools/build_gdal.sh +++ b/tools/build_gdal.sh @@ -24,6 +24,21 @@ # OS-provided DLL and breaks LoadLibrary on end-user machines that don't # have that driver installed. The MSSQLSpatial driver falls back to the # generic ODBC32-based path (same as the MSYS2 gdal package). +# - GDAL_USE_HDF5=OFF, GDAL_USE_NETCDF=OFF — HDF5 (and its dependent +# NetCDF) pulls in libopenblas → libgfortran-5/libgomp-1/libquadmath-0. +# R on Windows (Rtools45) already loads its own versions of libgfortran +# and libgomp at process startup. Windows' "loaded-module list" rule means +# these Rtools copies are reused by any subsequently loaded DLL, even when +# a different version lives in the bundle's bin/. When the Rtools and MSYS2 +# versions diverge (e.g. GCC 14 vs GCC 15 snapshot) the mismatched +# libopenblas DllMain returns FALSE → ERROR_DLL_INIT_FAILED (1114) for +# libgdal itself. Disabling HDF5/NetCDF eliminates the entire +# OpenBLAS/Fortran/OpenMP dependency chain from the bundle. +# - GDAL_USE_POPPLER=OFF — Poppler links against Mozilla NSS/NSPR +# (libnspr4/nss3/nssutil3) which perform process-wide initialization on +# load. On locked-down Windows environments this can also produce +# ERROR_DLL_INIT_FAILED. PDF driver support is rarely needed in R spatial +# workflows, so disabling it is a safe trade-off. # ============================================================================= set -euo pipefail @@ -75,12 +90,13 @@ cmake -B build -G Ninja \ -DGDAL_USE_MUPARSER=ON \ -DGDAL_USE_ARROW=ON \ -DGDAL_USE_PARQUET=ON \ - -DGDAL_USE_HDF5=ON \ - -DGDAL_USE_NETCDF=ON \ -DGDAL_USE_GEOS=ON \ -DGDAL_USE_SPATIALITE=ON \ -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ \ + -DGDAL_USE_HDF5=OFF \ + -DGDAL_USE_NETCDF=OFF \ + -DGDAL_USE_POPPLER=OFF \ -DGDAL_USE_MSSQL_ODBC=OFF \ -DGDAL_USE_MSSQL_NCLI=OFF \ \