Bug 763651 - Link the javascript engine against zlib. r=khuey
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 12 Jul 2012 08:30:59 +0200
changeset 99052 4be97839a566d8f482f431801237afc4caac22ae
parent 99051 4761bf12898b036468f524ab64d04322cedabc25
child 99053 341214c1b9641b726e23abbc7e91006587de6f35
push id23099
push useremorley@mozilla.com
push dateThu, 12 Jul 2012 16:29:09 +0000
treeherdermozilla-central@f9499238bd4b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs763651
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 763651 - Link the javascript engine against zlib. r=khuey
Makefile.in
aclocal.m4
build/autoconf/zlib.m4
configure.in
js/src/Makefile.in
js/src/aclocal.m4
js/src/build/autoconf/zlib.m4
js/src/config/Makefile.in
js/src/config/autoconf.mk.in
js/src/configure.in
js/src/jsapi-tests/Makefile.in
js/src/shell/Makefile.in
layout/media/Makefile.in
media/libpng/Makefile.in
modules/libjar/Makefile.in
modules/zlib/src/Makefile.in
modules/zlib/src/mozzconf.h
mozglue/build/Makefile.in
netwerk/streamconv/converters/Makefile.in
toolkit/library/Makefile.in
toolkit/toolkit-tiers.mk
--- a/Makefile.in
+++ b/Makefile.in
@@ -48,16 +48,19 @@ endif
 
 ifdef MOZ_MEMORY
 tier_base_dirs += memory/mozjemalloc
 ifdef MOZ_JEMALLOC
 tier_base_dirs += memory/jemalloc
 endif
 tier_base_dirs += memory/build
 endif
