[m-rev.] diff: fix problem with JAVAC_FLAGS_FOR_HEAP_SIZE and --restricted-command-line
Julien Fischer
jfischer at opturion.com
Wed Feb 18 01:20:03 AEDT 2015
Fix problem with JAVAC_FLAGS_FOR_HEAP_SIZE and --restricted-command-line.
The default configuration of Mercury on Windows breaks when using the Java
grade due to the argument we pass to the Java compiler's '-J' option, in order
to set the maximum heap size, not being quoted in the @file we pass to the Java
compiler when '--restricted-command-line' is enabled.
What should be placed in the @file is:
-J"-Xmx1024m"
What we currently put in it is:
-J-Xmx1024m
The reason for this is that the setting of JAVAC_FLAGS_FOR_HEAP_SIZE in
scripts/Mercury.config does not escape the double quotes, consequently they do
not get passed through the Mercury compiler to the aforementioned @file. This
problem was already correctly identified and documented in the comments
accompanying the MERCURY_CHECK_JAVAC_HEAP_SIZE macro in m4/mercury.m4, but the
actual behaviour of that macro is incorrect. In particular, it fails to
account for the fact that the value of JAVAC_FLAGS_FOR_HEAP_SIZE should differ
depending on whether mmake or 'mmc --make' is using that value. The current
value will work for mmake but not with 'mmc --make'
(and '--restricted-command-line').
The fix is to separate the handling of the mmake and 'mmc --make' cases and
correctly escape the version that is put in Mercury.config.
configure.ac:
m4/mercury.m4:
Define separate configuration variables for mmake and 'mmc --make' to
set the Java compiler's maximum heap size.
scripts/Mercury.config.in:
scripts/Mercury.config.bootstrap.in:
scripts/Mmake.vars.in:
Conform to the above change.
Julien.
diff --git a/configure.ac b/configure.ac
index 8183991..9cecd22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1234,13 +1234,16 @@ AC_ARG_ENABLE(javac-flags-for-heap-size,
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
+ JAVAC_FLAGS_FOR_HEAP_SIZE_MMAKE=$mercury_cv_javac_flags_for_heap_size_mmake
+ JAVAC_FLAGS_FOR_HEAP_SIZE_CONFIG=$mercury_cv_javac_flags_for_heap_size_config
;;
no)
- JAVAC_FLAGS_FOR_HEAP_SIZE=
+ JAVAC_FLAGS_FOR_HEAP_SIZE_MMAKE=
+ JAVAC_FLAGS_FOR_HEAP_SIZE_CONFIG=
;;
esac
-AC_SUBST(JAVAC_FLAGS_FOR_HEAP_SIZE)
+AC_SUBST(JAVAC_FLAGS_FOR_HEAP_SIZE_MMAKE)
+AC_SUBST(JAVAC_FLAGS_FOR_HEAP_SIZE_CONFIG)
#-----------------------------------------------------------------------------#
# Erlang configuration
diff --git a/m4/mercury.m4 b/m4/mercury.m4
index 85516cb..c93623c 100644
--- a/m4/mercury.m4
+++ b/m4/mercury.m4
@@ -560,12 +560,18 @@ 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])
- # There are two versions of this. The _test version is the one we test
- # here. The second one, with the escaped quotes, is the one that gets
- # included in the output files. The quotes are necessary in order for
- # --restricted-command-line to work with the Java backend.
+ # There are three versions of this. The '_test' version is the one we
+ # test here; the '_mmake' version is the one that gets included in
+ # in the Mmake.vars file and the '_config' verison is the version that
+ # gets in included in the Mercury.config file.
+ # The difference between the three versions is how much we need to
+ # escape the double quotes; in particular we need to ensure that they
+ # are *not* escaped in Mmake.vars and *are* escaped in Mercury.config.
+ # The latter is necessary in order for --restricted-command-line to
+ # work.
mercury_cv_javac_flags_for_heap_size_test="-J-Xmx256m"
- mercury_cv_javac_flags_for_heap_size="-J\"-Xmx1024m\""
+ mercury_cv_javac_flags_for_heap_size_mmake="-J\"-Xmx1024m\""
+ mercury_cv_javac_flags_for_heap_size_config="-J\\\"-Xmx1024m\\\""
if "$JAVAC" "$mercury_cv_javac_flags_for_heap_size_test" -version \
2> /dev/null
then
diff --git a/scripts/Mercury.config.bootstrap.in b/scripts/Mercury.config.bootstrap.in
index c9c730e..30fbcb1 100644
--- a/scripts/Mercury.config.bootstrap.in
+++ b/scripts/Mercury.config.bootstrap.in
@@ -77,7 +77,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@" \
+ --java-flags "@JAVAC_FLAGS_FOR_HEAP_SIZE_CONFIG@" \
--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 5ff6f6c..f793f13 100644
--- a/scripts/Mercury.config.in
+++ b/scripts/Mercury.config.in
@@ -72,7 +72,7 @@ DEFAULT_MCFLAGS=\
--cflags-for-gotos "@CFLAGS_FOR_GOTOS@" \
--cflags-for-pic "@CFLAGS_FOR_PIC@" \
--c-flag-to-name-object-file "@OBJFILE_OPT@" \
- --java-flags "@JAVAC_FLAGS_FOR_HEAP_SIZE@" \
+ --java-flags "@JAVAC_FLAGS_FOR_HEAP_SIZE_CONFIG@" \
--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 c21b166..972bc64 100644
--- a/scripts/Mmake.vars.in
+++ b/scripts/Mmake.vars.in
@@ -260,7 +260,7 @@ LIB_CSCFLAGS =
JAVAC = @JAVAC@
ALL_JAVACFLAGS = $(JAVACFLAGS) $(EXTRA_JAVACFLAGS) $(TARGET_JAVACFLAGS) \
$(LIB_JAVACFLAGS)
-JAVACFLAGS = @JAVAC_FLAGS_FOR_HEAP_SIZE@
+JAVACFLAGS = @JAVAC_FLAGS_FOR_HEAP_SIZE_MMAKE@
EXTRA_JAVACFLAGS =
# XXX Should we set LIB_JAVACFLAGS?
LIB_JAVACFLAGS =
More information about the reviews
mailing list