Details
-
Bug
-
Resolution: Fixed
-
P3
-
8
-
b06
-
x86
-
os_x
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8267177 | openjdk8u302 | Henry Jen | P3 | Resolved | Fixed | b03 |
JDK-8236418 | 8u251 | Erik Joelsson | P3 | Resolved | Fixed | b01 |
JDK-8239607 | emb-8u251 | Erik Joelsson | P3 | Resolved | Fixed | team |
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'
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
Issue Links
- backported by
-
JDK-8236418 Changes needed to compile JDK 8 on MacOS with clang compiler
- Resolved
-
JDK-8239607 Changes needed to compile JDK 8 on MacOS with clang compiler
- Resolved
-
JDK-8267177 Changes needed to compile JDK 8 on MacOS with clang compiler
- Resolved
- relates to
-
JDK-8033898 undefined symbol when build hotspot with Xcode5
- Resolved
-
JDK-8266755 [8u] regenerated generated-configure.sh does not match checked-in version
- Resolved
-
JDK-8037816 Fix for 8036122 breaks build with Xcode5/clang
- Resolved
(1 relates to)