+ifndef MOZ_NATIVE_ZLIB
+tier_base_dirs += modules/zlib
+endif
 tier_base_dirs += \
   mozglue \
   memory/mozalloc \
   $(NULL)
 endif
 
 ifdef COMPILE_ENVIRONMENT
 include $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -14,16 +14,17 @@ builtin(include, build/autoconf/mozcommo
 builtin(include, build/autoconf/acwinpaths.m4)dnl
 builtin(include, build/autoconf/lto.m4)dnl
 builtin(include, build/autoconf/gcc-pr49911.m4)dnl
 builtin(include, build/autoconf/frameptr.m4)dnl
 builtin(include, build/autoconf/compiler-opts.m4)dnl
 builtin(include, build/autoconf/expandlibs.m4)dnl
 builtin(include, build/autoconf/arch.m4)dnl
 builtin(include, build/autoconf/android.m4)dnl
+builtin(include, build/autoconf/zlib.m4)dnl
 
 MOZ_PROG_CHECKMSYS()
 
 # Read the user's .mozconfig script.  We can't do this in
 # configure.in: autoconf puts the argument parsing code above anything
 # expanded from configure.in, and we need to get the configure options
 # from .mozconfig in place before that argument parsing code.
 MOZ_READ_MOZCONFIG(.)
new file mode 100644
--- /dev/null
+++ b/build/autoconf/zlib.m4
@@ -0,0 +1,54 @@
+dnl This Source Code Form is subject to the terms of the Mozilla Public
+dnl License, v. 2.0. If a copy of the MPL was not distributed with this
+dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+dnl Usage: MOZ_ZLIB_CHECK([version])
+
+AC_DEFUN([MOZ_ZLIB_CHECK],
+[
+
+MOZZLIB=$1
+
+MOZ_ARG_WITH_STRING(system-zlib,
+[  --with-system-zlib[=PFX]
+                          Use system libz [installed at prefix PFX]],
+    ZLIB_DIR=$withval)
+
+if test -z "$MOZ_ZLIB_LIBS$MOZ_ZLIB_CFLAGS$SKIP_LIBRARY_CHECKS"; then
+    _SAVE_CFLAGS=$CFLAGS
+    _SAVE_LDFLAGS=$LDFLAGS
+    _SAVE_LIBS=$LIBS
+
+    if test -n "${ZLIB_DIR}" -a "${ZLIB_DIR}" != "yes"; then
+        MOZ_ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
+        MOZ_ZLIB_LIBS="-L${ZLIB_DIR}/lib"
+        CFLAGS="$MOZ_ZLIB_CFLAGS $CFLAGS"
+        LDFLAGS="$MOZ_ZLIB_LIBS $LDFLAGS"
+    fi
+    if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then
+        MOZ_NATIVE_ZLIB=
+    else
+        AC_CHECK_LIB(z, gzread, [MOZ_NATIVE_ZLIB=1 MOZ_ZLIB_LIBS="$MOZ_ZLIB_LIBS -lz"],
+            [MOZ_NATIVE_ZLIB=])
+        if test "$MOZ_NATIVE_ZLIB" = 1; then
+            MOZZLIBNUM=`echo $MOZZLIB | awk -F. changequote(<<, >>)'{printf "0x%x\n", (((<<$>>1 * 16 + <<$>>2) * 16) + <<$>>3) * 16 + <<$>>4}'changequote([, ])`
+            AC_TRY_COMPILE([ #include <stdio.h>
+                             #include <string.h>
+                             #include <zlib.h> ],
+                           [ #if ZLIB_VERNUM < $MOZZLIBNUM
+                             #error "Insufficient zlib version ($MOZZLIBNUM required)."
+                             #endif ],
+                           MOZ_NATIVE_ZLIB=1,
+                           AC_MSG_ERROR([Insufficient zlib version for --with-system-zlib ($MOZZLIB required)]))
+        fi
+    fi
+    CFLAGS=$_SAVE_CFLAGS
+    LDFLAGS=$_SAVE_LDFLAGS
+    LIBS=$_SAVE_LIBS
+fi
+
+AC_SUBST(MOZ_ZLIB_CFLAGS)
+AC_SUBST(MOZ_ZLIB_LIBS)
+AC_SUBST(MOZ_NATIVE_ZLIB)
+
+])
--- a/configure.in
+++ b/configure.in
@@ -49,17 +49,16 @@ dnl ====================================
 _SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
 _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
 _SUBDIR_CONFIG_ARGS="$ac_configure_args"
 
 dnl Set the version number of the libs included with mozilla
 dnl ========================================================
 MOZJPEG=62
 MOZPNG=10511
-MOZZLIB=1.2.3
 NSPR_VERSION=4
 NSS_VERSION=3
 
 dnl Set the minimum version of toolkit libs used by mozilla
 dnl ========================================================
 GLIB_VERSION=1.2.0
 PERL_VERSION=5.006
 PYTHON_VERSION=2.5
@@ -1080,18 +1079,16 @@ ASM_SUFFIX=s
 IMPORT_LIB_SUFFIX=
 TARGET_MD_ARCH=unix
 DIRENT_INO=d_ino
 WIN_TOP_SRC=
 MOZ_USER_DIR=".mozilla"
 
 MOZ_JPEG_CFLAGS=
 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/media/libjpeg)'
-MOZ_ZLIB_CFLAGS=
-MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,$(DEPTH)/modules/zlib/src)'
 MOZ_BZ2_CFLAGS=
 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
 MOZ_PNG_CFLAGS=
 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)'
 
 MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)'
 MOZ_JS_SHARED_LIBS='$(call EXPAND_LIBNAME_PATH,mozjs,$(LIBXUL_DIST)/lib)'
 DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core -lmozalloc'
@@ -4029,61 +4026,32 @@ fi
 CFLAGS=$_SAVE_CFLAGS
 LDFLAGS=$_SAVE_LDFLAGS
 LIBS=$_SAVE_LIBS
 
 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_NATIVE_JPEG" = 1; then
     MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
     MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
 fi
+fi # SKIP_LIBRARY_CHECKS
 
 dnl system ZLIB support
 dnl ========================================================
