[m-rev.] for review: extend configure to support an hlc source distribution
Julien Fischer
juliensf at csse.unimelb.edu.au
Tue Mar 2 01:21:55 AEDT 2010
For review by anyone. I would draw attention to the change of behaviour
when there are no pre-generated C files and no bootstrap Mercury compiler.
Is the current behaviour, proceeding as far as the compilation of the
standard library, intended? If so, why?
---------
Extend the configure script to support an "hlc" version of the source
distribution, in addition to the usual low-level C source distribution.
Note that this diff assumes that hlc.gc is the only grade that is going to be
used in the "hlc" source distribution -- currently, we cannot detect the
presence of other optional high-level C features, e.g. high-level data, nested
functions, in the generated C files anyway.
configure.in:
If we don't have a (working) Mercury compiler from which to
bootstrap, but do have some pre-generated C files, then check
whether those files were generated with --highlevel-code
enabled.
Force the bootstrap grade to be hlc.gc if we are compiling
the source distribution and the pre-generated C files were
created with --highlevel-code enabled.
Abort early and emit an error message if we do not have
any pre-generated C files and we also do not have a bootstrap
Mercury compiler -- currently this situation is not checked
for, and compilation proceeds as far as the standard library.
(XXX Is this behaviour intended?)
When checking whether any C files need to be rebuilt take the
code model used to generate them into consideration as well.
Julien.
Index: configure.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/configure.in,v
retrieving revision 1.558
diff -u -r1.558 configure.in
--- configure.in 27 Dec 2009 23:36:31 -0000 1.558
+++ configure.in 1 Mar 2010 14:03:13 -0000
@@ -224,7 +224,9 @@
MERCURY_MSG("wrong mmc ignored")
;;
esac
-if test "$BOOTSTRAP_MC" != ""; then
+
+if test "$BOOTSTRAP_MC" != ""
+then
AC_MSG_CHECKING(whether the above mmc works and is sufficiently recent)
cat > conftest.m << EOF
% This module contains features which didn't work in
@@ -370,7 +372,7 @@
# Note that we need to set --grade to an LLDS grade
# when doing this test because term size profiling
# requires an LLDS grade.
- # This also tests for the --shlib-linker-intall-name-flag,
+ # This also tests for the --shlib-linker-install-name-flag,
# --warn-known-bad-format-calls and
# --warn-insts-without-matching-type options.
$BOOTSTRAP_MC \
@@ -399,6 +401,9 @@
test -f $PREFIX/bin/mercury_compile ||
test -f $PREFIX/bin/mercury_compile.exe
then
+ # This variable is used to let the tests in the following section know
+ # that we are going to attempt to bootstrap with the compiler $PREFIX/bin.
+ bootstrap_from_prefix="yes"
AC_MSG_WARN(
[using $PREFIX/bin/mercury_compile to bootstrap])
else
@@ -408,6 +413,62 @@
fi
rm -f conftest*
fi
+
+#-----------------------------------------------------------------------------#
+
+if test "$BOOTSTRAP_MC" = ""
+then
+ # If we do not have a working boostrap Mercury compiler, then work out
+ # whether any .c files we do have were compiled with --highlevel code or
+ # not. At this point we only check a single file -- this is enough to
+ # allow us to determine a value for BOOTSTRAP_GRADE below -- we check
+ # any other pre-generated .c files as part of the call to
+ # mercury_check_c_files() later on.
+ #
+ if test -f compiler/top_level.c
+ then
+ highlevel_code=`grep "HIGHLEVEL_CODE\=.*" compiler/top_level.c`
+ else
+ if test -f compiler/Mercury/cs/top_level.c
+ then
+ highlevel_code=`grep "HIGHLEVEL_CODE\=.*" compiler/Mercury/cs/top_level.c`
+ else
+ # If we are going to attempt to bootstrap from a compiler in
+ # $PREFIX/bin (see the above section), the it is ok if we don't
+ # have any pre-generated .c files; if not, then we cannot continue.
+ #
+ if test "$bootstrap_from_prefix" != "yes"
+ then
+ AC_MSG_ERROR(
+[You need a working Mercury compiler to bootstrap with])
+ fi
+ fi
+ fi
+
+ case "$highlevel_code" in
+
+ *yes)
+ BOOTSTRAP_HLC="yes"
+ ;;
+
+ *no)
+ BOOTSTRAP_HLC="no"
+ ;;
+
+ "")
+ # This corresponds to the case where we compile using
+ # $PREFIX/bin/mercury_compile. Since we can (hopefully)
+ # regenerate any .c files, it is irrelevant whether we used
+ # --highlevel-code or not when compiling any existing ones.
+ ;;
+
+ *)
+ AC_MSG_ERROR(
+[Cannot determine what code model pre-generated .c files use.])
+ ;;
+ esac
+fi
+
#-----------------------------------------------------------------------------#
#
# Let the user specify which C compiler to use.
@@ -3078,29 +3139,32 @@
;;
esac
-# BOOTSTRAP_GRADE is the most efficient grade which we can use to bootstrap
-# the compiler from the source distribution, if there is no installed Mercury
-# compiler. This grade needs to be one for which the C files are
-# compatible with the C files that we ship in the source distribution,
-# which are generated with grade asm_fast.gc.
-
-# In order to be compatible with grade asm_fast.gc, it needs to be an LLDS
-# grade. We generate the same C code for the base LLDS grades, except that a
-# couple of them (fast and jump) don't support code addresses in static
-# initializers.
+# BOOTSTRAP_GRADE is the most efficient grade which we can use to bootstrap the
+# compiler from the source distribution, if there is no installed Mercury
+# compiler. This grade needs to be one for which the C files are compatible
+# with the C files that we ship in the source distribution. The C files in the
+# source distribution are generated in either hlc.gc or in asm_fast.gc. In the
+# former case, we _must_ use the grade hlc.gc, in the latter case we can use any
+# of the base LLDS grades (it's the same C code), except that a couple of them
+# (fast and jump) don't support code addresses in static initalizers.
-case $BEST_LLDS_BASE_GRADE in
- jump|fast)
- if test $mercury_cv_gcc_model_reg = yes; then
- BOOTSTRAP_GRADE=reg.gc
- else
- BOOTSTRAP_GRADE=none.gc
- fi
- ;;
- *)
- BOOTSTRAP_GRADE=$BEST_LLDS_BASE_GRADE.gc
- ;;
-esac
+if test "$BOOTSTRAP_HLC" = "yes"
+then
+ BOOTSTRAP_GRADE=hlc.gc
+else
+ case $BEST_LLDS_BASE_GRADE in
+ jump|fast)
+ if test $mercury_cv_gcc_model_reg = yes; then
+ BOOTSTRAP_GRADE=reg.gc
+ else
+ BOOTSTRAP_GRADE=none.gc
+ fi
+ ;;
+ *)
+ BOOTSTRAP_GRADE=$BEST_LLDS_BASE_GRADE.gc
+ ;;
+ esac
+fi
# Choose whether to use $BOOTSTRAP_GRADE or $BEST_GRADE_FOR_COMPILER,
# and if necessary remove the previously built C files.
@@ -4838,6 +4902,14 @@
#-----------------------------------------------------------------------------#
+# We need to check that any existing .c files are compatible with the selected
+# grade with respect to whether --highlevel-code was used to generate them.
+#
+case "$GRADE" in
+ hl*) need_hl_c_files="yes" ;;
+ *) need_hl_c_files="no" ;;
+esac
+
mercury_check_c_files () {
c_dir=$1
c_date_dir=$2
@@ -4855,6 +4927,8 @@
if grep "TAG_BITS=$mercury_cv_low_tag_bits" \
confscratch > /dev/null 2>&1 \
&& grep "UNBOXED_FLOAT=$mercury_cv_unboxed_floats" \
+ confscratch > /dev/null 2>&1 \
+ && grep "HIGHLEVEL_CODE=$need_hl_c_files" \
confscratch > /dev/null 2>&1
then
some_kept=true
--------------------------------------------------------------------------
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