Skip to content

Backport -we4013 to the mswin warnflags for Ruby 3.3#135

Merged
hsbt merged 1 commit into
masterfrom
mswin-3-3-warnflags
Jul 13, 2026
Merged

Backport -we4013 to the mswin warnflags for Ruby 3.3#135
hsbt merged 1 commit into
masterfrom
mswin-3-3-warnflags

Conversation

@hsbt

@hsbt hsbt commented Jul 13, 2026

Copy link
Copy Markdown
Member

Building the json gem against the packaged Ruby 3.3 fails to link with unresolved external symbol __builtin_clzll, which fails the workflow's own extension-build verification. Ruby 3.3 predates ruby/ruby 091c7d4a54, which promotes the mswin C4013 warning to an error. Without that, mkmf's have_func style probe for a compiler builtin compiles a bare implicit declaration and reports a false positive, so json's parser selects __builtin_clzll, a symbol that does not exist under MSVC, and fails at link time. Ruby 3.4 and later already carry the flag and build fine.

This appends -we4013 to the mswin warnflags for the trees that still lack it, mirroring ruby/ruby 091c7d4a54 and the existing vcpkg.json override. The step is guarded by a grep so it patches only Ruby 3.3 and no-ops on 3.4 and later. Verified locally by building Ruby 3.3.11 with the flag, which compiles clean, records -we4013 in the packaged rbconfig.rb, and then lets gem install json succeed where checking for __builtin_clzll() now correctly reports no.

This is a build-side workaround. The proper fix belongs in json, whose builtin probe should link rather than only compile, and that is being pursued upstream. This override can be dropped once a fixed json is widely available.

https://bugs.ruby-lang.org/issues/22180

Generated with Claude Code

Ruby 3.3 predates ruby/ruby 091c7d4a54, which promotes C4013 to an
error on mswin. Without it mkmf's have_func probe for a compiler
builtin such as __builtin_clzll compiles a bare implicit declaration
and reports a false positive, so json's parser selects a symbol that
does not exist under MSVC and fails to link, breaking gem install
json on the packaged 3.3. Patch only the older trees that lack the
flag, mirroring the vcpkg.json override.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 13, 2026 01:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the Windows (mswin) packaging workflow to ensure Ruby 3.3 builds treat MSVC warning C4013 (implicit function declaration) as an error, preventing mkmf false positives that can lead to json selecting __builtin_clzll and failing to link on MSVC. It also documents the rationale in the repository README alongside the existing Ruby 3.3 vcpkg.json override.

Changes:

  • Add a guarded workflow patch that appends -we4013 to src/win32/Makefile.sub only when the flag is not already present (no-op for Ruby 3.4+).
  • Update README documentation to describe the Ruby 3.3 -we4013 backport and why it’s needed.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
README.md Documents the Ruby 3.3-specific -we4013 warnflags backport and its motivation alongside existing mswin packaging details.
.github/workflows/mswin-build.yml Adds a guarded step to patch Ruby 3.3 mswin warnflags to include -we4013 to avoid mkmf/json link failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hsbt hsbt merged commit b68a08a into master Jul 13, 2026
1 check passed
@hsbt hsbt deleted the mswin-3-3-warnflags branch July 13, 2026 01:49
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.

2 participants