-MOZ_ARG_WITH_STRING(system-zlib,
-[  --with-system-zlib[=PFX]
-                          Use system libz [installed at prefix PFX]],
-    ZLIB_DIR=$withval)
-
-_SAVE_CFLAGS=$CFLAGS
-_SAVE_LDFLAGS=$LDFLAGS
-_SAVE_LIBS=$LIBS
-if test -n "${ZLIB_DIR}" -a "${ZLIB_DIR}" != "yes"; then
-    CFLAGS="-I${ZLIB_DIR}/include $CFLAGS"
-    LDFLAGS="-L${ZLIB_DIR}/lib $LDFLAGS"
-fi
-if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then
-    MOZ_NATIVE_ZLIB=
-else
-    AC_CHECK_LIB(z, gzread, [MOZ_NATIVE_ZLIB=1 MOZ_ZLIB_LIBS="-lz"],
-	[MOZ_NATIVE_ZLIB=])
-fi
-if test "$MOZ_NATIVE_ZLIB" = 1; then
-    MOZZLIBNUM=`echo $MOZZLIB | awk -F. '{printf "0x%x\n", ((($1 * 16 + $2) * 16) + $3) * 16 + $4}'`
-    AC_TRY_COMPILE([ #include <stdio.h>
-                     #include <string.h>
-                     #include <zlib.h> ],
-                   [ #if ZLIB_VERNUM < $MOZZLIBNUM
-                     #error "Insufficient zlib version ($MOZZLIBNUM required)."
-                     #endif ],
-                   MOZ_NATIVE_ZLIB=1,
-                   AC_MSG_ERROR([Insufficient zlib version for --with-system-zlib ($MOZZLIB required)]))
-fi
-CFLAGS=$_SAVE_CFLAGS
-LDFLAGS=$_SAVE_LDFLAGS
-LIBS=$_SAVE_LIBS
-
-if test "${ZLIB_DIR}" -a -d "${ZLIB_DIR}" -a "$MOZ_NATIVE_ZLIB" = 1; then
-    MOZ_ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
-    MOZ_ZLIB_LIBS="-L${ZLIB_DIR}/lib ${ZLIB_LIBS}"
+MOZ_ZLIB_CHECK([1.2.3])
+
+if test "$MOZ_NATIVE_ZLIB" != 1; then
+    MOZ_ZLIB_CFLAGS=
+    MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,'"$_objdir"'/modules/zlib/src)'
 fi
 
 if test "$MOZ_LINKER" = 1 -a "$MOZ_NATIVE_ZLIB" != 1; then
     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
 fi
 
+if test -z "$SKIP_LIBRARY_CHECKS"; then
 dnl system BZIP2 Support
 dnl ========================================================
 MOZ_ARG_WITH_STRING(system-bz2,
 [  --with-system-bz2[=PFX]
                           Use system libbz2 [installed at prefix PFX]],
     BZ2_DIR=$withval)
 
 _SAVE_CFLAGS=$CFLAGS
@@ -8519,24 +8487,21 @@ COMPILE_CXXFLAGS=`echo \
     $_DEFINES_CXXFLAGS \
 	$_DEPEND_CFLAGS \
     $COMPILE_CXXFLAGS`
 
 AC_SUBST(MOZ_NATIVE_MAKEDEPEND)
 AC_SUBST(SYSTEM_LIBXUL)
 AC_SUBST(MOZ_NATIVE_JPEG)
 AC_SUBST(MOZ_NATIVE_PNG)
-AC_SUBST(MOZ_NATIVE_ZLIB)
 AC_SUBST(MOZ_NATIVE_BZ2)
 
 AC_SUBST(MOZ_FLEXBOX)
 AC_SUBST(MOZ_JPEG_CFLAGS)
 AC_SUBST(MOZ_JPEG_LIBS)
-AC_SUBST(MOZ_ZLIB_CFLAGS)
-AC_SUBST(MOZ_ZLIB_LIBS)
 AC_SUBST(MOZ_BZ2_CFLAGS)
 AC_SUBST(MOZ_BZ2_LIBS)
 AC_SUBST(MOZ_PNG_CFLAGS)
 AC_SUBST(MOZ_PNG_LIBS)
 
 AC_SUBST(NSPR_CFLAGS)
 AC_SUBST(NSPR_LIBS)
 AC_SUBST(MOZ_NATIVE_NSPR)
@@ -9182,16 +9147,22 @@ if test "$MOZ_MEMORY"; then
    ac_configure_args="$ac_configure_args --enable-jemalloc"
 fi
 if test -n "$MOZ_GLUE_LDFLAGS"; then
    export MOZ_GLUE_LDFLAGS
 fi
 if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then
    export MOZ_GLUE_PROGRAM_LDFLAGS
 fi
+if test "$MOZ_NATIVE_ZLIB" != 1 -a "$OS_ARCH" = "WINNT"; then
+   MOZ_ZLIB_LIBS=
+fi
+export MOZ_NATIVE_ZLIB
+export MOZ_ZLIB_CFLAGS
+export MOZ_ZLIB_LIBS
 export MOZ_APP_NAME
 export STLPORT_CPPFLAGS
 export STLPORT_LDFLAGS
 export STLPORT_LIBS
 AC_OUTPUT_SUBDIRS(js/src)
 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
 
 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -660,16 +660,19 @@ ifdef MOZ_ETW
 RESFILE = ETWProvider.res
 endif
 
 # HP-UX does not require the extra linking of "-lm"
 ifeq (,$(filter HP-UX WINNT OS2,$(OS_ARCH)))
 EXTRA_LIBS	+= -lm
 endif
 
+CFLAGS += $(MOZ_ZLIB_CFLAGS)
+EXTRA_LIBS += $(MOZ_ZLIB_LIBS)
+
 # Prevent floating point errors caused by VC++ optimizations
 ifdef _MSC_VER
 # XXX We should add this to CXXFLAGS, too?
 CFLAGS += -fp:precise
 
 ifeq ($(CPU_ARCH),x86)
 # Workaround compiler bug on PGO (Bug 721284)
 MonoIC.$(OBJ_SUFFIX): CXXFLAGS += -GL-
--- a/js/src/aclocal.m4
+++ b/js/src/aclocal.m4
@@ -13,10 +13,11 @@ builtin(include, build/autoconf/mozcommo
 builtin(include, build/autoconf/acwinpaths.m4)dnl
 builtin(include, build/autoconf/lto.m4)dnl
 builtin(include, build/autoconf/gcc-pr49911.m4)dnl
 builtin(include, build/autoconf/frameptr.m4)dnl
 builtin(include, build/autoconf/compiler-opts.m4)dnl
 builtin(include, build/autoconf/expandlibs.m4)dnl
 builtin(include, build/autoconf/arch.m4)dnl
 builtin(include, build/autoconf/android.m4)dnl
+builtin(include, build/autoconf/zlib.m4)dnl
 
 MOZ_PROG_CHECKMSYS()
new file mode 100644
--- /dev/null
+++ b/js/src/build/autoconf/zlib.m4
@@ -0,0 +1,54 @@
+dnl This Source Code Form is subject to the terms of the Mozilla Public
+dnl License, v. 2.0. If a copy of the MPL was not distributed with this
+dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+dnl Usage: MOZ_ZLIB_CHECK([version])
+
+AC_DEFUN([MOZ_ZLIB_CHECK],
+[
+
+MOZZLIB=$1
+
+MOZ_ARG_WITH_STRING(system-zlib,
+[  --with-system-zlib[=PFX]
+                          Use system libz [installed at prefix PFX]],
+    ZLIB_DIR=$withval)
+
+if test -z "$MOZ_ZLIB_LIBS$MOZ_ZLIB_CFLAGS$SKIP_LIBRARY_CHECKS"; then
+    _SAVE_CFLAGS=$CFLAGS
+    _SAVE_LDFLAGS=$LDFLAGS
+    _SAVE_LIBS=$LIBS
+
+    if test -n "${ZLIB_DIR}" -a "${ZLIB_DIR}" != "yes"; then
+        MOZ_ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
+        MOZ_ZLIB_LIBS="-L${ZLIB_DIR}/lib"
+        CFLAGS="$MOZ_ZLIB_CFLAGS $CFLAGS"
+        LDFLAGS="$MOZ_ZLIB_LIBS $LDFLAGS"
+    fi
+    if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then
+        MOZ_NATIVE_ZLIB=
+    else
+        AC_CHECK_LIB(z, gzread, [MOZ_NATIVE_ZLIB=1 MOZ_ZLIB_LIBS="$MOZ_ZLIB_LIBS -lz"],
+            [MOZ_NATIVE_ZLIB=])
+        if test "$MOZ_NATIVE_ZLIB" = 1; then
+            MOZZLIBNUM=`echo $MOZZLIB | awk -F. changequote(<<, >>)'{printf "0x%x\n", (((<<$>>1 * 16 + <<$>>2) * 16) + <<$>>3) * 16 + <<$>>4}'changequote([, ])`
+            AC_TRY_COMPILE([ #include <stdio.h>
+                             #include <string.h>
+                             #include <zlib.h> ],
+                           [ #if ZLIB_VERNUM < $MOZZLIBNUM
+                             #error "Insufficient zlib version ($MOZZLIBNUM required)."
+                             #endif ],
+                           MOZ_NATIVE_ZLIB=1,
+                           AC_MSG_ERROR([Insufficient zlib version for --with-system-zlib ($MOZZLIB required)]))
+        fi
+    fi
+    CFLAGS=$_SAVE_CFLAGS
+    LDFLAGS=$_SAVE_LDFLAGS
+    LIBS=$_SAVE_LIBS
+fi
+
+AC_SUBST(MOZ_ZLIB_CFLAGS)
+AC_SUBST(MOZ_ZLIB_LIBS)
+AC_SUBST(MOZ_NATIVE_ZLIB)
+
+])
--- a/js/src/config/Makefile.in
+++ b/js/src/config/Makefile.in
@@ -37,16 +37,21 @@ DIRS		+= mkdepend
 endif
 endif
 
 include $(topsrcdir)/config/config.mk
 
 # Do not install util programs
 NO_INSTALL=1
 
+# Force wrap zlib system header if building js as a shared library.
+ifdef JS_SHARED_LIBRARY
+DEFINES += -DMOZ_NATIVE_ZLIB=1
+endif
+
 include $(topsrcdir)/config/rules.mk
 
 HOST_CFLAGS += -DUNICODE -D_UNICODE
 
 export:: $(TARGETS)
 ifdef HOST_PROGRAM
 	$(INSTALL) $(HOST_PROGRAM) $(DIST)/bin
 endif
--- a/js/src/config/autoconf.mk.in
+++ b/js/src/config/autoconf.mk.in
@@ -187,16 +187,19 @@ DOXYGEN		= @DOXYGEN@
 PBBUILD_BIN	= @PBBUILD_BIN@
 SDP		= @SDP@
 NSINSTALL_BIN	= @NSINSTALL_BIN@
 
 NSPR_CONFIG	= @NSPR_CONFIG@
 NSPR_CFLAGS	= @NSPR_CFLAGS@
 NSPR_LIBS	= @NSPR_LIBS@
 
+MOZ_ZLIB_LIBS   = @MOZ_ZLIB_LIBS@
+MOZ_ZLIB_CFLAGS = @MOZ_ZLIB_CFLAGS@
+
 MOZ_NATIVE_FFI	= @MOZ_NATIVE_FFI@
 MOZ_FFI_LIBS	= @MOZ_FFI_LIBS@
 MOZ_FFI_CFLAGS	= @MOZ_FFI_CFLAGS@
 
 USE_DEPENDENT_LIBS = @USE_DEPENDENT_LIBS@
 
 JS_NATIVE_EDITLINE = @JS_NATIVE_EDITLINE@
 JS_DISABLE_SHELL   = @JS_DISABLE_SHELL@
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -3320,16 +3320,24 @@ if test -n "$MOZ_NATIVE_NSPR"; then
                  #error PR_STATIC_ASSERT not defined
                  #endif],
                 [MOZ_NATIVE_NSPR=1],
                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT]))
     CFLAGS=$_SAVE_CFLAGS
 fi
 
 dnl ========================================================
+dnl system zlib Support
+dnl ========================================================
+dnl Standalone js defaults to system zlib
+ZLIB_DIR=yes
+
+MOZ_ZLIB_CHECK([1.2.3])
+
+dnl ========================================================
 dnl system libffi Support
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(system-ffi,
 [  --enable-system-ffi       Use system libffi (located with pkgconfig)],
     MOZ_NATIVE_FFI=1 )
 
 if test -n "$MOZ_NATIVE_FFI"; then
     # Vanilla libffi 3.0.9 needs a few patches from upcoming version 3.0.10
--- a/js/src/jsapi-tests/Makefile.in
+++ b/js/src/jsapi-tests/Makefile.in
@@ -77,16 +77,16 @@ CSRCS = \
 #  testRegExpInstanceProperties.cpp \
 #  $(NULL)
 
 DEFINES         += -DEXPORT_JS_API
 # Building against js_static requires that we declare mfbt sybols "exported"
 # on its behalf.
 DEFINES         += -DIMPL_MFBT
 
-LIBS      = $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_SUFFIX) $(NSPR_LIBS)
+LIBS      = $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_SUFFIX) $(NSPR_LIBS) $(MOZ_ZLIB_LIBS)
 
 LOCAL_INCLUDES += -I$(topsrcdir) -I..
 
 include $(topsrcdir)/config/rules.mk
 
 check::
 	$(wildcard $(RUN_TEST_PROGRAM)) $(DIST)/bin/jsapi-tests$(BIN_SUFFIX)
