--- old/make/autoconf/flags.m4 2018-02-05 14:28:50.000000000 -0800 +++ new/make/autoconf/flags.m4 2018-02-05 14:28:50.000000000 -0800 @@ -1113,10 +1113,11 @@ # Additional macosx handling if test "x$OPENJDK_$1_OS" = xmacosx; then - # MACOSX_VERSION_MIN is the c++ and ld is -mmacosx-version-min argument. The expected - # format is X.Y.Z. It's hard-coded to the minimum OSX version on which the - # JDK can be built and makes the linked binaries compatible even if built on - # a newer version of the OS. + # MACOSX_VERSION_MIN specifies the lowest version of Macosx that the built + # binaries should be compatible with, even if compiled on a newer version + # of the OS. It currently has a hard coded value. Setting this also limits + # exposure to API changes in header files. Bumping this is likely to + # require code changes to build. MACOSX_VERSION_MIN=10.7.0 AC_SUBST(MACOSX_VERSION_MIN) @@ -1150,6 +1151,7 @@ $2JVM_CFLAGS="[$]$2JVM_CFLAGS \ -DMAC_OS_X_VERSION_MIN_REQUIRED=\$(subst .,,\$(MACOSX_VERSION_MIN)) \ -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" + $2ARFLAGS="$2$ARFLAGS -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" if test -n "$MACOSX_VERSION_MAX"; then $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \ --- old/make/autoconf/lib-bundled.m4 2018-02-05 14:28:51.000000000 -0800 +++ new/make/autoconf/lib-bundled.m4 2018-02-05 14:28:51.000000000 -0800 @@ -209,7 +209,15 @@ AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled']) fi + if test "x$USER_EXTERNAL_LIBZ" = "xfalse"; then + LIBZ_CFLAGS="$LIBZ_CFLAGS -I$TOPDIR/src/java.base/share/native/libzip/zlib" + else + LIBZ_LIBS="-lz" + fi + AC_SUBST(USE_EXTERNAL_LIBZ) + AC_SUBST(LIBZ_CFLAGS) + AC_SUBST(LIBZ_LIBS) ]) ################################################################################ --- old/make/autoconf/spec.gmk.in 2018-02-05 14:28:52.000000000 -0800 +++ new/make/autoconf/spec.gmk.in 2018-02-05 14:28:52.000000000 -0800 @@ -737,6 +737,8 @@ USE_EXTERNAL_LIBJPEG:=@USE_EXTERNAL_LIBJPEG@ USE_EXTERNAL_LIBGIF:=@USE_EXTERNAL_LIBGIF@ USE_EXTERNAL_LIBZ:=@USE_EXTERNAL_LIBZ@ +LIBZ_CFLAGS:=@LIBZ_CFLAGS@ +LIBZ_LIBS:=@LIBZ_LIBS@ LIBZIP_CAN_USE_MMAP:=@LIBZIP_CAN_USE_MMAP@ MSVCR_DLL:=@MSVCR_DLL@ MSVCP_DLL:=@MSVCP_DLL@ --- old/make/lib/Awt2dLibraries.gmk 2018-02-05 14:28:54.000000000 -0800 +++ new/make/lib/Awt2dLibraries.gmk 2018-02-05 14:28:53.000000000 -0800 @@ -905,9 +905,18 @@ LIBSPLASHSCREEN_LIBS := - ifneq ($(USE_EXTERNAL_LIBZ), true) + ifeq ($(USE_EXTERNAL_LIBZ), false) LIBSPLASHSCREEN_DIRS += $(TOPDIR)/src/java.base/share/native/libzip/zlib - LIBSPLASHSCREEN_CFLAGS += $(ZLIB_CPPFLAGS) + else + ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(USE_EXTERNAL_LIBPNG), false) + # When building our own libpng and using an external libz, we need to + # inject our own libz.h to tweak the exported ZLIB_VERNUM macro. See + # $(TOPDIR)/src/java.desktop/macosx/native/libsplashscreen/libpng/zlib.h + # for details. + LIBSPLASHSCREEN_CFLAGS += -iquote $(TOPDIR)/src/java.desktop/macosx/native/libsplashscreen/libpng + endif + endif endif ifeq ($(OPENJDK_TARGET_OS), macosx) @@ -933,7 +942,7 @@ EXCLUDES := $(LIBSPLASHSCREEN_EXCLUDES), \ OPTIMIZATION := LOW, \ CFLAGS := $(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB) \ - $(GIFLIB_CFLAGS) $(LIBJPEG_CFLAGS) $(PNG_CFLAGS), \ + $(GIFLIB_CFLAGS) $(LIBJPEG_CFLAGS) $(PNG_CFLAGS) $(LIBZ_CFLAGS), \ DISABLED_WARNINGS_gcc := sign-compare type-limits unused-result maybe-uninitialized shift-negative-value, \ DISABLED_WARNINGS_clang := incompatible-pointer-types, \ DISABLED_WARNINGS_solstudio := E_NEWLINE_NOT_LAST E_DECLARATION_IN_CODE \ @@ -942,8 +951,8 @@ MAPFILE := $(TOPDIR)/make/mapfiles/libsplashscreen/mapfile-vers, \ LDFLAGS := $(LIBSPLASHSCREEN_LDFLAGS) $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ - LIBS := $(JDKLIB_LIBS) $(LIBSPLASHSCREEN_LIBS) $(LIBZ) \ - $(GIFLIB_LIBS) $(LIBJPEG_LIBS) $(PNG_LIBS), \ + LIBS := $(JDKLIB_LIBS) $(LIBSPLASHSCREEN_LIBS) $(LIBZ_LIBS) \ + $(GIFLIB_LIBS) $(LIBJPEG_LIBS) $(PNG_LIBS), \ LIBS_aix := -liconv, \ VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \ RC_FLAGS := $(RC_FLAGS) \ --- old/make/lib/CoreLibraries.gmk 2018-02-05 14:28:55.000000000 -0800 +++ new/make/lib/CoreLibraries.gmk 2018-02-05 14:28:55.000000000 -0800 @@ -82,7 +82,7 @@ OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \ SRC := $(LIBFDLIBM_SRC), \ CFLAGS := $(CFLAGS_JDKLIB) $(LIBFDLIBM_CFLAGS), \ - LDFLAGS := -nostdlib -r -arch x86_64, \ + LDFLAGS := -nostdlib $(ARFLAGS), \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \ )) @@ -224,7 +224,7 @@ SRC := $(TOPDIR)/src/java.base/share/native/libzip, \ EXCLUDES := $(LIBZIP_EXCLUDES), \ CFLAGS := $(CFLAGS_JDKLIB) \ - $(ZLIB_CPPFLAGS) \ + $(LIBZ_CFLAGS) \ -I$(TOPDIR)/src/java.base/share/native/libjava \ -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \ -I$(SUPPORT_OUTPUTDIR)/headers/java.base, \ @@ -236,7 +236,7 @@ LDFLAGS_windows := -export:ZIP_Open -export:ZIP_Close -export:ZIP_FindEntry \ -export:ZIP_ReadEntry -export:ZIP_GetNextEntry \ -export:ZIP_InflateFully -export:ZIP_CRC32 -export:ZIP_FreeEntry, \ - LIBS_unix := -ljvm -ljava $(LIBZ), \ + LIBS_unix := -ljvm -ljava $(LIBZ_LIBS), \ LIBS_solaris := -lc, \ LIBS_windows := jvm.lib $(WIN_JAVA_LIB), \ VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \ @@ -341,8 +341,9 @@ LIBJLI_CFLAGS += $(addprefix -I, $(LIBJLI_SRC_DIRS)) +LIBJLI_CFLAGS += $(LIBZ_CFLAGS) + ifneq ($(USE_EXTERNAL_LIBZ), true) - LIBJLI_CFLAGS += $(ZLIB_CPPFLAGS) LIBJLI_EXTRA_FILES += \ $(addprefix $(TOPDIR)/src/java.base/share/native/libzip/zlib/, \ inflate.c \ @@ -390,7 +391,7 @@ -export:JLI_PreprocessArg \ -export:JLI_AddArgsFromEnvVar \ -export:JLI_GetAppArgIndex, \ - LIBS_unix := $(LIBZ), \ + LIBS_unix := $(LIBZ_LIBS), \ LIBS_linux := $(LIBDL) -lc -lpthread, \ LIBS_solaris := $(LIBDL) -lc, \ LIBS_aix := $(LIBDL),\ @@ -437,7 +438,7 @@ EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \ OPTIMIZATION := HIGH, \ CFLAGS := $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS), \ - LDFLAGS := -nostdlib -r, \ + LDFLAGS := -nostdlib $(ARFLAGS), \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static, \ )) --- old/make/lib/Lib-java.instrument.gmk 2018-02-05 14:28:56.000000000 -0800 +++ new/make/lib/Lib-java.instrument.gmk 2018-02-05 14:28:56.000000000 -0800 @@ -68,7 +68,7 @@ LDFLAGS_macosx := -Wl$(COMMA)-all_load, \ LDFLAGS_aix := -L$(SUPPORT_OUTPUTDIR)/native/java.base, \ LIBS := $(JDKLIB_LIBS), \ - LIBS_unix := -ljava -ljvm $(LIBZ), \ + LIBS_unix := -ljava -ljvm $(LIBZ_LIBS), \ LIBS_linux := -ljli $(LIBDL), \ LIBS_solaris := -ljli $(LIBDL), \ LIBS_aix := -liconv -ljli_static $(LIBDL), \ --- old/make/lib/LibCommon.gmk 2018-02-05 14:28:57.000000000 -0800 +++ new/make/lib/LibCommon.gmk 2018-02-05 14:28:57.000000000 -0800 @@ -68,12 +68,3 @@ INSTALL_LIBRARIES_HERE := $(call FindLibDirForModule, $(MODULE)) ################################################################################ - -# Define it here since there are multiple uses. -ifeq ($(USE_EXTERNAL_LIBZ), true) - LIBZ := -lz -else - ZLIB_CPPFLAGS := -I$(TOPDIR)/src/java.base/share/native/libzip/zlib -endif - -############################################################################### --- old/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m 2018-02-05 14:28:58.000000000 -0800 +++ new/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m 2018-02-05 14:28:58.000000000 -0800 @@ -342,9 +342,7 @@ #define DRAGMASK (NSMouseMovedMask | NSLeftMouseDraggedMask | NSRightMouseDownMask | NSRightMouseDraggedMask | NSLeftMouseUpMask | NSRightMouseUpMask | NSFlagsChangedMask | NSKeyDownMask) -#if defined(MAC_OS_X_VERSION_10_12) && \ - MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12 && \ - __LP64__ +#if defined(MAC_OS_X_VERSION_10_12) && __LP64__ // 10.12 changed `mask` to NSEventMask (unsigned long long) for x86_64 builds. - (NSEvent *)nextEventMatchingMask:(NSEventMask)mask #else --- /dev/null 2018-02-05 14:28:59.000000000 -0800 +++ new/src/java.desktop/macosx/native/libsplashscreen/libpng/zlib.h 2018-02-05 14:28:59.000000000 -0800 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * This header file is used to hijack the include of "zlib.h" from libpng on + * Macos. We do that to be able to build on macos 10.13 or later, but still + * keep binary compatibility with older versions (as specified to configure). + * + * The problem is that in 10.13, Macos shipped with a newer version of zlib, + * which exports the function inflateValidate. There is a call to this + * function in pngrutil.c, guarded by a preprocessor check of ZLIB_VERNUM being + * high enough. If we compile this call in and link to the newer version of + * zlib, we will get link errors if the code is executed on an older Mac with + * an older version of zlib. + * + * The zlib.h header in Macos has been annotated with Macos specific macros that + * guard these kinds of version specific APIs, but libpng is not using those + * checks in its conditionals, just ZLIB_VERNUM. To fix this, we check for the + * MAC_OS_X_VERSION_MIN_REQUIRED macro here and adjust the ZLIB_VERNUM to the + # known version bundled with that release. This solution is certainly a hack, + * but it seems the affected versions of zlib.h are compatible enough for this + * to work. + */ + +#include +#include + +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12 +# undef ZLIB_VERNUM +# define ZLIB_VERNUM 0x1250 +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_13 +# undef ZLIB_VERNUM +# define ZLIB_VERNUM 0x1280 +#endif