[m-rev.] for review: keep the invocation automatically up-to-date

Peter Wang novalazy at gmail.com
Wed Jul 23 15:54:02 AEST 2025


On Wed, 23 Jul 2025 15:04:09 +1000 Julien Fischer <jfischer at opturion.com> wrote:
> On Wed, 23 Jul 2025 at 11:18, Peter Wang <novalazy at gmail.com> wrote:
> >
> > On Sun, 20 Jul 2025 22:44:44 +1000 Julien Fischer <jfischer at opturion.com> wrote:
> > > On Sat, 19 Jul 2025 at 07:43, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
> > > >
> > > > The main issue I am seeking feedback on is that after this diff,
> > > > making the user guide requires compiler/mercury_compile to be
> > > > up to date. The other rules of doc/Mmakefile already depend
> > > > on the contents of the compiler directory, but they do so only for
> > > > .m files, which do not need to be built.
> > >
> > > There is one case where this is a problem, namely building the source
> > > distribution.
> > > In that case mercury_compile will not exist when we build the doc directory.
> > >
> >
> > We also cannot assume that ../compiler/mercury_compile is executable
> > when cross-compiling.
> >
> > I assume the solution is also to invoke the bootstrap compiler
> > when CROSS_COMPILING=yes.
> 
> Presumably, something like this will do?
> 
> diff --git a/doc/Mmakefile b/doc/Mmakefile
> index 8dc9d91f1..5c08915e6 100644
> --- a/doc/Mmakefile
> +++ b/doc/Mmakefile
> @@ -172,6 +172,9 @@ ug_invocation.texi: ug_invocation.texi_date
>  ifdef BUILD_SRCDIST
>  UG_INVOCATION_DEP=
>  UG_INVOCATION_MC=$(MC)
> +else ifdef CROSS_COMPILING
> +UG_INVOCATION_DEP=
> +UG_INVOCATION_MC=$(MC)
>  else
>  # We do not specify the executable extension $(EXT_FOR_EXE) here because we
>  # need a way to refer to the compiler that works regardless of the grade in
> 
> Are you set up to test the above?

I can commit the following. Any thoughts about committing the generated file?

Peter

---

Generate ug_invocation.texi using bootstrap compiler when cross-compiling.

doc/Mmakefile:
    Generate ug_invocation.texi using the bootstrap compiler when
    cross-compiling as we may not be able to run the mercury_compile
    executable.

doc/.gitignore:
    Ignore ug_invocation.texi and ug_invocation.texi_date.

diff --git a/doc/.gitignore b/doc/.gitignore
index c9034d0a6..99e2aa088 100644
--- a/doc/.gitignore
+++ b/doc/.gitignore
@@ -35,3 +35,5 @@ mdb_command_list
 mdb_command_test.inp
 Prof.MemoryCells
 Prof.MemoryWords
+ug_invocation.texi
+ug_invocation.texi_date
diff --git a/doc/Mmakefile b/doc/Mmakefile
index 8dc9d91f1..5854d18a4 100644
--- a/doc/Mmakefile
+++ b/doc/Mmakefile
@@ -165,14 +165,19 @@ user_guide.texi_pp: ug_invocation.texi
 ug_invocation.texi: ug_invocation.texi_date
 	@:
 
-# If we are building the source distribution, then we will not have
-# a mercury_compile executable to generate ug_invocation.texi from.
-# In that case, we just use the bootstrap compiler to generate it
-# since it will be the same version anyway.
+# If we are building the source distribution or if we are cross-compiling,
+# then either we will not have a mercury_compile executable, or we may not be
+# able to run it. In both cases, we just use the bootstrap compiler to generate
+# ug_invocation.texi, assuming the bootstrap compiler is the same or a similar
+# version.
 ifdef BUILD_SRCDIST
 UG_INVOCATION_DEP=
 UG_INVOCATION_MC=$(MC)
 else
+ifeq ($(CROSS_COMPILING),yes)
+UG_INVOCATION_DEP=
+UG_INVOCATION_MC=$(MC)
+else
 # We do not specify the executable extension $(EXT_FOR_EXE) here because we
 # need a way to refer to the compiler that works regardless of the grade in
 # which it is compiled, and on all platforms. The extension that $(EXT_FOR_EXE)
@@ -187,6 +192,7 @@ else
 UG_INVOCATION_DEP=../compiler/mercury_compile
 UG_INVOCATION_MC=../compiler/mercury_compile
 endif
+endif
 
 ug_invocation.texi_date: $(UG_INVOCATION_DEP)
 	@echo checking whether ug_invocation.texi is up to date


More information about the reviews mailing list