--- a/js/src/shell/Makefile.in
+++ b/js/src/shell/Makefile.in
@@ -18,17 +18,17 @@ CPPSRCS		= \
   jsheaptools.cpp \
   $(NULL)
 
 DEFINES         += -DEXPORT_JS_API
 # Building against js_static requires that we declare mfbt sybols "exported"
 # on its behalf.
 DEFINES         += -DIMPL_MFBT
 
-LIBS      = $(NSPR_LIBS) $(EDITLINE_LIBS) $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_SUFFIX)
+LIBS      = $(NSPR_LIBS) $(EDITLINE_LIBS) $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_SUFFIX) $(MOZ_ZLIB_LIBS)
 ifdef MOZ_NATIVE_FFI
 EXTRA_LIBS += $(MOZ_FFI_LIBS)
 endif
 
 LOCAL_INCLUDES += -I$(topsrcdir) -I..
 
 ifeq ($(OS_ARCH),Darwin)
 ifeq ($(TARGET_CPU),x86_64)
--- a/layout/media/Makefile.in
+++ b/layout/media/Makefile.in
@@ -121,19 +121,16 @@ endif
 ifdef MOZ_ENABLE_SKIA
 SHARED_LIBRARY_LIBS += $(MOZ_SKIA_LIBS)
 endif
 
 ifeq (WINNT,$(OS_TARGET))
 EXTRA_DSO_LDOPTS = $(MOZALLOC_LIB) $(NSPR_LIBS)
 OS_LIBS += $(call EXPAND_LIBNAME,usp10 ole32)
 
