镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

feat: add native gem for aarch64-mingw-ucrt (Windows on ARM64) - #778

Open
mrhoribu wants to merge 3 commits into
sparklemotion:mainfrom
mrhoribu:feat/aarch64-mingw-ucrt-native-gem
Open

mrhoribu wants to merge 3 commits into
sparklemotion:mainfrom
mrhoribu:feat/aarch64-mingw-ucrt-native-gem

Conversation

@mrhoribu

@mrhoribu mrhoribu commented Nov 15, 2026 •

Copy link
Copy Markdown

What

Ship a precompiled sqlite3 gem for Windows on ARM64 (aarch64-mingw-ucrt). Today Windows ARM64 users get the source gem and must compile SQLite.

The pinned rake-compiler-dock (1.12.0) already provides an aarch64-mingw-ucrt image. It is the same approach Nokogiri used for its aarch64-mingw-ucrt gem in sparklemotion/nokogiri#3530.

Prior work: #650 and flavorjones/mini_portile#167

This continues #650 by YOU54F, which proposed the same platform with a recipe.host override in extconf.rb. On that PR flavorjones asked whether an upstream fix was pending, and whether it was in a release that could be pinned instead. YOU54F then opened flavorjones/mini_portile#167, which normalizes *-windows-gnu triples inside detect_host. They closed #650 and planned a platform-only PR once a mini_portile release shipped the fix.

The answer to the pin question: no released mini_portile2 has the fix. flavorjones/mini_portile#167 is still open, and the latest release is 2.8.9 (May 2025). So this PR brings back a narrow override as a stopgap:

  • It only rewrites *-w64-windows-gnu to *-w64-mingw32. Every other triple passes through unchanged.
  • Once a mini_portile2 release normalizes the triple, $CC -v will already yield *-mingw32 and the line becomes a no-op. The code comment says to remove it then and require that mini_portile2 version.
  • Overriding recipe.host after MiniPortile.new makes mini_portile treat the build as cross-compiling (host != original_host). As a result activate prepends -L<lib> to ENV["LDFLAGS"], which normalizing in detect_host would not do. In sqlite3 this has no effect today: activate is the last mini_portile step, and mkmf never reads ENV["LDFLAGS"] afterwards. It is one more reason to treat the override as temporary.

Whether to take the stopgap now or wait for a mini_portile release is the maintainers' call. Credit to YOU54F for the original work, in the CHANGELOG too.

Changes

Commit 1, fix(extconf):

  • ext/sqlite3/extconf.rb: mini_portile takes --host from $CC -v. llvm-mingw (the RCD aarch64-mingw-ucrt toolchain, and the clang toolchain RubyInstaller uses on Windows ARM64) reports aarch64-w64-windows-gnu, and sqlite's config.sub rejects it with "Kernel 'windows' not known to work with OS 'gnu'". The fix rewrites *-w64-windows-gnu to *-w64-mingw32. Using RbConfig's host instead broke x64-mingw-ucrt, which reports x64-w64-mingw32, so the rewrite is deliberately limited to the llvm-mingw triple.
  • .github/workflows/ci.yml: the test job and the source-gem install job ("test source") now also compile from source on windows-11-arm, with the packaged sqlite, on Ruby 3.4 and 4.0. Both jobs used runs-on: ${{ matrix.os }}-latest, so they now take an optional matrix.runner and fall back to that.
  • CHANGELOG.md: a Fixed entry for the source build.

Commit 2, feat:

  • rakelib/native.rake: add aarch64-mingw-ucrt to cross_platforms. The RCD image only has Ruby 3.4 and 4.0, because there is no RubyInstaller for Windows ARM64 before 3.4. rake-compiler warns, skips 3.2 and 3.3 for this platform, and derives required_ruby_version (>= 3.4, < 4.1.dev) from the versions it built.
  • .github/workflows/build-gems.yml: add the platform to the native build matrix. The release workflow uses this file, so the release flow picks it up as well.
  • bin/test-gem-file-contents: per-platform supported Ruby versions. It also asserts the gem does not claim a Ruby it has no binary for.
  • .github/workflows/ci.yml: new test_aarch64_mingw_ucrt job on windows-11-arm, which installs the native gem and runs the suite on Ruby 3.4 and 4.0. It is separate from test_the_rest so it doesn't cross with 3.2 and 3.3.
  • INSTALLATION.md, CHANGELOG.md: list the platform.

