From 475be9b9273279d44527681691b42f79def59a6d Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 25 Sep 2026 07:08:13 +0900 Subject: [PATCH 1/2] Let create_header pick up OS_CODE mkmf's create_header ignores $defs entries that do not start with -D, so the leading space dropped OS_CODE from extconf.h. The in-tree build of ruby/ruby then fell back to OS_UNIX in zlib.c, and Zlib::OS_CODE was 3 on Windows. Co-Authored-By: Claude Opus 5.5 --- ext/zlib/extconf.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/zlib/extconf.rb b/ext/zlib/extconf.rb index 2b2dbb1..2187ed1 100644 --- a/ext/zlib/extconf.rb +++ b/ext/zlib/extconf.rb @@ -114,7 +114,7 @@ Logging::message "#{OS_NAMES[os_code]}\n" defines << "OS_CODE=#{os_code}" - $defs.concat(defines.collect{|d|' -D'+d}) + $defs.concat(defines.collect{|d|'-D'+d}) if zsrc $defs << "-DHAVE_CRC32_COMBINE" From 104cbd525f0c80094c8a7e39acb106c7674890f5 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 25 Sep 2026 08:31:59 +0900 Subject: [PATCH 2/2] Check that Zlib::OS_CODE is OS_WIN32 on Windows test_os_code only compared the written os_code with Zlib::OS_CODE itself, so it could not catch OS_CODE falling back to OS_UNIX. Co-Authored-By: Claude Opus 5.5 --- test/zlib/test_zlib.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb index 71159a0..38f39e5 100644 --- a/test/zlib/test_zlib.rb +++ b/test/zlib/test_zlib.rb @@ -677,6 +677,7 @@ def test_os_code assert_equal(Zlib::OS_CODE, f.os_code) end } + assert_equal(Zlib::OS_WIN32, Zlib::OS_CODE) if /mswin|mingw/ =~ RUBY_PLATFORM end def test_orig_name