-# OTS uses uncompress2() from libz, so we need to link with this
-EXTRA_DSO_LDOPTS += $(MOZ_ZLIB_LIBS)
-
 ifdef MOZ_WEBRTC
 EXTRA_DSO_LDOPTS += \
   -LIBPATH:"$(MOZ_DIRECTX_SDK_PATH)/lib/$(MOZ_DIRECTX_SDK_CPU_SUFFIX)" \
   $(NULL)
 OS_LIBS += $(call EXPAND_LIBNAME,secur32 crypt32 iphlpapi strmiids dmoguids wmcodecdspuuid amstrmid msdmo wininet)
 endif
 
 DEFFILE = symbols.def
--- a/media/libpng/Makefile.in
+++ b/media/libpng/Makefile.in
@@ -47,13 +47,12 @@ EXPORTS		= png.h pngconf.h mozpngconf.h
 
 LOCAL_INCLUDES	= -I$(srcdir)
 
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 ifeq ($(OS_ARCH),WINNT)
-DEFINES		+= -DZLIB_DLL
 ifdef BUILD_DEBUG_GC
 DEFINES		+= -DDEBUG_GC
 endif
 endif
--- a/modules/libjar/Makefile.in
+++ b/modules/libjar/Makefile.in
@@ -33,12 +33,8 @@ LIBXUL_LIBRARY = 1
 
 CPPSRCS		= $(MODULES_LIBJAR_LCPPSRCS)
 
 XPIDLSRCS	= $(MODULES_LIBJAR_LXPIDLSRCS)
 
 EXPORTS		= $(MODULES_LIBJAR_LEXPORTS)
 
 include $(topsrcdir)/config/rules.mk
-
-ifeq ($(OS_ARCH),WINNT)
-DEFINES		+= -DZLIB_DLL=1
-endif
--- a/modules/zlib/src/Makefile.in
+++ b/modules/zlib/src/Makefile.in
@@ -8,22 +8,15 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 include $(srcdir)/objs.mk
 
 MODULE		= zlib
 LIBRARY_NAME	= mozz
-GRE_MODULE	= 1
-LIBXUL_LIBRARY = 1
-DIST_INSTALL = 1
-
-ifeq (,$(filter-out WINNT OS2,$(OS_ARCH)))
-DEFINES	+= -DZLIB_DLL=1
-endif
 
 CSRCS		= $(MODULES_ZLIB_SRC_LCSRCS)
 
 EXPORTS		= zlib.h zconf.h mozzconf.h
 
 
 include $(topsrcdir)/config/rules.mk
--- a/modules/zlib/src/mozzconf.h
+++ b/modules/zlib/src/mozzconf.h
@@ -1,18 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZZCONF_H
 #define MOZZCONF_H
 
-#if defined(XP_WIN) && defined(ZLIB_DLL)
-#undef ZLIB_DLL
+#if defined(XP_WIN)
+#define ZLIB_DLL 1
 #endif
 
 /* Exported Symbols */
 #define zlibVersion MOZ_Z_zlibVersion
 #define deflate MOZ_Z_deflate
 #define deflateEnd MOZ_Z_deflateEnd
 #define inflate MOZ_Z_inflate
 #define inflateEnd MOZ_Z_inflateEnd
