From 442b527ce8df11754d0c4d820d33dd02f5071ce0 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 18 Nov 2026 10:43:03 +0900 Subject: [PATCH 1/3] Pass the vcpkg pkgconf to mkmf with forward slashes mkmf skips an absolute PKG_CONFIG that File.expand_path would rewrite, so the backslashed path never ran pkgconf and extensions built only through their header and library fallbacks. Co-Authored-By: Claude Opus 5.5 --- dist/index.js | 4 ++-- windows.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6cce5be2a..5143d14c3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -46334,9 +46334,9 @@ async function installVCPKG(url) { LIB: `${vcpkgDir}\\lib;${process.env.LIB}` }) - // Without these, mkmf runs the MSYS2 pkg-config on PATH, whose MinGW flags break MSVC builds, and pkgconf only searches the missing tools\lib\pkgconfig + // Otherwise mkmf runs the MSYS2 pkg-config, whose MinGW flags break MSVC builds. mkmf accepts an absolute PKG_CONFIG only with forward slashes, and pkgconf alone searches just the missing tools\lib\pkgconfig exportEnv({ - PKG_CONFIG: `${vcpkgDir}\\tools\\pkgconf\\pkgconf.exe`, + PKG_CONFIG: `${vcpkgDir}\\tools\\pkgconf\\pkgconf.exe`.replaceAll('\\', '/'), PKG_CONFIG_PATH: `${vcpkgDir}\\lib\\pkgconfig` }) }) diff --git a/windows.js b/windows.js index 1e9b5cd5d..b410e1772 100644 --- a/windows.js +++ b/windows.js @@ -235,9 +235,9 @@ async function installVCPKG(url) { LIB: `${vcpkgDir}\\lib;${process.env.LIB}` }) - // Without these, mkmf runs the MSYS2 pkg-config on PATH, whose MinGW flags break MSVC builds, and pkgconf only searches the missing tools\lib\pkgconfig + // Otherwise mkmf runs the MSYS2 pkg-config, whose MinGW flags break MSVC builds. mkmf accepts an absolute PKG_CONFIG only with forward slashes, and pkgconf alone searches just the missing tools\lib\pkgconfig exportEnv({ - PKG_CONFIG: `${vcpkgDir}\\tools\\pkgconf\\pkgconf.exe`, + PKG_CONFIG: `${vcpkgDir}\\tools\\pkgconf\\pkgconf.exe`.replaceAll('\\', '/'), PKG_CONFIG_PATH: `${vcpkgDir}\\lib\\pkgconfig` }) }) From 0d08440fec3b85c729c811175ffb1554223a9187 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 18 Nov 2026 10:43:29 +0900 Subject: [PATCH 2/3] Add the vcpkg bin directory to PATH on mswin The mswin Ruby ships z.dll, not the libz.dll that vcpkg's libz.lib imports, so a zlib extension built against vcpkg failed to load and then broke RubyGems in that gem home. The other vcpkg DLLs still resolve to the copies in Ruby's own bin first. Co-Authored-By: Claude Opus 5.5 --- dist/index.js | 4 ++-- windows.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 5143d14c3..58542e1f5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -46326,9 +46326,9 @@ async function installVCPKG(url) { return exportCommandEnv(`set "MAKE=nmake" && "${vcVars}"`) }) + const vcpkgDir = `${extractPath}\\installed\\${os.arch()}-windows` await core.group('Setting up vcpkg', async () => { // mswin Rubies do not record the vcpkg location in configure_args, so the compiler and linker find it through INCLUDE and LIB - const vcpkgDir = `${extractPath}\\installed\\${os.arch()}-windows` exportEnv({ INCLUDE: `${vcpkgDir}\\include;${process.env.INCLUDE}`, LIB: `${vcpkgDir}\\lib;${process.env.LIB}` @@ -46341,7 +46341,7 @@ async function installVCPKG(url) { }) }) - return paths + return [...paths, `${vcpkgDir}\\bin`] } // Run a cmd command, export its environment, and return new paths diff --git a/windows.js b/windows.js index b410e1772..e76140688 100644 --- a/windows.js +++ b/windows.js @@ -227,9 +227,9 @@ async function installVCPKG(url) { return exportCommandEnv(`set "MAKE=nmake" && "${vcVars}"`) }) + const vcpkgDir = `${extractPath}\\installed\\${os.arch()}-windows` await core.group('Setting up vcpkg', async () => { // mswin Rubies do not record the vcpkg location in configure_args, so the compiler and linker find it through INCLUDE and LIB - const vcpkgDir = `${extractPath}\\installed\\${os.arch()}-windows` exportEnv({ INCLUDE: `${vcpkgDir}\\include;${process.env.INCLUDE}`, LIB: `${vcpkgDir}\\lib;${process.env.LIB}` @@ -242,7 +242,7 @@ async function installVCPKG(url) { }) }) - return paths + return [...paths, `${vcpkgDir}\\bin`] } // Run a cmd command, export its environment, and return new paths From 1f0488080707a5f8c34703bb063b3a126bc2201a Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 18 Nov 2026 10:46:45 +0900 Subject: [PATCH 3/3] Load C extensions linked to vcpkg libraries on mswin in CI Building fiddle succeeded even while a zlib extension linked to libz.dll could not be loaded. The step activates the installed zlib explicitly, because Ruby also ships a default zlib built against its own z.dll. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 06726e02c..2d53bff55 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -86,7 +86,10 @@ jobs: - name: C extension test run: gem install json -v 2.2.0 - name: C extension test with vcpkg libraries (mswin) - run: gem install fiddle -v 1.1.8 + run: gem install fiddle:1.1.8 zlib:3.2.4 + if: matrix.ruby == 'mswin' + - name: Load C extensions linked to vcpkg libraries (mswin) + run: ruby -rfiddle -e 'gem %q(zlib), %q(3.2.4); require %q(zlib); p Zlib.crc32(%q(a))' if: matrix.ruby == 'mswin' - run: bundle --version # This step is redundant with `bundler-cache: true` but is there to check a redundant `bundle install` still works