changeset 2868:a7607c98a59c

PR3653: Detect whether -Xprefer:source and -J-Xmx<limit> can be used, rather than assuming 2018-11-23 Andrew John Hughes <gnu_andrew@member.fsf.org> PR3653: Detect whether -Xprefer:source and -J-Xmx<limit> can be used, rather than assuming * Makefile.am: (PREFER_SOURCE): Define if COMPILER_SUPPORTS_XPREFERSOURCE is set by configure. (MEMORY_LIMIT): Define if COMPILER_SUPPORTS_MAX_HEAP_SIZE is set by configure. * NEWS: Updated. * acinclude.m4: (IT_DIAMOND_CHECK): Use 'the Java compiler' rather than 'javac' to avoid confusion with the OpenJDK command. (IT_JAVAC_OPTIONS_CHECK): Check whether the selected Java compiler supports -Xprefer:source and -J-Xmx. * configure.ac: Invoke IT_JAVAC_OPTIONS_CHECK.
author Andrew John Hughes <gnu_andrew@member.fsf.org>
date Tue, 25 Dec 2018 22:47:20 +0000
parents 1d016c70f634
children b680c0a6f284
files ChangeLog Makefile.am NEWS acinclude.m4 configure.ac
diffstat 5 files changed, 95 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Dec 25 04:40:36 2018 +0000
+++ b/ChangeLog	Tue Dec 25 22:47:20 2018 +0000
@@ -1,3 +1,24 @@
+2018-11-23  Andrew John Hughes  <gnu_andrew@member.fsf.org>
+
+	PR3653: Detect whether -Xprefer:source
+	and -J-Xmx<limit> can be used, rather than assuming
+	* Makefile.am:
+	(PREFER_SOURCE): Define if
+	COMPILER_SUPPORTS_XPREFERSOURCE is set
+	by configure.
+	(MEMORY_LIMIT): Define if
+	COMPILER_SUPPORTS_MAX_HEAP_SIZE is set
+	by configure.
+	* NEWS: Updated.
+	* acinclude.m4:
+	(IT_DIAMOND_CHECK): Use 'the Java compiler'
+	rather than 'javac' to avoid confusion with
+	the OpenJDK command.
+	(IT_JAVAC_OPTIONS_CHECK): Check whether the
+	selected Java compiler supports -Xprefer:source
+	and -J-Xmx.
+	* configure.ac: Invoke IT_JAVAC_OPTIONS_CHECK.
+
 2018-12-24  Andrew John Hughes  <gnu_andrew@member.fsf.org>
 
 	PR3673: Alternate HotSpot builds need fix for PR3094
--- a/Makefile.am	Tue Dec 25 04:40:36 2018 +0000
+++ b/Makefile.am	Tue Dec 25 22:47:20 2018 +0000
@@ -255,15 +255,16 @@
 REV_ARG = -r $(HGREV)
 endif
 
-# This should not depend on bootstrapping
-# but on whether MEMORY_LIMIT is accepted
-# as an argument to javac
-if BOOTSTRAPPING
+if COMPILER_SUPPORTS_XPREFERSOURCE
+  PREFER_SOURCE = -Xprefer:source
+else
+  PREFER_SOURCE =
+endif
+
+if COMPILER_SUPPORTS_MAX_HEAP_SIZE
+  MEMORY_LIMIT = -J-Xmx1024m
+else
   MEMORY_LIMIT =
-  PREFER_SOURCE = 
-else
-  MEMORY_LIMIT = -J-Xmx1024m
-  PREFER_SOURCE = -Xprefer:source
 endif
 
 ICEDTEA_BUILD_TARGET=images
--- a/NEWS	Tue Dec 25 04:40:36 2018 +0000
+++ b/NEWS	Tue Dec 25 22:47:20 2018 +0000
@@ -76,6 +76,7 @@
   - S8202261, PR3638: (fc) FileChannel.map and RandomAccessFile.setLength should not preallocate space
   - S8209639, PR3643, RH1640127: assert failure in coalesce.cpp: attempted to spill a non-spillable item
 * Bug fixes