--- a/mozglue/build/Makefile.in
+++ b/mozglue/build/Makefile.in
@@ -51,16 +51,18 @@ mozglue.def: mozglue.def.in
 	$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(ACDEFINES) $< > $@
 
 GARBAGE += mozglue.def
 
 ifneq (,$(filter -DEFAULTLIB:mozcrt,$(MOZ_GLUE_LDFLAGS)))
 # Don't install the import library if we use mozcrt
 NO_INSTALL_IMPORT_LIBRARY = 1
 endif
+
+EXTRA_DSO_LDOPTS += $(MOZ_ZLIB_LIBS)
 endif
 
 ifeq (Android,$(OS_TARGET))
 # To properly wrap jemalloc's pthread_atfork call.
 EXTRA_DSO_LDOPTS += -Wl,--wrap=pthread_atfork
 CPPSRCS += BionicGlue.cpp
 SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,android,$(DEPTH)/other-licenses/android)
 endif
--- a/netwerk/streamconv/converters/Makefile.in
+++ b/netwerk/streamconv/converters/Makefile.in
@@ -46,13 +46,9 @@ endif
 FORCE_STATIC_LIB = 1
 
 LOCAL_INCLUDES =                        \
         -I$(topsrcdir)/netwerk/base/src \
         $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
-ifeq ($(OS_ARCH),WINNT)
-DEFINES		+= -DZLIB_DLL
-endif
-
 DEFINES += -DIMPL_NS_NET
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -74,20 +74,16 @@ RCINCLUDE = xulrunner.rc
 ifndef MOZ_NATIVE_ZLIB
 CPPSRCS += dlldeps-zlib.cpp
 endif
 
 LOCAL_INCLUDES += -I$(topsrcdir)/widget/windows
 LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/base
 endif
 
-ifneq (,$(filter WINNT OS2,$(OS_ARCH)))
-DEFINES += -DZLIB_DLL=1
-endif
-
 ifeq ($(OS_ARCH),OS2)
 
 CPPSRCS += \
   nsGFXDeps.cpp \
   $(NULL)
 
 ifndef MOZ_NATIVE_ZLIB
 CPPSRCS += dlldeps-zlib.cpp
@@ -351,17 +347,19 @@ EXTRA_DSO_LDOPTS += \
 ifdef MOZ_NATIVE_JPEG
 EXTRA_DSO_LDOPTS += $(MOZ_JPEG_LIBS)
 endif
 
 ifdef MOZ_NATIVE_PNG
 EXTRA_DSO_LDOPTS += $(MOZ_PNG_LIBS)
 endif
 
+ifneq (WINNT,$(OS_ARCH))
 EXTRA_DSO_LDOPTS += $(MOZ_ZLIB_LIBS)
+endif
 
 ifdef MOZ_NATIVE_HUNSPELL
 EXTRA_DSO_LDOPTS += $(MOZ_HUNSPELL_LIBS)
 endif
 
 ifdef MOZ_NATIVE_LIBEVENT
 EXTRA_DSO_LDOPTS += $(MOZ_LIBEVENT_LIBS)
 endif
--- a/toolkit/toolkit-tiers.mk
+++ b/toolkit/toolkit-tiers.mk
@@ -16,20 +16,16 @@ tier_platform_dirs = tools/trace-malloc/
 endif
 
 ifdef MOZ_TREE_FREETYPE
 tier_platform_staticdirs += modules/freetype2
 endif
 
 tier_platform_dirs += xpcom
 
-ifndef MOZ_NATIVE_ZLIB
-tier_platform_dirs += modules/zlib
-endif
-
 tier_platform_dirs += \
 		modules/libpref \
 		intl \
 		netwerk \
 		$(NULL)
 
 ifdef MOZ_AUTH_EXTENSION
 tier_platform_dirs += extensions/auth