Repository navigation
Treat clang-cl as MSVC on mswin - #56
Merged
Merged
Conversation
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>
kou
reviewed
Oct 18, 2026
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 |
Member
There was a problem hiding this comment.
Ah, we don't need to test for this case with changing RbConfig::CONFIG["CC"]. Could you remove this test change?
| 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"]) |
Member
There was a problem hiding this comment.
Suggested change
| /^(?:clang-)?cl\b/.match(RbConfig::CONFIG["CC"]) | |
| /\A(?:clang-)?cl\b/.match(RbConfig::CONFIG["CC"]) |
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>
Member
|
Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a mswin Ruby built with clang-cl (ruby/ruby#19333),
RbConfig::CONFIG["CC"]isclang-cl -nologo -source-charset:utf-8.PKGConfig.msvc?matches onlycl, soPKGConfig.libsreturns-L/-lflags instead of/libpath:andfoo.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
libasLIBEXT, so this treats it likecl.I ran
bundle exec rakeon 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