configure.in:
Rename this to configure.ac which is what current versions
of autotools expect and also doesn't cause warnings to be
emitted by aclocal.
Mmakefile:
scripts/ml.in:
Conform to the above change.
Delete the empty lazy_evaluation directory from extras.
*/.cvsignore:
Make this into .gitignore files.
(Update them where necessary.)
extra/lazy_evalution:
Delete this directory; its former contents were moved
elsewhere some time ago.
Branches: main, 12.08(?)
Further work on PowerShell integration -- PowerShell is now usable as a host
environment type for Mercury. As a target environment type, PowerShell is
currently treated as identical to cmd.exe by Mercury.
compiler/module_cmds.m:
Fix an XXX: on Windows with PowerShell we can redirect standard
error in the shell; do so.
compiler/compile_target_code.m:
When --verbose-commands is enabled, include any escapes for @files
in the verbose message. (This assists with manually debugging
such command lines.)
Branches: main, 12.08 (probably)
Begin work on integrating Mercury with Windows PowerShell.
In the absence of Cygwin or MinGW/MSYS, using the Mercury compiler on Windows
has been rather troublesome, mostly due to the fact that cmd.exe is rubbish.
I've been experimenting with using PowerShell in place of cmd.exe recently
and my initial impressions are that it works much better.
This diff fixes a few issues that arise when COMSPEC is set to powershell.exe
rather than cmd.exe, in addition to adding powershell to the list of supported
environment types. This is still work-in-progress.
compiler/globals.m:
Add PowerShell to the list of environment types.
compiler/compile_target_code.m:
With PowerShell we need to escape the `@' character: do so
when generating command lines that use @files.
compiler/module_cmds.m:
Unix and cmd.exe style redirection of standard input doesn't
work on PowerShell.
XXX add a couple of notes about things that could be improved.
Branches: main, 12.08
Fix errors checking for a trailing slash in dir./ and
dir.is_dotnet_root_directory which would throw an exception if the
last codepoint in the tested path consists of multiple code units.
This fixes bug #269.
library/dir.m:
As above.
Branches: main, 12.08
Fix a problem statically linking Mercury executables with gcc 4.7
on Linux.
configure.in:
Add a comma after GCC's -Wl option. GCC 4.7 (on Fedora 17)
no longer recognises the variant without the comma.
(XXX I'm not sure that the whole -Wl,-defsym -Wl,_DYNAMIC=0
thing is actually necessary these days -- things seem fine
on my machine without it, but I haven't tested this on
other machines.)
Estimated hours taken: 2
Branches: main, 12.08
Sign the all the assemblies in the csharp grade.
mercury.snk:
The strong name key used for signing.
analysis/ANALYSIS_FLAGS.in:
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
Pass the signing key to the c# compiler.
scripts/prepare_install_dir.in:
Copy mercury.snk to the install dir.
Estimated hours taken: 0.5
Branches: main
runtime/mercury_stack_trace.c:
Avoid a core dump that we used to get when traversing stack frames
without debug info, such as the stack frames of hand-written procedures
like builtin_catch.
# Copyright (C) 1999,2001-2004, 2006-2012 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public Licence - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
#
# aclocal.m4
#
# This file contains Mercury-specific autoconf tests.
#
# We ought to move most of the code in configure.in into this file...
#
#-----------------------------------------------------------------------------#
AC_DEFUN([MERCURY_CHECK_FOR_HEADERS],
[
for mercury_cv_header in $1; do
mercury_cv_header_define="MR_HAVE_`echo $mercury_cv_header | \
tr abcdefghijklmnopqrstuvwxyz./ ABCDEFGHIJKLMNOPQRSTUVWXYZ__`"
AC_CHECK_HEADER($mercury_cv_header, [
AC_DEFINE_UNQUOTED($mercury_cv_header_define)
eval "$mercury_cv_header_define=1"
])
done
])
#-----------------------------------------------------------------------------#
AC_DEFUN([MERCURY_CHECK_FOR_IEEEFP_H],
[
MERCURY_CHECK_FOR_HEADERS(ieeefp.h)
])
AC_DEFUN([MERCURY_CHECK_FOR_IEEE_FUNC],
[
AC_REQUIRE([MERCURY_CHECK_FOR_IEEEFP_H])
AC_MSG_CHECKING(for $1 function)
mercury_cv_ieee_func_define="MR_HAVE_`echo $1 | \
tr abcdefghijklmnopqrstuvwxyz./ ABCDEFGHIJKLMNOPQRSTUVWXYZ__`"
AC_TRY_LINK([
#include <math.h>
#ifdef MR_HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
],[
float f;
$1(f);
],[mercury_cv_have_ieee_func=yes],[mercury_cv_have_ieee_func=no])
if test "$mercury_cv_have_ieee_func" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE_UNQUOTED($mercury_cv_ieee_func_define)
else
AC_MSG_RESULT(no)
fi
])
#-----------------------------------------------------------------------------#
# Test for C99 fp environment functions in the math library.
# The second argument to this macro should be the flags required by the
# C compiler to link against the math library. This is needed because
# some OSs, e.g. Mac OS X, don't have a separate math library.
AC_DEFUN([MERCURY_CHECK_FOR_FENV_FUNC],
[
AC_MSG_CHECKING(for $1 function)
mercury_cv_math_func_define="MR_HAVE_`echo $1 | \
tr abcdefghijklmnopqrstuvwxyz./ ABCDEFGHIJKLMNOPQRSTUVWXYZ__`"
save_libs="$LIBS"
LIBS="$2 $LIBS"
AC_TRY_LINK([
#ifdef MR_HAVE_FENV_H
#include <fenv.h>
#endif
],[
int i = 0;
$1(i);
],[mercury_cv_have_math_func=yes],[mercury_cv_have_math_func=no])
LIBS="$save_libs"
if test "$mercury_cv_have_math_func" = "yes"
then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([$mercury_cv_math_func_define])
else
AC_MSG_RESULT([no])
fi
])
#-----------------------------------------------------------------------------#
#
# Turn off MacOS's so-called "smart" C preprocessor, if present,
# since it causes lots of spurious warning messages,
# and furthermore it takes way too long and uses way too much memory
# when preprocessing the C code generated by the Mercury compiler's LLDS
# back-end.
#
AC_DEFUN([MERCURY_CHECK_CC_NEEDS_TRAD_CPP],
[
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(whether C compiler needs -no-cpp-precomp)
AC_CACHE_VAL(mercury_cv_cpp_precomp, [
>conftest.c
if test "$GCC" = yes &&
$CC -v -c conftest.c 2>&1 | \
grep "cpp-precomp.*-smart" > /dev/null
then
mercury_cv_cpp_precomp=yes
else
mercury_cv_cpp_precomp=no
fi
])
AC_MSG_RESULT($mercury_cv_cpp_precomp)
if test $mercury_cv_cpp_precomp = yes; then
CC="$CC -no-cpp-precomp"
fi
])
#-----------------------------------------------------------------------------#
#
# Check whether we need to add any extra directories to the search path for
# header files, and set ALL_LOCAL_C_INCL_DIRS to the -I option(s) needed
# for this, if any.
#
# GNU C normally searches /usr/local/include by default;
# to keep things consistent, we do the same for other C compilers.
#
AC_DEFUN([MERCURY_CHECK_LOCAL_C_INCL_DIRS],
[
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(whether to pass -I/usr/local/include to C compiler)
ALL_LOCAL_C_INCL_DIRS=""
ALL_LOCAL_C_INCL_DIR_MMC_OPTS=""
if test "$GCC" = yes -o "$USING_MICROSOFT_CL_COMPILER" = yes; then
# Don't add -I/usr/local/include, since it causes a warning
# with gcc 3.1, and gcc already searches /usr/local/include.
# Microsoft compilers don't understand Unix pathnames.
AC_MSG_RESULT(no)
else
# It's some other compiler. We don't know if it searches
# /usr/local/include by default, so add it.
if test -d /usr/local/include/.; then
AC_MSG_RESULT(yes)
ALL_LOCAL_C_INCL_DIRS="-I/usr/local/include "
ALL_LOCAL_C_INCL_DIR_MMC_OPTS="--c-include-directory /usr/local/include "
else
AC_MSG_RESULT(no)
fi
fi
AC_SUBST(ALL_LOCAL_C_INCL_DIRS)
AC_SUBST(ALL_LOCAL_C_INCL_DIR_MMC_OPTS)
])
#-----------------------------------------------------------------------------#
#
# Set ALL_LOCAL_C_LIB_DIRS to any extra directories we need to add to the
# search path for libraries.
#
AC_DEFUN([MERCURY_CHECK_LOCAL_C_LIB_DIRS],
[
AC_MSG_CHECKING(whether to pass -L/usr/local/lib to the linker)
# Microsoft compilers don't understand Unix pathnames.
if test "$USING_MICROSOFT_CL_COMPILER" = no -a -d /usr/local/lib/.; then
AC_MSG_RESULT(yes)
ALL_LOCAL_C_LIB_DIRS=/usr/local/lib
ALL_LOCAL_C_LIB_DIR_MMC_OPTS="-L/usr/local/lib -R/usr/local/lib"
else
AC_MSG_RESULT(no)
ALL_LOCAL_C_LIB_DIRS=
ALL_LOCAL_C_LIB_DIR_MMC_OPTS=
fi
AC_SUBST(ALL_LOCAL_C_LIB_DIRS)
AC_SUBST(ALL_LOCAL_C_LIB_DIR_MMC_OPTS)
])
#-----------------------------------------------------------------------------#
#
# Check for readline and related header files and libraries
#
AC_DEFUN([MERCURY_CHECK_READLINE],
[
AC_ARG_WITH(readline,
[ --without-readline Don't use the GPL'd GNU readline library],
mercury_cv_with_readline="$withval", mercury_cv_with_readline=yes)
if test "$mercury_cv_with_readline" = yes; then
# check for the readline header files
MERCURY_CHECK_FOR_HEADERS(readline/readline.h readline/history.h)
# check for the libraries that readline depends on
MERCURY_MSG('looking for termcap or curses (needed by readline)...')
AC_CHECK_LIB(termcap, tgetent, mercury_cv_termcap_lib=-ltermcap,
[AC_CHECK_LIB(curses, tgetent, mercury_cv_termcap_lib=-lcurses,
[AC_CHECK_LIB(ncurses, tgetent, mercury_cv_termcap_lib=-lncurses,
mercury_cv_termcap_lib='')])])
# check for the readline library
AC_CHECK_LIB(readline, readline, mercury_cv_have_readline=yes,
mercury_cv_have_readline=no, $mercury_cv_termcap_lib)
else
mercury_cv_have_readline=no
fi
# Now figure out whether we can use readline, and define variables according.
# Note that on most systems, we don't actually need the header files in
# order to use readline. (Ain't C grand? ;-).
if test $mercury_cv_have_readline = no; then
TERMCAP_LIBRARY=""
READLINE_LIBRARIES=""
AC_DEFINE(MR_NO_USE_READLINE)
else
TERMCAP_LIBRARY="$mercury_cv_termcap_lib"
READLINE_LIBRARIES="-lreadline $TERMCAP_LIBRARY"
fi
AC_SUBST(TERMCAP_LIBRARY)
AC_SUBST(READLINE_LIBRARIES)
])
#-----------------------------------------------------------------------------#
#
# Microsoft.NET configuration
#
AC_DEFUN([MERCURY_CHECK_DOTNET],
[
AC_PATH_PROG([ILASM], [ilasm])
AC_PATH_PROG([GACUTIL], [gacutil])
AC_MSG_CHECKING([for Microsoft.NET Framework SDK])
AC_CACHE_VAL([mercury_cv_microsoft_dotnet], [
if test "$ILASM" != ""; then
changequote(<<,>>)
MS_DOTNET_SDK_DIR=`expr "$ILASM" : '\(.*\)[/\\]*[bB]in[/\\]*ilasm'`
changequote([,])
mercury_cv_microsoft_dotnet="yes"
else
MS_DOTNET_SDK_DIR=""
mercury_cv_microsoft_dotnet="no"
fi
])
AC_MSG_RESULT([$mercury_cv_microsoft_dotnet])
ILASM=`basename "$ILASM"`
GACUTIL=`basename "$GACUTIL"`
# Check for the C# (C sharp) compiler.
# mcs is the Mono C# compiler targetting all runtimes
# dmcs is the Mono C# compiler targeting the 4.0 runtime
# gmcs is the Mono C# compiler targeting the 2.0 runtime (with generics).
# cscc is the DotGNU C# compiler.
AC_PATH_PROGS([CANDIDATE_CSC], [csc mcs dmcs gmcs cscc])
CANDIDATE_CSC=`basename "$CANDIDATE_CSC"`
# The Microsoft C# compiler and the Chicken Scheme compiler share the same
# executable name so if we find an executable named csc above check that it is
# actually the Microsoft C# compiler and if it is not then try to use one of
# the other instead.
#
case "$CANDIDATE_CSC" in
csc*)
$CANDIDATE_CSC 2>&1 | grep -q "^Microsoft"
if test $? -ne 0
then
AC_MSG_WARN([$CANDIDATE_CSC is not the Microsoft C sharp compiler])
AC_PATH_PROGS([CSC], [mcs dmcs gmcs cscc])
CSC=`basename "$CSC"`
else
CSC="$CANDIDATE_CSC"
fi
;;
*)
CSC="$CANDIDATE_CSC"
;;
esac
case "$CSC" in
csc*)
CSHARP_COMPILER_TYPE=microsoft
;;
mcs*)
CSHARP_COMPILER_TYPE=mono
;;
dmcs*)
CSHARP_COMPILER_TYPE=mono
;;
gmcs*)
CSHARP_COMPILER_TYPE=mono
;;
*)
CSHARP_COMPILER_TYPE=unknown
;;
esac
# We default to the Beta 2 version of the library
mercury_cv_microsoft_dotnet_library_version=1.0.2411.0
if test $mercury_cv_microsoft_dotnet = "yes" &&
test "$CSC" != "";
then
AC_MSG_CHECKING([version of .NET libraries])
cat > conftest.cs << EOF
using System;
using System.Reflection;
public class version {
public static void Main()
{
Assembly asm = Assembly.Load("mscorlib");
AssemblyName name = asm.GetName();
Version version = name.Version;
Console.Write(version);
Console.Write("\n");
}
}
EOF
if
echo $CSC conftest.cs >&AC_FD_CC 2>&1 && \
$CSC conftest.cs >&AC_FD_CC 2>&1 && \
./conftest > conftest.out 2>&1
then
mercury_cv_microsoft_dotnet_library_version=`cat conftest.out`
AC_MSG_RESULT([$mercury_cv_microsoft_dotnet_library_version])
rm -f conftest*
else
rm -f conftest*
if test "$enable_dotnet_grades" = "yes"; then
AC_MSG_ERROR([unable to determine version])
exit 1
else
AC_MSG_WARN([unable to determine version])
fi
fi
fi
MS_DOTNET_LIBRARY_VERSION=$mercury_cv_microsoft_dotnet_library_version
# Check for the assembly linker.
# ilalink is the DotGNU assembly linker.
AC_PATH_PROGS([MS_AL], [al ilalink])
MS_AL=`basename "$MS_AL"`
# Check for an implementation of the Common Language Infrastructure.
AC_PATH_PROGS([CLI_INTERPRETER], [mono])
MONO=`basename "$CLI_INTERPRETER"`
AC_SUBST([ILASM])
AC_SUBST([GACUTIL])
AC_SUBST([CSC])
AC_SUBST([CSHARP_COMPILER_TYPE])
AC_SUBST([MS_AL])
AC_SUBST([MS_DOTNET_SDK_DIR])
AC_SUBST([MS_DOTNET_LIBRARY_VERSION])
AC_SUBST([MS_VISUALCPP_DIR])
AC_SUBST([CLI_INTERPRETER])
])
#-----------------------------------------------------------------------------#
#
# Java configuration
#
AC_DEFUN([MERCURY_CHECK_JAVA],
[
# jikes requires the usual Java SDK to run, so if we checked for javac first,
# then that's what we'd get. If the user has jikes installed, then that
# probably means that they want to use it, so we check for jikes before javac.
# On Windows, the Java SDK has a high chance of being installed in a path
# containing spaces. The simplest solution is to keep only the basename.
# Everything will still work so long as the executables can be found on the
# PATH later.
AC_PATH_PROGS(JAVAC, jikes javac gcj)
case "$JAVAC" in
*" "*)
JAVAC=`basename "$JAVAC"`
;;
esac
case "$JAVAC" in
*gcj)
JAVAC="$JAVAC -C"
;;
esac
AC_PATH_PROG(JAVA_INTERPRETER, java gij)
case "$JAVA_INTERPRETER" in
*" "*)
JAVA_INTERPRETER=`basename "$JAVA_INTERPRETER"`
;;
esac
AC_PATH_PROG(JAR, jar)
case "$JAR" in
*" "*)
JAR=`basename "$JAR"`
;;
esac
AC_CACHE_VAL(mercury_cv_java, [
if test "$JAVAC" != "" -a "$JAVA_INTERPRETER" != "" -a "$JAR" != ""; then
AC_MSG_CHECKING(if the above Java SDK works and is sufficiently recent)
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.5, printing "Hello, world"
// if successful.
public class conftest {
public static void main (String[[]] args) {
float version;
String strVer = System.getProperty(
"java.specification.version");
try {
version = Float.valueOf(strVer).floatValue();
}
catch (NumberFormatException e) {
System.out.println("ERROR: \"java." +
"specification.version\" " +
"constant has incorrect " +
"format.\nGot \"" + strVer +
"\", expected a number.");
version = 0f;
}
if (version >= 1.5f) {
System.out.println("Hello, world\n");
} else {
System.out.println("Nope, sorry.\n");
}
}
}
EOF
if
echo "$JAVAC" conftest.java >&AC_FD_CC 2>&1 &&
"$JAVAC" conftest.java >&AC_FD_CC 2>&1 &&
echo "$JAVA_INTERPRETER" conftest > conftest.out 2>&AC_FD_CC &&
CLASSPATH=. "$JAVA_INTERPRETER" conftest > conftest.out 2>&AC_FD_CC &&
test "`tr -d '\015' < conftest.out`" = "Hello, world"
then
mercury_cv_java="yes"
else
mercury_cv_java="no"
fi
AC_MSG_RESULT($mercury_cv_java)
else
if test "$JAVAC" = ""; then
JAVAC="javac"
fi
if test "$JAVA_INTERPRETER" = ""; then
JAVA_INTERPRETER="java"
fi
if test "$JAR" = ""; then
JAR="jar"
fi
mercury_cv_java="no"
fi
])
AC_SUBST(JAVAC)
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])
# 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.
mercury_cv_javac_flags_for_heap_size_test="-J-Xmx256m"
mercury_cv_javac_flags_for_heap_size="-J\"-Xmx1024m\""
if "$JAVAC" "$mercury_cv_javac_flags_for_heap_size_test" -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
#
# copy of AC_ERLANG_PATH_ERLC from autoconf-2.60
AC_DEFUN([MERCURY_ERLANG_PATH_ERLC],
[AC_ARG_VAR([ERLC], [Erlang/OTP compiler command [autodetected]])dnl
if test -n "$ERLC"; then
AC_MSG_CHECKING([for erlc])
AC_MSG_RESULT([$ERLC])
else
AC_PATH_TOOL(ERLC, erlc, [$1], [$2])
fi
AC_ARG_VAR([ERLCFLAGS], [Erlang/OTP compiler flags [none]])dnl
])
# copy of AC_ERLANG_PATH_ERL from autoconf-2.60
AC_DEFUN([MERCURY_ERLANG_PATH_ERL],
[AC_ARG_VAR([ERL], [Erlang/OTP interpreter command [autodetected]])dnl
if test -n "$ERL"; then
AC_MSG_CHECKING([for erl])
AC_MSG_RESULT([$ERL])
else
AC_PATH_TOOL(ERL, erl, [$1], [$2])[]dnl
fi
])
AC_DEFUN([MERCURY_CHECK_ERLANG],
[
MERCURY_ERLANG_PATH_ERLC
MERCURY_ERLANG_PATH_ERL
if test "$ERLC" != "" -a "$ERL" != ""; then
mercury_cv_erlang="yes"
else
mercury_cv_erlang="no"
fi
AC_SUBST(ERLC)
AC_SUBST(ERL)
])
#-----------------------------------------------------------------------------#
# NOTE: updates to this macro may need to be reflected in compiler/globals.m.
# Generating an executable and running it does not work when cross-compiling.
AC_DEFUN([MERCURY_GCC_VERSION], [
AC_REQUIRE([AC_PROG_CC])
mercury_cv_gcc_version=`$CC -dumpversion | tr . ' ' | {
read major minor patchlevel ignore
echo ${major:-u}_${minor:-u}_${patchlevel:-u}
}`
])
#-----------------------------------------------------------------------------#
# Work out the C compiler type using a stronger test than AC_PROG_CC to
# distinguish between clang and gcc.
# (We don't handle lcc here - I don't think that it's possible to.)
AC_DEFUN([MERCURY_CC_TYPE], [
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([what the C compiler type really is])
# MSVC uses different command line options to most other C compilers.
# Try to determine whether CC is MSVC based on the usage message.
#
$CC 2>&1 | grep -q "^Microsoft"
if test $? -eq 0
then
cc_out_opt="-Fe"
nologo_opt="-nologo"
else
cc_out_opt="-o "
nologo_opt=
fi
cat > conftest.c << EOF
#include <stdio.h>
int main(int argc, char **argv)
{
#if defined(__clang__)
printf("clang");
#elif defined(__GNUC__)
printf("gcc");
#elif defined(_MSC_VER)
printf("msvc");
#else
printf("unknown");
#endif
return 0;
}
EOF
echo "$CC $nologo_opt ${cc_out_opt}conftest conftest.c" >&AC_FD_CC 2>&1
if
# We direct the output to /dev/null because it's appears to be the
# only way to shut some C compilers up.
$CC $nologo_opt ${cc_out_opt}conftest conftest.c 2>&1 > /dev/null
then
AC_CACHE_VAL(mercury_cv_cc_type,
mercury_cv_cc_type=`./conftest`)
else
# This shouldn't happen as we have already checked for this.
AC_MSG_ERROR([unexpected: $CC cannot create executable])
fi
AC_MSG_RESULT([$mercury_cv_cc_type])
])
#-----------------------------------------------------------------------------#
AC_DEFUN([MERCURY_CLANG_VERSION], [
AC_REQUIRE([AC_PROG_CC])
cat > conftest.c << EOF
#include <stdio.h>
int main(int argc, char **argv)
{
printf("%d_%d_%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
return 0;
}
EOF
echo "$CC -o conftest contest.c" >&AC_FD_CC 2>&1
if
$CC -o conftest conftest.c
then
mercury_cv_clang_version=`./conftest`
else
# This shouldn't happen as we have already checked for this.
AC_MSG_ERROR([unexpected: $CC cannot create executable])
fi
])
#-----------------------------------------------------------------------------#
AC_DEFUN([MERCURY_MSVC_VERSION], [
AC_REQUIRE([AC_PROG_CC])
cat > conftest.c << EOF
#include <stdio.h>
int main(int argc, char **argv)
{
printf("%d", _MSC_VER);
return 0;
}
EOF
echo "$CC conftest.c -Fecontest" >&AC_FD_CC 2>&1
if
$CC conftest.c -Feconftest > /dev/null
then
mercury_cv_msvc_version=`./conftest`
else
# This shouldn't happen as we have already checked for this.
AC_MSG_ERROR([unexpected: $CC cannot create executable])
fi
])
#-----------------------------------------------------------------------------#
#
# Check if the POSIX threads library is pthreads-win32.
#
AC_DEFUN([MERCURY_HAVE_PTHREADS_WIN32], [
AC_MSG_CHECKING([if we are using pthreads-win32])
cat > conftest.c << EOF
#include <pthread.h>
#include <stdio.h>
int main(int argc, char **argv)
{
#if defined(PTW32_VERSION)
return 0;
#else
return 1;
#endif
}
EOF
echo "$CC -o conftest contest.c" >&AC_FD_CC 2>&1
if
$CC -o conftest conftest.c
then
mercury_cv_have_pthreads_win32="yes"
else
mercury_cv_have_pthreads_win32="no"
fi
AC_MSG_RESULT($mercury_cv_have_pthreads_win32)
])
#-----------------------------------------------------------------------------#
The mercury_main() function is used in both standalone and library builds of
Mercury code. However the main function where the code was was only used in
standalone programs. The Mercury compiler is built as a library and
usually liked with main.c in the root directory, this is done so that it can
be used with GCC for the GCC backend. I have moved the sbrk profiling code
into mercury_main so that it will be executed by the compiler. I used this
to generate memory usage information in my thesis.
util/mkinit.c:
As above.
Estimated hours taken: 4
Branches: main
Make the error messages that report mismatches in insts between different
branches of a branched control structure more useful, by reporting not just
the insts of the relevant variable at end of each branch, but also the
location of each branch. This makes it MUCH easier to interpret error
messages about large disjunctions and switches.
compiler/mode_errors.m:
Change the representation of errors of the above kind to include
the context of each inst, and print the contexts next to the insts.
compiler/instmap.m:
Give the predicates that merge instmaps the context of the goals
that the instmaps are talking about, so that if there are any errors,
these contexts can be given to mode_errors.m.
Remove the predicate instmap_unify and its helper predicates, since
it is not used anywhere.
compiler/modecheck_goal.m:
compiler/unique_modes.m:
Associate a context with each instmap before calling instmap.m
to merge those instmaps.
compiler/mercury_to_mercury.m:
Switch the order of the arguments of some functions and predicates
to make it easier to curry them; mode_errors.m wants this
functionality.
compiler/hlds_out_mode.m:
compiler/hlds_out_module.m:
compiler/prog_ctgc.m:
Conform to the changes above.
tests/invalid/merge_inst_error.{m,err_exp}:
New test case to test the new functionality.
tests/invalid/Mmakefile:
Enable the new test case.
tests/invalid/multimode_dcg.err_exp:
Update this expected output as well.
Branches: main, 12.08
Avoid a linker warning on Mac OS X 10.7 and 10.8.
configure.in:
Don't pass -s to the linker on all versions of Darwin.
It has been deprecated for several versions.
Estimated hours taken: 0.3
Branches: main
On the module summary page, display the link to the module representation page
only if we actually have access to the module representation.
deep_profiler/report.m:
Add a field giving this information to the data structure representing
the module summary page.
deep_profiler/create_report.m:
Fill in this field when generating module summary information.
deep_profiler/display_report.m:
Act on this field when displaying module summary pages.
Estimated hours taken: 0.1
Branches: main
compiler/notes/order_indep_state_update:
Add this file, which contains my design of how the OISU system
should work.
Estimated hours taken: 120
Branches: main
The algorithm that decides whether the order independent state update
transformation is applicable in a given module needs access to the list
of oisu pragmas in that module, and to information about the types
of variables in the procedures named in those pragmas. This diff
puts this information in Deep.procrep files, to make them available
to the autoparallelization feedback program, to which that algorithm
will later be added.
Compilers that have this diff will generate Deep.procrep files in a new,
slightly different format, but the deep profiler will be able to read
Deep.procrep files not just in the new format, but in the old format as well.
runtime/mercury_stack_layout.h:
Add to module layout structures the fields holding the new information
we want to put into Deep.procrep files. This means three things:
- a bytecode array in module layout structures encoding the list
of oisu pragmas in the module;
- additions to the bytecode arrays in procedure layout structures
mapping the procedure's variables to their types; and
- a bytecode array containing the encoded versions of those types
themselves in the module layout structure. This allows us to
represent each type used in the module just once.
Since there is now information in module layout structures that
is needed only for deep profiling, as well as information that is
needed only for debugging, the old arrangement that split a module's
information between two structures, MR_ModuleLayout (debug specific
info) and MR_ModuleCommonLayout (info used by both debugging and
profiling), is no longer approriate. We could add a third structure
containing profiling-specific info, but it is simpler to move
all the info into just one structure, some of whose fields
may not be used. This wastes only a few words of memory per module,
but allows the runtime system to avoid unnecessary indirections.
runtime/mercury_types.h:
Remove the type synonym for the deleted type.
runtime/mercury_grade.h:
The change in mercury_stack_layout.h destroys binary compatibility
with previous versions of Mercury for debug and deep profiling grades,
so bump their grade-component-specific version numbers.
runtime/mercury_deep_profiling.c:
Write out the information in the new fields in module layout
structures, if they are filled in.
Since this changes the format of the Deep.procrep file, bump
its version number.
runtime/mercury_deep_profiling.h:
runtime/mercury_stack_layout.c:
Conform to the change to mercury_stack_layout.h.
mdbcomp/program_representation.m:
Add to module representations information about the oisu pragmas
defined in that module, and the type table of the module.
Optionally add to procedure representations a map mapping
the variables of the procedure to their types.
Rename the old var_table type to be the var_name_table type,
since it contains just names. Make the var to type map separate,
since it will be there only for selected procedures.
Modify the predicates reading in module and procedure representations
to allow them to read in the new representation, while still accepting
the old one. Use the version number in the Deep.procrep file to decide
which format to expect.
mdbcomp/rtti_access.m:
Add functions to encode the data representations that this module
also decodes.
Conform to the changes above.
mdbcomp/feedback.automatic_parallelism.m:
Conform the changes above.
mdbcomp/prim_data.m:
Fix layout.
compiler/layout.m:
Update the compiler's representation of layout structures
to conform to the change to runtime/mercury_stack_layout.h.
compiler/layout_out.m:
Output the new parts of module layout structures.
compiler/opt_debug.m:
Allow the debugging of code referring to the new parts of
module layout structures.
compiler/llds_out_file.m:
Conform to the move to a single module layout structure.
compiler/prog_rep_tables.m:
This new module provided mechanisms for building the string table
and the type table components of module layouts. The string table
part is old (it is moved here from stack_layout.m); the type table
part is new.
Putting this code in a module of its own allows us to remove
a circular dependency between prog_rep.m and stack_layout.m;
instead, both now just depend on prog_rep_tables.m.
compiler/ll_backend.m:
Add the new module.
compiler/notes/compiler_design.html:
Describe the new module.
compiler/prog_rep.m:
When generating the representation of a module for deep profiling,
include the information needed by the order independent state update
analysis: the list of oisu pragmas in the module, if any, and
information about the types of variables in selected procedures.
To avoid having these additions increasing the size of the bytecode
representation too much, convert some fixed 32 bit numbers in the
bytecode to use variable sized numbers, which will usually be 8 or 16
bits.
Do not use predicates from bytecode_gen.m to encode numbers,
since there is nothing keeping these in sync with the code that
reads them in mdbcomp/program_representation.m. Instead, use
new predicates in program_representation.m itself.
compiler/stack_layout.m:
Generate the new parts of module layouts.
Remove the code moved to prog_rep_tables.m.
compiler/continuation_info.m:
compiler/proc_gen.m:
Make some more information available to stack_layout.m.
compiler/prog_data.m:
Fix some formatting.
compiler/introduce_parallelism.m:
Conform to the renaming of the var_table type.
compiler/follow_code.m:
Fix the bug that used to cause the failure of the
hard_coded/mode_check_clauses test case in deep profiling grades.
deep_profiler/program_representation_utils.m:
Output the new parts of module and procedure representations,
to allow the correctness of this change to be tested.
deep_profiler/mdprof_create_feedback.m:
If we cannot read the Deep.procrep file, print a single error message
and exit, instead of continuing with an analysis that will generate
a whole bunch of error messages, one for each attempt to access
a procedure's representation.
deep_profiler/mdprof_procrep.m:
Give this program an option that specifies what file it is to
look at; do not hardwire in "Deep.procrep" in the current directory.
deep_profiler/report.m:
Add a report type that just prints the representation of a module.
It returns the same information as mdprof_procrep, but from within
the deep profiler, which can be more convenient.
deep_profiler/create_report.m:
deep_profiler/display_report.m:
Respectively create and display the new report type.
deep_profiler/query.m:
Recognize a query asking for the new report type.
deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/autopar_search_goals.m:
deep_profiler/autopar_types.m:
deep_profiler/branch_and_bound.m:
deep_profiler/coverage.m:
deep_profiler/display.m:
deep_profiler/html_format.m:
deep_profiler/mdprof_test.m:
deep_profiler/measurements.m:
deep_profiler/query.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/top_procs.m:
deep_profiler/top_procs.m:
Conform to the changes above.
Fix layout.
tests/debugger/declarative/dependency.exp2:
Add this file as a possible expected output. It contains the new
field added to module representations.
in the table for the calls into the procedure from its parent call sites.
Note that since this report shows proc static data parent call sites are
defined as calls to the procedure from other procedures (they may include
mutual recursion). As this may be a point of confusion this information is
only shown in developer mode.
report.m:
As above.
We also count the number of calls into this procedure, including the
numbers of unique ProcStatic and ProcDynamic structures seen.
The later is trivially the number of calls into the procedure.
create_report.m:
Generate this data.
display_report.m:
Handle the new report data.
display.m:
So that we only show this table row in developer mode, add a new table
row type (table_developer_row) that contains the real table row.
html_format.m:
Handle the new table row type.
This redesign prevents at least one race condition that could previously
occur with scheduling of contexts. This work actually represents an attempt
to design and check these algorithms rather than my previous work which was
no-where near as thorough.
runtime/mercury_context.[ch]:
Modified along with this are the actions that an engine can undertake,
many have been renamed but MR_ENGINE_ACTION_CONTEXT_ADVICE has been
added, which is given to an engine to instruct that engine to check the
context run queue.
There are now two procedures for notifying/waking engines.
try_wake_engine and try_notify_engine, the former is used only when an
engine is sleeping, the latter is to be used when the engine is idle but
not sleeping.
I've also modified how the MR_num_idle_engines counter is used. It
now counts the number of engines in the stealing or sleeping states.
A lot of fprintfs have been added for thread debugging. They use the
MR_DEBUG_THREADS macro and --debug-threads runtime option.
We now support polling and non-polling modes for work stealing. Engines
can either be notified when there is a new spark, slowing down spark
creation time. Or engines can wake up and poll other engines for
sparks meaning that the system doesn't idle well.
Remove MR_do_idle_clean_context which was a specialised entry point for
the MR_do_idle code. However there is not much difference between it
and MR_do_idle, so it is not worth maintaining two procedures.
Remove MR_do_idle_dirty_context, this logic has been re-implemented in
MR_join_and_continue where it can be faster.
Make MR_attempt_steal_spark skip stealing from the current engine.
Add a memory fence to MR_join_and_continue to make sure that context
data is saved before marking the context as runnable.
Modify the spark deque structure to reduce false-sharing. (Very minor
speed-up).
Estimated hours taken: 30
Branches: main
Implement semantic checks for oisu (order independent state update) pragmas.
compiler/hlds_pred.m:
Record for each procedure whether it implements an operation
on a oisu type, and if yes, what kind of operation.
compiler/hlds_module.m:
Add to module_infos a data structure that lists the oisu pragmas
in the module, and the procedures mentioned in them. These are intended
to be used later during code generation.
compiler/add_pragma.m:
Add such pragmas to the HLDS, after checking whatever properties
can be checked during the creation of the HLDS.
compiler/oisu_check.m:
A new module, whose job it is to check those aspects of oisu pragmas
that can be checked only after other semantics are complete on the
module.
compiler/check_hlds.m:
Add the new module.
compiler/notes/compiler_design.html:
Document the new module.
compiler/mercury_compile_front_end.m:
Invoke the new module.
compiler/error_util.m:
Add the new semantic check as a phase.
compiler/mercury_to_mercury.m:
Fix typos in the code for writing out oisu pragmas.
compiler/prog_io_pragmas.m:
Fix typos in the code for reading in oisu pragmas.
compiler/module_qual.m:
Improve the error messages generated for any problems discovered during
module qualification inside pragmas, by writing out what *kind* of
pragma the problem was discovered in.
compiler/modules.m:
Fix a bug: oisu pragmas *can* appear in module interfaces.
compiler/stratify.m:
Give a predicate a better interface and a name.
compiler/hlds_goal.m:
Remove a duplicate comment.
compiler/make_hlds_passes.m:
Fix formatting.
tests/hard_coded/oisu_check_main.{m,exp}:
tests/hard_coded/oisu_check_db.m:
A new multimodule test case, which uses oisu pragmas correctly.
tests/invalid/oisu_check_add_pragma_errors.{m,err_exp}:
A new test case, which tests add_pragma.m's ability to diagnose
the problems it is supposed to diagnose.
tests/invalid/oisu_check_semantic_errors.{m,err_exp}:
A new test case, which tests oisu_check.m's ability to diagnose
the problems it is supposed to diagnose.
tests/hard_coded/Mmakefile:
tests/invalid/Mmakefile:
Enable the new test cases.
Chase & Lev's algorithm for circular work stealing deques does not
specify a memory model, and appears to assume a strict memory model such
as Java provides, this I have inferred because the examples in their
paper use Java syntax.
When we translated their algorithms into C we introduced two bugs by
assuming that we could write the code in C as it appeared in the Java
examples. C has no specific memory model and allows your processor to
re-order many memory operations. This patch corrects both bugs by
introducing one memory fence operation per bug and explains the bugs and
fixes in comments.
Unfortunately this causes the fibs micro benchmark (without granularity
control) to slow down by almost one third. Which is disappointing bot
unavoidable.
runtime/mercury_wsdeque.h:
As above.
Estimated hours taken: 5
Branches: main
compiler/pred_table.m:
The predicates that searched the pred table used to return lists of
matching pred_ids, but they never returned empty lists; if there
were no matching pred_ids, they failed. This diff changes them
from semidet to det, and makes them return empty lists if there
are no matches.
This change simplifies both the code of these predicates, and the code
of the predicates calling them.
- Some callers of these predicates were prepared BOTH for the call
to fail, and for it to succeed returning an empty list; their types
allowed both.
- Some pattern-matched the return value againt a one-element list
in the call itself, and treated both no matches and multiple matches
the same, even though an error message for one will be misleading
for the other.
- All calls had to have a test for cons to pick up the first match;
this test was logically redundant, since they also had a test for
success/failure.
Change the names of the affected predicates by replacing "search"
in their names with "lookup", both to give the right intuition
about what they do, and to make sure I didn't miss updating any
callers.
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_pragma.m:
compiler/add_pred.m:
compiler/check_typeclass.m:
compiler/dead_proc_elim.m:
compiler/deep_profiling.m:
compiler/elds_to_erlang.m:
compiler/hlds_module.m:
compiler/intermod.m:
compiler/make_hlds_passes.m:
compiler/mmc_analysis.m:
compiler/post_typecheck.m:
compiler/recompilation.usage.m:
compiler/simplify.m:
compiler/type_constraints.m:
compiler/typecheck.m:
compiler/typecheck_errors.m:
Conform to the above change.
Estimated hours taken: 16
Branches: main
Add preliminary support for a new pragma that will be needed to implement
order-independent state update (oisu). The pragma will look like this:
:- pragma oisu(global_data/0, [
creators([global_data_init/3]),
mutators([global_data_add_new_proc_var/4,
global_data_add_new_proc_layout/4,
...]),
destructors([])
]).
compiler/prog_item.m:
Add a representation for oisu pragmas.
Change the representation of some existing pragmas to represent
type_ctors as a unit.
Give the representation of an existing pragma a less ambiguous name.
compiler/prog_data.m:
Make a type tighter.
compiler/make_hlds_error.m:
Give some predicates that generate error messages the ability
to keep some parts of error messages atomic (i.e. unbreakable
at white space).
compiler/prog_io_pragma.m:
Add code for parsing oisu pragmas.
Treat type_ctors in pragmas as unit, not as a name/arity pair.
compiler/add_pragma.m:
compiler/make_hlds_passes.m:
Make_hlds_passes.m adds items to the HLDS in three passes (this is
due to dependencies between items). Pragmas are handled in passes
2 and 3. One pass used to decide what to do for pragmas in
make_hlds_passes.m, the other pass made that same decision
in add_pragma.m. We now make the decision in add_pragma.m
in BOTH passes. This allows add_pragma.m to export many fewer
predicates, and reduces the coupling between the two modules.
compiler/add_pragma.m:
compiler/prog_data.m:
Move a generally-useful function from add_pragma.m to prog_data.m.
compiler/add_pragma.m:
Add preliminary code for handling oisu pragmas to the HLDS. (Since
the HLDS has not yet been updated to handle oisu pragmas, we don't
yet update the HLDS when we handle oisu pragmas.)
Simplify some code.
compiler/prog_io_util.m:
Rename a predicate to avoid an ambiguity.
compiler/add_clause.m:
compiler/add_pred.m:
compiler/equiv_type.m:
compiler/goal_expr_to_goal.m:
compiler/intermod.m:
compiler/mercury_to_mercury.m:
compiler/module_imports.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/prog_io_mutable.m:
compiler/prog_io_type_defn.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
Conform to the changes above.
algorithmic changes.
compiler/add_pragma.m:
compiler/hlds_code_util.m:
Move some predicates from add_pragma.m to hlds_code_util.m;
they are used not only when adding pragmas.
compiler/prog_io.m:
compiler/prog_mode.m:
Move some predicates from prog_io.m to prog_mode.m;
they do not do parsing.
compiler/add_clause.m:
compiler/prog_io_pragma.m:
Conform to the changes above.
compiler/hlds.m:
Fix typos.
Estimated hours taken: 12
Branches: main
This diff changes data representations, but has no significant changes
in algorithms.
This diff is performance neutral; the difference in performance it makes
is in the noise. This is not surprising. Since the compiler does not spend
much time handling pragmas, how we handle them does not affect speed much.
compiler/prog_item.m:
Change the representation of items representing pragmas.
The first change is providing a bunch of types that each store
all the information needed for one or more kinds of pragma.
This allows the information about a pragma to be passed around
and manipulated as an entity of its own. This is the main
reason for the change; I want to add a new pragma type,
and I want new pragma types to be easy to add.
The second change is factoring out some commonalities in these types,
specifically, the various different ways of specifying predicates
and procedures.
compiler/hlds_module.m:
Take advantage of the first change above to make a data type
tighter.
compiler/add_pragma.m:
compiler/add_solver.m:
compiler/equiv_type.m:
compiler/exception_analysis.m:
compiler/intermod.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/module_imports.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/prog_io.m:
compiler/prog_io_pragma.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
compiler/structure_reuse.analysis.m:
compiler/structure_sharing.analysis.m:
compiler/tabling_analysis.m:
compiler/term_info.m:
compiler/termination.m:
compiler/trailing_analysis.m:
compiler/unused_args.m:
Conform to the changes above.
I've found the cause of a long standing race condition in the parallel
runtime system. The fix is to properly design the engine state and
notification system in the parallel runtime system. I've worked on a design
and committed a description. I've started implementing the changes but found
a new different race condition. I don't currently have the time to complete
this change, therefore I will commit the documentation of the current
problem and proposed solution.
runtime/mercury_context.c:
As above, document the current race.
Also comment on a bug where an idle engine could be notified of a
context to execute. This notification could be dropped in some
situations causing the context to be lost.
runtime/notes/par_engine_state.txt:
runtime/notes/par_engine_state.dot:
As above, document the proposed new engine state and notification
design.
I've found the cause of a long standing race condition in the parallel
runtime system. The fix is to properly design the engine state and
notification system in the parallel runtime system. I've worked on a design
and committed a description. I've started implementing the changes but found
a new different race condition. I don't currently have the time to complete
this change, therefore I will commit the documentation of the current
problem and proposed solution.
runtime/mercury_context.c:
As above, document the current race.
Also comment on a bug where an idle engine could be notified of a
context to execute. This notification could be dropped in some
situations causing the context to be lost.
runtime/notes/par_engine_state.txt:
runtime/notes/par_engine_state.dot:
As above, document the proposed new engine state and notification
design.
Branches: main, release
library/string.m:
Replace `uo' argument modes with `out' in string.split
as the output arguments may share storage with an `in' argument.
Conform to the change: string.split_by_codepoint,
string.left, string.left_by_codepoint,
string.right, string.right_by_codepoint.
Branches: main
Prepare for the creation of the 12.08 branch.
HISTORY:
NEWS:
Shift the 11.07* news into the HISTORY file.
RELEASE_NOTES:
Bump the release number.
When I fixed this comment last night I didn't read the code it was next to.
This caused me to document a different loop and race condition elsewhere in
the runtime system. This change replaces the comment with one that makes
sense in this location.
runtime/mercury_context.c:
As above.
Branches: main
Allow the last-call-modulo-cons optimisation to move goals in a conjunction
following after a recursive call to before the call, if that would make the
LCMC transform possible. Currently, only construction unifications and
from_ground_term goals are moved.
compiler/lco.m:
As above.
tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
tests/hard_coded/lco_reorder.exp:
tests/hard_coded/lco_reorder.m:
Add test case.