summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-11-24 08:27:08 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-11-24 08:27:08 +0900
commit48d1e8682c343bca9d40e81200876eae3af01def (patch)
tree6f2567e11386def98535e04aa603860d9246fdab /ext
parent78c40e658848e762b20f069042b5ec4eb853d330 (diff)
zlib: patches for mswin64
* cast to suppress C4267 warnings; no possible loss of data as following the comparison. * shift base address to suppress LNK4281; although /DYNAMICBASE is preferable, not sure from which version of link.exe supports it.
Diffstat (limited to 'ext')
-rw-r--r--ext/zlib/extconf.rb6
-rw-r--r--ext/zlib/extlibs1
-rw-r--r--ext/zlib/win32/zlib-1.2.11-mswin.patch95
3 files changed, 101 insertions, 1 deletions
diff --git a/ext/zlib/extconf.rb b/ext/zlib/extconf.rb
index fd2f168..76cd345 100644
--- a/ext/zlib/extconf.rb
+++ b/ext/zlib/extconf.rb
@@ -31,9 +31,12 @@ else
$extso << dll
$cleanfiles << "$(topdir)/#{dll}" << "$(ZIMPLIB)"
zmk = "\t$(MAKE) -f $(ZMKFILE) TOP=$(ZSRC)"
+ zopts = []
if $nmake
zmkfile = "$(ZSRC)/win32/Makefile.msc"
m = "#{zsrc}/win32/Makefile.msc"
+ # zopts << "USE_ASM=1"
+ zopts << "ARCH=#{RbConfig::CONFIG['target_cpu']}"
else
zmkfile = "$(ZSRC)/win32/Makefile.gcc"
m = "#{zsrc}/win32/Makefile.gcc"
@@ -55,9 +58,10 @@ else
addconf.push(
"ZMKFILE = #{zmkfile}\n",
"ZIMPLIB = #{zimplib}\n",
+ "ZOPTS = #{zopts.join(' ')}\n",
"$(TARGET_SO): $(ZIMPLIB)\n",
"$(ZIMPLIB):\n",
- "#{zmk} $@\n",
+ "#{zmk} $(ZOPTS) $@\n",
"install-so: $(topdir)/#{dll}",
"$(topdir)/#{dll}: $(ZIMPLIB)\n",
"\t$(Q) $(COPY) #{dll} $(@D)\n",
diff --git a/ext/zlib/extlibs b/ext/zlib/extlibs
index c0e0815..a64b37b 100644
--- a/ext/zlib/extlibs
+++ b/ext/zlib/extlibs
@@ -5,3 +5,4 @@ https://zlib.net/$(pkg).tar.gz \
md5:1c9f62f0778697a09d36121ead88e08e \
sha512:73fd3fff4adeccd4894084c15ddac89890cd10ef105dd5e1835e1e9bbb6a49ff229713bd197d203edfa17c2727700fce65a2a235f07568212d820dca88b528ae \
#
+ win32/$(pkg)-mswin.patch -p0
diff --git a/ext/zlib/win32/zlib-1.2.11-mswin.patch b/ext/zlib/win32/zlib-1.2.11-mswin.patch
new file mode 100644
index 0000000..8810b44
--- /dev/null
+++ b/ext/zlib/win32/zlib-1.2.11-mswin.patch
@@ -0,0 +1,95 @@
+diff -ru zlib-1.2.11/gzread.c zlib-1.2.11/gzread.c
+--- zlib-1.2.11/gzread.c 2016-12-31 23:37:10.000000000 +0900
++++ zlib-1.2.11/gzread.c 2020-11-23 19:35:00.550987184 +0900
+@@ -316,7 +316,7 @@
+ /* set n to the maximum amount of len that fits in an unsigned int */
+ n = -1;
+ if (n > len)
+- n = len;
++ n = (unsigned)len;
+
+ /* first just try copying data from the output buffer */
+ if (state->x.have) {
+@@ -397,7 +397,7 @@
+ }
+
+ /* read len or fewer bytes to buf */
+- len = gz_read(state, buf, len);
++ len = (unsigned)gz_read(state, buf, len);
+
+ /* check for an error */
+ if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)
+@@ -469,7 +469,7 @@
+ }
+
+ /* nothing there -- try gz_read() */
+- ret = gz_read(state, buf, 1);
++ ret = (int)gz_read(state, buf, 1);
+ return ret < 1 ? -1 : buf[0];
+ }
+
+diff -ru zlib-1.2.11/gzwrite.c zlib-1.2.11/gzwrite.c
+--- zlib-1.2.11/gzwrite.c 2017-01-15 09:29:40.000000000 +0900
++++ zlib-1.2.11/gzwrite.c 2020-11-23 19:35:41.530494030 +0900
+@@ -209,7 +209,7 @@
+ state->in);
+ copy = state->size - have;
+ if (copy > len)
+- copy = len;
++ copy = (unsigned)len;
+ memcpy(state->in + have, buf, copy);
+ state->strm.avail_in += copy;
+ state->x.pos += copy;
+@@ -229,7 +229,7 @@
+ do {
+ unsigned n = (unsigned)-1;
+ if (n > len)
+- n = len;
++ n = (unsigned)len;
+ state->strm.avail_in = n;
+ state->x.pos += n;
+ if (gz_comp(state, Z_NO_FLUSH) == -1)
+@@ -368,7 +368,7 @@
+
+ /* write string */
+ len = strlen(str);
+- ret = gz_write(state, str, len);
++ ret = (int)gz_write(state, str, len);
+ return ret == 0 && len != 0 ? -1 : ret;
+ }
+
+diff -ru zlib-1.2.11/win32/Makefile.msc zlib-1.2.11/win32/Makefile.msc
+--- zlib-1.2.11/win32/Makefile.msc 2017-01-15 09:07:08.000000000 +0900
++++ zlib-1.2.11/win32/Makefile.msc 2020-11-23 22:37:19.746500208 +0900
+@@ -37,6 +37,22 @@
+ gzwrite.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr.obj zutil.obj
+ OBJA =
+
++!ifdef USE_ASM
++LOC = -DASMV -DASMINF
++!if "$(ARCH)" == "i386"
++OBJA = inffas32.obj match686.obj
++!else if "$(ARCH)" == "x64"
++AS = ml64
++LOC = $(LOC) -I.
++OBJA = inffasx64.obj gvmat64.obj inffas8664.obj
++!endif
++!endif
++
++!if "$(ARCH)" == "x64"
++ZBASE = 0x5A4C000000
++!else
++ZBASE = 0x5A4C0000
++!endif
+
+ # targets
+ all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \
+@@ -49,7 +65,7 @@
+
+ $(SHAREDLIB): $(TOP)/win32/zlib.def $(OBJS) $(OBJA) zlib1.res
+ $(LD) $(LDFLAGS) -def:$(TOP)/win32/zlib.def -dll -implib:$(IMPLIB) \
+- -out:$@ -base:0x5A4C0000 $(OBJS) $(OBJA) zlib1.res
++ -out:$@ -base:$(ZBASE) $(OBJS) $(OBJA) zlib1.res
+ if exist $@.manifest \
+ mt -nologo -manifest $@.manifest -outputresource:$@;2
+