[m-users.] Automatic GC selection for grades

Julien Fischer jfischer at opturion.com
Fri Mar 6 15:31:08 AEDT 2020


Hi Adrian,

On Fri, 6 Mar 2020, Adrian Ho wrote:

> I'm currently updating the Homebrew (macOS) formula for Mercury, and was
> puzzled when I tested the Java grade as documented in README.Java, but
> got this error:
>
> $ cd samples
> $ mmc --make --java hello
> mercury_compile:
> Use of Boehm GC is incompatible with target language Java.
>
> It took a while to realize that I had to do:
>
> $ mmc --make --java --gc automatic hello
>
> instead. However, the mmc help text:
>
>         --gc {none, boehm, hgc, accurate, automatic}
>         --garbage-collection {none, boehm, hgc, accurate, automatic}
>                                         (`java', `csharp', and `erlang'
>                                                 grades use `--gc automatic',
>                                         `.gc' grades use `--gc boehm',
>                                         `.hgc' grades use `--gc hgc',
>                                         other grades use `--gc none'.)
>                 Specify which method of garbage collection to use
>                 (default: boehm).
>                 `boehm' is Hans Boehm et al's conservative collector.
>                 `hgc' is our own conservative collector;
>                 `accurate' is our own type-accurate copying GC;
>                 it requires `--high-level-code'.
>                 `automatic' means the target language provides it.
>                 This is the case for the C#, Java and Erlang back-ends,
>                 which always use the garbage collector of the underlying
>                 implementation.
>
> suggests that there's only one reasonable GC method for most grades, so
> why is the default a fixed "boehm", instead of the choice appropriate to
> the requested grade?

The --java option is not a request for the Java grade, it just tells the
compiler to use Java as its target language.  (As you have seen, other
compilation model options also need to be set appropriately for it to
work.)

You should build programs in the Java grade by using:

      $ mmc --grade java --make hello

The --grade option will set all the appropriate compilation model
options for you.  (The fact that README.Java doesn't say to do that
is an error, which will fix shortly.)

Julien.


More information about the users mailing list