+  - PR3653: Detect whether -Xprefer:source and -J-Xmx<limit> can be used, rather than assuming
   - PR3673: Alternate HotSpot builds need fix for PR3094
 * SystemTap
   - PR3625: arc_priority representation creates an implicit limit on character sequence within regexp
--- a/acinclude.m4	Tue Dec 25 04:40:36 2018 +0000
+++ b/acinclude.m4	Tue Dec 25 22:47:20 2018 +0000
@@ -1466,7 +1466,7 @@
 ])
 
 AC_DEFUN([IT_DIAMOND_CHECK],[
-  AC_CACHE_CHECK([if javac lacks support for the diamond operator], it_cv_diamond, [
+  AC_CACHE_CHECK([if the Java compiler lacks support for the diamond operator], it_cv_diamond, [
   CLASS=Test.java
   BYTECODE=$(echo $CLASS|sed 's#\.java##')
   mkdir tmp.$$
@@ -2278,6 +2278,68 @@
   AM_CONDITIONAL([DISABLE_SYSTEMTAP_TESTS], test x"${disable_systemtap_tests}" = "xyes")
 ])
 
+AC_DEFUN_ONCE([IT_JAVAC_OPTIONS_CHECK],
+[
+  AC_REQUIRE([IT_CHECK_JAVA_AND_JAVAC_WORK])
+  AC_CACHE_CHECK([if the Java compiler supports -Xprefer:source], it_cv_xprefersource_works, [
+  CLASS=Test.java
+  BYTECODE=$(echo $CLASS|sed 's#\.java##')
+  mkdir tmp.$$
+  cd tmp.$$
+  cat << \EOF > $CLASS
+[/* [#]line __oline__ "configure" */
+
+public class Test
+{
+    public static void main(String[] args)
+    {
+      System.out.println("Hello World!");
+    }
+}]
+EOF
+  mkdir build
+  if $JAVAC -d build -cp . $JAVACFLAGS -Xprefer:source $CLASS >&AS_MESSAGE_LOG_FD 2>&1; then
+    it_cv_xprefersource_works=yes;
+  else
+    it_cv_xprefersource_works=no;
+  fi
+  rm -f $CLASS build/*.class
+  rmdir build
+  cd ..
+  rmdir tmp.$$
+  ])
+  AC_CACHE_CHECK([if the Java compiler supports setting the maximum heap size], it_cv_max_heap_size_works, [
+  CLASS=Test.java
+  BYTECODE=$(echo $CLASS|sed 's#\.java##')
+  mkdir tmp.$$
+  cd tmp.$$
+  cat << \EOF > $CLASS
+[/* [#]line __oline__ "configure" */
+
+public class Test
+{
+    public static void main(String[] args)
+    {
+      System.out.println("Hello World!");
+    }
+}]
+EOF
+  mkdir build
+  if $JAVAC -d build -cp . $JAVACFLAGS -J-Xmx1024m $CLASS >&AS_MESSAGE_LOG_FD 2>&1; then
+    it_cv_max_heap_size_works=yes;
+  else
+    it_cv_max_heap_size_works=no;
+  fi
+  rm -f $CLASS build/*.class
+  rmdir build
+  cd ..
+  rmdir tmp.$$
+  ])
+  AC_PROVIDE([$0])dnl
+  AM_CONDITIONAL([COMPILER_SUPPORTS_XPREFERSOURCE], test x"${it_cv_xprefersource_works}" = "xyes")
+  AM_CONDITIONAL([COMPILER_SUPPORTS_MAX_HEAP_SIZE], test x"${it_cv_max_heap_size_works}" = "xyes")
+])
+
 AC_DEFUN_ONCE([IT_DISABLE_PRECOMPILED_HEADERS],
 [
   AC_MSG_CHECKING([whether to disable the use of pre-compiled headers])
--- a/configure.ac	Tue Dec 25 04:40:36 2018 +0000
+++ b/configure.ac	Tue Dec 25 22:47:20 2018 +0000
@@ -108,6 +108,7 @@
 
 IT_CHECK_ENABLE_WARNINGS
 IT_DIAMOND_CHECK
+IT_JAVAC_OPTIONS_CHECK
 
 IT_ENABLE_OPENJDK_CHECKSUM
 IT_ENABLE_HOTSPOT_CHECKSUM