mmc fails silently if specified grade is not available; should print error
Closed this issue · 8 comments
For example,
mmc --debug ...
outputs nothing (files or in the terminal) if a debug grade is not available that matches other options. I assume it is computing a grade by adding.debug
to the default grade, or something similar.
This also fails silently because asm_fast.gc.decldebug
is not available, only asm_fast.gc.decldebug.stseg
is:
mmc -s asm_fast.gc.decldebug ...
Failing is correct, but an error message would really help, preferably showing the computed grade it is is attempting to use. Because there was no error message I thought I had a bad install or a system problem of some kind.
Thank you for Mercury, I'm have a good time learning!
You are correct, compilation model options like --debug
are additive and just add to whatever the selected grade is.
If you haven't selected a grade, then the default grade will be used -- the default grade is selected by the autoconfiguration script when Mercury is installed.
If you build programs using the --make
option, then you will get an error when a required grade is not installed.
$ mmc -s asm_fast.par.gc hello
should will print:
mercury_compile: error: the Mercury standard library cannot be found in grade
`asm_fast.par.gc'.
on a system where the grade asm_fast.par.gc
is not installed. (I don't remember why we
don't support that error message for single file compilations, possibly it's just an oversight.)
If you want to see the computed grade a particular set of options will result in, use the --output-grade-string
option.
@juliensf Thank you, I tried --make
and I do get the expected error. So the scope of the problem is limited to single file builds.
Did you mean to put --make
in your mmc command above? I don't see it.
Yes, thank you, I had found --output-grade-string
while trying to debug the problem.
More info from chloekek on IRC:
jumpnbrownweasel: I encountered a similar issue recently. The reason it failed silently was because it segfaulted.
@jumpnbrownweasel, yes I meant to put --make
in my command line.
This is a regression introduced in 22.01. Mercury 20.06 did produce an error about an error about a missing standard library grade when compiling single files. We will look into it.
I originally suspected commit 3fb275c,
from 12 oct 2020, when I replaced a single giant predicate with many smaller ones.
When I try "mdb lmc73 -s asm_fast.par.gc hello" where lmc73 is a compiler in a debug-grade
workspace, maybe_check_libraries_are_installed is called, but it does nothing, because
libgrade_install_check being set to "no" tells it to do nothing. The value of that option is set
only in one place: handle_directory_options in handle_options.m. That predicate has two pieces of logic
that can update that option. The first correctly leaves the option with its default value
of "yes" due to the op_mode being opmcg_target_object_and_executable, but the second
then overwrites this with "no" because mercury_standard_library_directory is not set.
That option can only ever be set by the mercury_standard_library_directory_special
option being given on the command line. I believe (though I am not sure) that this is
supposed to come from the Mercury.config file in the compiler installation, which is why
it is not a surprise that it is not set for a non-installed compiler in a workspace.
That code does seem to work after all, though it is inelegant. (It should have exactly one place
that always sets the value of the libgrade_install_check option, so that each separate execution
path must explicitly set the value the variable we pass to that call.)
The bug is actually in my commit 0f0e535 from jan 2022.
The bug is that when maybe_check_libraries_are_installed returns an error spec, this error spec
was not added to the list of error_specs to print. (It was used in a decision, which is why we
got no singleton warning.) I just committed a fix for this.
That commit has another issue as well, which I am addressing separately.
Thanks Zoltan. The code near the point you made the fix has a comment that says the following:
We also used to do this check, as we are we doing now,
only when InvokedByMake = no. I, zs, don't know why, though
I guess that it may be that the compiler invocation that set
--invoked-by-mmc-make may have done it already.
You guess is correct, mmc --make
does the call library grade check itself. The library
grade check that the comment refers to was only ever intended for the non --make
case.
Fix available in rotd-2023-03-11 and 20.06.6-beta-2023-03-11.