Skip to content

Use append_cflags for GCC-specific warning flags - #236

Open
hsbt wants to merge 1 commit into
brianmario:masterfrom
hsbt:claude/magical-edison-5dfdf1
Open

Use append_cflags for GCC-specific warning flags#236
hsbt wants to merge 1 commit into
brianmario:masterfrom
hsbt:claude/magical-edison-5dfdf1

Conversation

@hsbt

@hsbt hsbt commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

The extconf.rb unconditionally appended -Wall -funroll-loops -Wno-declaration-after-statement to $CFLAGS. These are GCC and clang flags, so building the gem from source on x64-mswin64 with MSVC failed with command line error D8021 because cl.exe cannot parse -Wno-declaration-after-statement.

This switches to append_cflags, which probes each flag and keeps only the ones the active compiler accepts. On GCC and clang all three flags are still applied, so those builds are unchanged. On MSVC only -Wall survives and the source build succeeds. The vendored yajl C sources themselves need no MSVC changes.

gem install yajl-ruby --platform ruby

now builds with nmake and cl, and Yajl::Parser.parse(Yajl::Encoder.encode({"a" => 1})) works on the resulting install.

cl.exe rejects -Wno-declaration-after-statement with command line
error D8021, breaking source builds on x64-mswin64. append_cflags
keeps only the flags the compiler actually accepts, so GCC and clang
builds are unaffected.

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

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 aims to make the native extension build portable across compilers by avoiding unconditional GCC/clang-only warning flags in extconf.rb, which currently break MSVC builds on Windows.

Changes:

  • Replaces a direct $CFLAGS append of GCC/clang flags with append_cflags(...) to (intended) probe and apply only supported flags.

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

Comment thread ext/yajl/extconf.rb
require 'rbconfig'

$CFLAGS << ' -Wall -funroll-loops -Wno-declaration-after-statement'
append_cflags(%w[-Wall -funroll-loops -Wno-declaration-after-statement])
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