[m-rev.] for review: increase javac heap size
Peter Wang
novalazy at gmail.com
Tue Aug 11 13:19:22 AEST 2009
Branches: main
Pass a flag to the Java compiler to increase the maximum heap size of the
JVM. The default size (at least with Sun Java) is too small to build the
Mercury standard library on 32-bit JVMs. We choose a heap size of 256 MB
currently. (There doesn't seem to be an option to just switch off the
maximum.)
As the flag may not work with non-Sun compilers, we have to check during
configuration whether it's accepted by the detected Java compiler.
aclocal.m4:
Add a function to check if the Java compiler accepts the option
`-J-Xmx<n>'.
Bump Java SDK requirement to 1.5 (this was raised previously without
updating the check).
Update some comments.
configure.in:
Add the configure option `--enable-javac-flags-for-heap-size',
enabled by default.
Check if the Java compiler accepts the maximum heap size option.
Substitute the option in scripts.
scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
scripts/Mmake.vars.in:
Add @JAVAC_FLAGS_FOR_HEAP_SIZE@ to default javac flags.
diff --git a/aclocal.m4 b/aclocal.m4
index 4fc4d0c..27fa77c 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -328,7 +328,7 @@ if test "$JAVAC" != "" -a "$JAVA_INTERPRETER" != "" -a "$JAR" != ""; then
cat > conftest.java << EOF
// This program simply retrieves the constant
// specifying the version number of the Java SDK and
- // checks it is at least 1.2, printing "Hello, world"
+ // checks it is at least 1.5, printing "Hello, world"
// if successful.
public class conftest {
public static void main (String[[]] args) {
@@ -348,7 +348,7 @@ if test "$JAVAC" != "" -a "$JAVA_INTERPRETER" != "" -a "$JAR" != ""; then
version = 0f;
}
- if (version >= 1.2f) {
+ if (version >= 1.5f) {
System.out.println("Hello, world\n");
} else {
System.out.println("Nope, sorry.\n");
@@ -387,6 +387,29 @@ AC_SUBST(JAVA_INTERPRETER)
AC_SUBST(JAR)
])
+AC_DEFUN(MERCURY_CHECK_JAVAC_HEAP_SIZE,
+[
+# The default maximum heap size is too small to build the standard library and
+# other programs so we need to increase it. The option to do that is
+# non-standard so we have to check that it is accepted.
+AC_CACHE_VAL(mercury_cv_javac_flags_for_heap_size, [
+if test "$mercury_cv_java" = "yes"; then
+ AC_MSG_CHECKING(if the Java compiler accepts the max heap size option)
+ mercury_cv_javac_flags_for_heap_size="-J-Xmx256m"
+ if "$JAVAC" "$mercury_cv_javac_flags_for_heap_size" -version \
+ 2> /dev/null
+ then
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
+ mercury_cv_javac_flags_for_heap_size=
+ fi
+else
+ mercury_cv_javac_flags_for_heap_size=
+fi
+])
+])
+
#-----------------------------------------------------------------------------#
#
# Erlang configuration
diff --git a/configure.in b/configure.in
index 0b1e993..fd5090e 100644
--- a/configure.in
+++ b/configure.in
@@ -1051,6 +1051,23 @@ MERCURY_CHECK_DOTNET
MERCURY_CHECK_JAVA
+AC_ARG_ENABLE(javac-flags-for-heap-size,
+ AC_HELP_STRING([--enable-javac-flags-for-heap-size],
+ [enable maximum heap size option for Java compiler]),
+ enable_javac_flags_for_heap_size="$enableval",
+ enable_javac_flags_for_heap_size=yes)
+
+case "$enable_javac_flags_for_heap_size" in
+ yes)
+ MERCURY_CHECK_JAVAC_HEAP_SIZE
+ JAVAC_FLAGS_FOR_HEAP_SIZE=$mercury_cv_javac_flags_for_heap_size
+ ;;
+ no)
+ JAVAC_FLAGS_FOR_HEAP_SIZE=
+ ;;
+esac
+AC_SUBST(JAVAC_FLAGS_FOR_HEAP_SIZE)
+
#-----------------------------------------------------------------------------#
# Erlang configuration
#
@@ -3170,14 +3187,13 @@ AC_ARG_ENABLE(dotnet-grades,
AC_HELP_STRING([--enable-dotnet-grades], [install the .NET grades]),
enable_dotnet_grades="$enableval",enable_dotnet_grades=no)
-# XXX The java backend is currently broken, so we don't
-# enable the java grade by default.
+# We don't enable the java grade by default.
AC_ARG_ENABLE(java-grade,
AC_HELP_STRING([--enable-java-grade], [install the Java grade]),
enable_java_grade="$enableval",enable_java_grade=no)
# We don't enable the Erlang grades by default because it is still
-# experimental and it requires mmc --make to install.
+# experimental.
AC_ARG_ENABLE(erlang-grade,
AC_HELP_STRING([--enable-erlang-grade], [install the Erlang grade]),
enable_erlang_grade="$enableval",enable_erlang_grade=no)
diff --git a/scripts/Mercury.config.bootstrap.in b/scripts/Mercury.config.bootstrap.in
index fbbf8c1..b8c9164 100644
--- a/scripts/Mercury.config.bootstrap.in
+++ b/scripts/Mercury.config.bootstrap.in
@@ -63,6 +63,7 @@ DEFAULT_MCFLAGS=\
--c-flag-to-name-object-file "@OBJFILE_OPT@" \
--java-classpath "$(INSTALL_JAVA_LIBRARY_DIR)/$(RT_LIB_NAME).jar" \
--java-classpath "$(INSTALL_JAVA_LIBRARY_DIR)/$(STD_LIB_NAME).jar" \
+ --java-flags "@JAVAC_FLAGS_FOR_HEAP_SIZE@" \
--object-file-extension ". at OBJ_SUFFIX@" \
--pic-object-file-extension ". at EXT_FOR_PIC_OBJECTS@" \
--link-with-pic-object-file-extension ". at EXT_FOR_LINK_WITH_PIC_OBJECTS@" \
diff --git a/scripts/Mercury.config.in b/scripts/Mercury.config.in
index 0a7204a..b2df88b 100644
--- a/scripts/Mercury.config.in
+++ b/scripts/Mercury.config.in
@@ -69,6 +69,7 @@ DEFAULT_MCFLAGS=\
--c-flag-to-name-object-file "@OBJFILE_OPT@" \
--java-classpath "$(INSTALL_JAVA_LIBRARY_DIR)/$(RT_LIB_NAME).jar" \
--java-classpath "$(INSTALL_JAVA_LIBRARY_DIR)/$(STD_LIB_NAME).jar" \
+ --java-flags "@JAVAC_FLAGS_FOR_HEAP_SIZE@" \
--object-file-extension ". at OBJ_SUFFIX@" \
--pic-object-file-extension ". at EXT_FOR_PIC_OBJECTS@" \
--link-with-pic-object-file-extension ". at EXT_FOR_LINK_WITH_PIC_OBJECTS@" \
diff --git a/scripts/Mmake.vars.in b/scripts/Mmake.vars.in
index 03fe227..4922837 100644
--- a/scripts/Mmake.vars.in
+++ b/scripts/Mmake.vars.in
@@ -268,7 +268,7 @@ LIB_MS_CSCFLAGS =
JAVAC = @JAVAC@
ALL_JAVACFLAGS = $(JAVACFLAGS) $(EXTRA_JAVACFLAGS) $(TARGET_JAVACFLAGS) \
$(LIB_JAVACFLAGS)
-JAVACFLAGS =
+JAVACFLAGS = @JAVAC_FLAGS_FOR_HEAP_SIZE@
EXTRA_JAVACFLAGS =
# XXX Should we set LIB_JAVACFLAGS?
LIB_JAVACFLAGS =
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list