Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8196803

Fix build warnings in jdk libraries with Xcode 9

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 11
    • Fix Version/s: 11
    • Component/s: infrastructure
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b01
    • OS:
      os_x

      Description

      When building with Xcode 9, the following warnings are triggered in desktop libraries:

      /Users/ejoelsso/hg/jdk-newdevkit/open/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m:351:48: warning: conflicting parameter types in implementation of 'nextEventMatchingMask:untilDate:inMode:dequeue:': 'NSEventMask' (aka 'enum NSEventMask') vs 'NSUInteger' (aka 'unsigned long') [-Wmismatched-parameter-types]
      - (NSEvent *)nextEventMatchingMask:(NSUInteger)mask
                                          ~~~~~~~~~~ ^
      /Users/ejoelsso/hg/jdk-newdevkit/open/build/devkit/Xcode9.2-MacOSX10.13/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSApplication.h:282:58: note: previous definition is here
      - (nullable NSEvent *)nextEventMatchingMask:(NSEventMask)mask untilDate:(nullable NSDate *)expiration inMode:(NSRunLoopMode)mode dequeue:(BOOL)deqFlag;
                                                   ~~~~~~~~~~~ ^
      1 warning generated.
      /Users/ejoelsso/hg/jdk-newdevkit/open/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c:457:16: warning: 'inflateValidate' is only available on macOS 10.13 or newer [-Wunguarded-availability-new]
               ret = inflateValidate(&png_ptr->zstream, 0);
                     ^~~~~~~~~~~~~~~
      /Users/ejoelsso/hg/jdk-newdevkit/open/build/devkit/Xcode9.2-MacOSX10.13/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/zlib.h:1917:32: note: 'inflateValidate' has been explicitly marked partial here
      ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int))
                                     ^
      /Users/ejoelsso/hg/jdk-newdevkit/open/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c:457:16: note: enclose 'inflateValidate' in a __builtin_available check to silence this warning
               ret = inflateValidate(&png_ptr->zstream, 0);
                     ^~~~~~~~~~~~~~~
      1 warning generated.

      There are two separate issues here with the common root cause being bad handling Macosx headers from different versions of Macosx.

      In NSApplicationAWT.m, we have this construct:

      #if defined(MAC_OS_X_VERSION_10_12) && \
         MAC_OS_X_VERSION_MAX_ALLOWED >= 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
      - (NSEvent *)nextEventMatchingMask:(NSUInteger)mask
      #endif

      This fails for us because we are setting MAC_OS_X_VERSION_MAX_ALLOWED to a value lower than 10.12. We do this to make it an error to utilize features that are newer than the oldest supported Macosx version. IMO the conditional above is wrong. If we are compiling against the 10.12 (or later) header, we have to accept the definitions there, and trust that the resulting binaries will still work. In this case, having a larger return type defined should be safer in both cases.

      The libz problem is trickier. Here we are dealing with a source file in libpng, which we are not in control over. The source file guards the use of the inflateValidate call with this check:

      #if ZLIB_VERNUM >= 0x1290

      Which in most cases is the correct thing to do. The problem for us is that it circumvents the MAC_OS_X_VERSION_MAX_ALLOWED and MAC_OS_X_VERSION_MIN_REQUIRED macros that we use to protect usage of newer APIs from the system. To fix this, we need to force the ZLIB_VERNUM to have a lower value, matching the version shipped with the version of Macosx we want to support. This can be solved by injecting a wrapper zlib.h where we override this value.

      We also get warnings when linking static libraries. These are easily fixed by adding the -mmacosx-version-min= arguments on these command lines just like we do for linking shared libraries and executables.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                erikj Erik Joelsson
                Reporter:
                erikj Erik Joelsson
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: