In configure, we use the "magic" AC_PROG_OBJC function to locate the compiler for Objective-C files. On the systems I tested, this returns gcc, even if we want to use clang (by setting --with-toolchain-type=clang).

The following patch just sets OBJC to CC (that is, clang), if clang is selected as toolchain.

Open question: Should we do the same for toolchain-type=gcc? I'm not quite sure what we're getting from calling the AC_PROG_OBJC macro, except perhaps a loss of transparency on how our tools are picked up. :-/ In fact, maybe we should just skip the OBJC variable completely. In fact, for Objective-C++ (.mm) files, we just use the normal C++ compiler.

Bug: https://bugs.openjdk.java.net/browse/JDK-8074099

Patch inlined:

diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4
--- a/common/autoconf/toolchain.m4
+++ b/common/autoconf/toolchain.m4
@@ -541,7 +541,13 @@
 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA],
 [
   if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
-    AC_PROG_OBJC
+    if test "x$TOOLCHAIN_TYPE" = "xclang"; then
+      # Use clang for compiling Objective-C
+      OBJC="$CC"
+      AC_SUBST(OBJC)
+    else
+      AC_PROG_OBJC
+    fi
     BASIC_FIXUP_EXECUTABLE(OBJC)
     BASIC_PATH_PROGS(LIPO, lipo)
     BASIC_FIXUP_EXECUTABLE(LIPO)

/Magnus

Reply via email to