Commit 3, doc: add the PR references to the CHANGELOG entries.

The extconf fix comes first, so every commit builds.

Verification

  • Full CI on this branch passed (on 9d18781, before the CHANGELOG-only commit), 141/141 jobs. That includes:

    • build native (aarch64-mingw-ucrt), which runs bin/test-gem-file-contents and the per-platform Ruby version checks;
    • installing the native gem and running the full test suite on windows-11-arm with Ruby 3.4 and 4.0;
    • the new source builds on windows-11-arm with Ruby 3.4 and 4.0, in both test and test source, which confirm the extconf fix for RubyInstaller's clang toolchain;
    • x64-mingw-ucrt and every other existing platform, all still passing.
  • The host-triple fix, tested with and without it on the real toolchain. MahtraDR ran a separate probe on windows-11-arm (run 43757252259). It used this PR's 9d18781 plus a single commit that adds only the probe workflow, and built from source on Ruby 3.4.12 and 4.0.9, each with the extconf.rb rewrite line kept and with it removed:

    • In all four jobs, RubyInstaller's CC is clang 23.1.5 from msys2/MINGW-packages. clang -v prints Target: aarch64-w64-windows-gnu, and mini_portile2 2.8.9 detects aarch64-w64-windows-gnu as the host.
    • Rewrite removed: configure is called with --host=aarch64-w64-windows-gnu and fails with Invalid configuration 'aarch64-w64-windows-gnu': Kernel 'windows' not known to work with OS 'gnu'.
    • Rewrite kept: configure is called with --host=aarch64-w64-mingw32, the compile succeeds, and the extension loads with the packaged SQLite 3.54.1.

    ext/ is the same at the current head (the later commit only changes CHANGELOG.md), so this still applies.

  • Nothing was built locally (no Docker). The Linux compile and test suite were run locally after the extconf change.

  • Note: the ARM64 DLLs keep about 190 KB of debug sections each, because rake-compiler-dock leaves out -s for aarch64-mingw (x64 gets it). That is RCD's choice, not something this PR controls.

🤖 Generated with Claude Code

mrhoribu and others added 3 commits November 15, 2026 14:41
mini_portile takes the --host triple from `$CC -v`. llvm-mingw (the
aarch64-mingw-ucrt cross toolchain, and the clang toolchain RubyInstaller
uses on Windows ARM64) reports aarch64-w64-windows-gnu, which sqlite's
config.sub rejects ("Kernel 'windows' not known to work with OS 'gnu'").
Rewrite *-w64-windows-gnu to the equivalent *-w64-mingw32. GCC mingw
toolchains already report *-mingw32, so other platforms are unchanged.

This is a stopgap until a mini_portile2 release normalizes the triple in
detect_host; no released version does yet.

ci: compile from source (packaged sqlite) on windows-11-arm with Ruby
3.4 and 4.0, in both the test and source-gem install jobs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rake-compiler-dock 1.12.0 provides an aarch64-mingw-ucrt image with
Ruby 3.4 and 4.0. Add it to the cross platforms and the build matrix.
rake-compiler skips 3.2/3.3 for that platform and sets the gem's
required_ruby_version to >= 3.4.

- bin/test-gem-file-contents: per-platform supported ruby versions,
  and assert the gem does not claim rubies it has no binary for
- ci: install-test the gem on windows-11-arm with Ruby 3.4 and 4.0
- docs: INSTALLATION platform list and CHANGELOG

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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