Skip to content

Treat clang-cl as MSVC on mswin - #56

Merged
kou merged 3 commits into
ruby-gnome:mainfrom
hsbt:claude/pkg-config-clang-cl-304cce
Oct 19, 2026
Merged

kou merged 3 commits into
ruby-gnome:mainfrom
hsbt:claude/pkg-config-clang-cl-304cce

Conversation

@hsbt

@hsbt hsbt commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

On a mswin Ruby built with clang-cl (ruby/ruby#19333), RbConfig::CONFIG["CC"] is clang-cl -nologo -source-charset:utf-8. PKGConfig.msvc? matches only cl, so PKGConfig.libs returns -L/-l flags instead of /libpath: and foo.lib. Extensions using them, such as nokogiri against a system libxml2, fail to link.

clang-cl is the MSVC-compatible driver and such a Ruby has lib as LIBEXT, so this treats it like cl.

I ran bundle exec rake on mswin Rubies built with clang-cl and with cl, and the new tests on Linux. Results on the cl Ruby and on Linux are unchanged.

Generated with Claude Code

A mswin Ruby built with clang-cl has `clang-cl` in `RbConfig::CONFIG["CC"]`, so `PKGConfig.msvc?` returned false and libs came out as `-L`/`-l` instead of `/libpath:` and `foo.lib`. Extensions using them failed to link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread test/test-pkg-config.rb Outdated
Comment on lines +349 to +355
def assert_msvc(expected, cc)
original_cc = RbConfig::CONFIG["CC"]
RbConfig::CONFIG["CC"] = cc
assert_equal(expected, !!PKGConfig.msvc?)
ensure
RbConfig::CONFIG["CC"] = original_cc
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, we don't need to test for this case with changing RbConfig::CONFIG["CC"]. Could you remove this test change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🆗

Comment thread lib/pkg-config.rb Outdated
def msvc?
/mswin/.match(RUBY_PLATFORM) and /^cl\b/.match(RbConfig::CONFIG["CC"])
/mswin/.match(RUBY_PLATFORM) and
/^(?:clang-)?cl\b/.match(RbConfig::CONFIG["CC"])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/^(?:clang-)?cl\b/.match(RbConfig::CONFIG["CC"])
/\A(?:clang-)?cl\b/.match(RbConfig::CONFIG["CC"])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍

hsbt and others added 2 commits October 18, 2026 18:14
They only exercised the regexp by swapping `RbConfig::CONFIG["CC"]`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kou
kou merged commit 0598eee into ruby-gnome:main Oct 19, 2026
24 checks passed
@kou

kou commented Oct 19, 2026

Copy link
Copy Markdown
Member

Thanks.

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