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

Changes needed to compile JDK 8 on MacOS with clang compiler

    Details

    • Subcomponent:
    • Resolved In Build:
      b06
    • CPU:
      x86
    • OS:
      os_x

      Backports

        Description

        It is preferred to build with clang on MacOS, with the fallback of using gcc.

        Something along these lines:

        % hg diff common/autoconf/toolchain.m4
        diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4
        --- a/common/autoconf/toolchain.m4
        +++ b/common/autoconf/toolchain.m4
        @@ -60,7 +60,20 @@ AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSI
                 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".])
               fi
             fi
        + elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
        + COMPILER_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
        + # Check that this is likely to be clang|GCC.
        + $COMPILER --version 2>&1 | $EGREP "Apple clang version|Free Software Foundation" > /dev/null
        + if test $? -ne 0; then
        + AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required compiler.])
        + AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_TEST"])
        + AC_MSG_ERROR([clang or GCC compiler is required. Try setting --with-tools-dir.])
        + fi
        + # First line typically looks something like:
        + COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/p"`
        + COMPILER_VENDOR=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^\(.*\) @<:@1-9@:>@@<:@0-9.@:>@*/\1/p"`
           else
        + # else must be l*ux and therefore gcc.
             COMPILER_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
             # Check that this is likely to be GCC.
             $COMPILER --version 2>&1 | $GREP "Free Software Foundation" > /dev/null
        @@ -242,6 +255,7 @@ fi
         
         # On windows, only cl.exe is supported.
         # On Solaris, cc is preferred to gcc.
        +# On MacOS, clang is preferred to gcc.
         # Elsewhere, gcc is preferred to cc.
         
         if test "x$CC" != x; then
        @@ -250,6 +264,8 @@ elif test "x$OPENJDK_TARGET_OS" = "xwind
           COMPILER_CHECK_LIST="cl"
         elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
           COMPILER_CHECK_LIST="cc gcc"
        +elif test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
        + COMPILER_CHECK_LIST="clang gcc cc"
         else
           COMPILER_CHECK_LIST="gcc cc"
         fi
        @@ -510,8 +526,7 @@ if test "x$GCC" = xyes; then
         
             # Linking is different on MacOSX
             if test "x$OPENJDK_TARGET_OS" = xmacosx; then
        - # Might change in the future to clang.
        - COMPILER_NAME=gcc
        + COMPILER_NAME=clang
                 SHARED_LIBRARY='lib[$]1.dylib'
                 SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
                 SHARED_LIBRARY_SUFFIX='.dylib'

          Attachments

          1. Wformat-nonliteral.diff
            4 kB
          2. xcode5.hotspot
            0.7 kB
          3. xcode5.top
            3 kB

            Issue Links

              Activity

                People

                • Assignee:
                  tbell Tim Bell
                  Reporter:
                  tbell Tim Bell
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  12 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: