[m-rev.] for post-commit review: carve create_launchers.m out of module_cmds.m
Julien Fischer
jfischer at opturion.com
Sat Jul 4 14:34:02 AEST 2026
On Thu, 2 Jul 2026 at 05:22, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
>
> There no changes in logic, just moving code, giving some
> predicates new names, and the addition of new comments.
> The main thing I would like feedback about is the top-of-module
> comment in the new module.
> Carve create_launchers.m out of module_cmds.m.
>
> compiler/create_launchers.m:
> compiler/module_cmds.m:
> As above. This improves the cohesion of both modules.
>
> Give some predicates more descriptive names. Document the reason
> for the differences between what the new module does for Java vs
> what it does for C#.
>
> compiler/backend_libs.m:
> compiler/notes/compiler_design.html:
> Add and document the new moduile.
>
> compiler/mercury_compile_main.m:
> Document a problem.
>
> compiler/link_target_code.m:
> compiler/write_deps_file.m:
> Conform to the changes above.
...
> diff --git a/compiler/create_launchers.m b/compiler/create_launchers.m
> new file mode 100644
> index 000000000..9cc16b7b4
> --- /dev/null
> +++ b/compiler/create_launchers.m
> @@ -0,0 +1,336 @@
> +%---------------------------------------------------------------------------%
> +% vim: ft=mercury ts=4 sw=4 et
> +%---------------------------------------------------------------------------%
> +% Copyright (C) 2026 The Mercury team.
> +% This file may only be copied under the terms of the GNU General
> +% Public License - see the file COPYING in the Mercury distribution.
> +%---------------------------------------------------------------------------%
> +%
> +% File: create_launchers.m.
> +%
> +% This module creates launcher scripts that play the role of executables
> +% for the Java backend, and does the last step of creating such executables
> +% for the C# backend.
> +%
> +% The difference is that the C# backend is much newer. We export
> +% create_java_shell_script to two modules beyond its main user,
> +% link_target_code.m:
> +%
> +% - write_deps_file.m, to allow the creation of java launchers for a program
> +% when we create its .dep file for Mmake, and
> +%
> +% - to mercury_compile_main.m, to allow it to create the launcher as part of
> +% the opfam_target_object_and_executable op_mode.
> +%
> +% The C# backend was designed NOT to support Mmake, and mercury_compile_main.m
> +% flat out IGNORES the job of create launcher scripts for that op_mode when
> +% targeting C#.
> +%
> +% This is why the C# equivalent of create_java_shell_script is local to
> +% link_target_code.m. If and when we ever fix the IGNORE above (if that fix
> +% is even possible, without the initial setup from mmc --make), it would
> +% have to start with moving that code here.
Actually, the current Java backend does not support Mmake either. There is
residual code for it (some of which dates back to my summer studentship),
but it has never worked.
Getting rid of it is non-trival, as it means working out what *is* required for
mmake --use-mmc-make to work and what is not. A reasonable heuristic would be
to delete any Java support in mmake where there isn't a C# equivalent present.
The other major difference between the C# and Java backends is that the launcher
script is only required when the .NET implementation is Mono. With .NET on
Windows, you can just run the executable assembly directly.
Julien.
More information about the reviews
mailing list