[m-rev.] for review: support wildcard argument expansion with MSVC
Zoltan Somogyi
zoltan.somogyi at runbox.com
Tue Jan 6 01:59:21 AEDT 2026
On Tue, 6 Jan 2026 01:04:34 +1100, Julien Fischer <jfischer at opturion.com> wrote:
> scripts/parse_ml_options.sh-subr.in:
> scripts/ml.in:
> Add a new option --use-msvc-setargv-extension, which causes the the
> wsetargv.obj file that enables the extension to be passed the linker.
> (MSVC seems rather picky about where this is positioned. A a result
> we do it within the ml script where we have more control over the matter.)
>
> compiler/Mmakefile:
I am not even a novice when it comes to programming on Windows, but
even so, I see two issues here.
First, this seems to be a solution just for people working in the compiler directory.
It does not help even us, Mercury developers, when working in e.g. the browser
or profiler directories, much less other Mercury users.
Second, it would be much better if we simply recorded the current platform
(including in this case that MSVC was specified as the C compiler) in the ml script
at configure time, and let it take care of all its implications, this new one
being just one of them.
Is there some reason why this wouldn't work? Is there some way of setting
USING_MICROSOFT_CL_COMPILER that works in a makefile but wouldn't
be implementable in a shell script? I know of one, Mercury.options files,
but really, this info does not belong there.
> diff --git a/compiler/Mmakefile b/compiler/Mmakefile
> index 1f706b73f..ce3bfc296 100644
> --- a/compiler/Mmakefile
> +++ b/compiler/Mmakefile
> @@ -2,7 +2,7 @@
> # vim: ts=8 sw=8 noexpandtab ft=make
> #-----------------------------------------------------------------------------#
> # Copyright (C) 1995-2003, 2005-2012 The University of Melbourne.
> -# Copyright (C) 2013-2017, 2019-2020, 2022-2023 The Mercury team.
> +# Copyright (C) 2013-2017, 2019-2020, 2022-2024, 2026 The Mercury team.
> # This file may only be copied under the terms of the GNU General
> # Public Licence - see the file COPYING in the Mercury distribution.
> #-----------------------------------------------------------------------------#
> @@ -46,6 +46,7 @@ VPATH = \
>
> MCFLAGS += --flags COMP_FLAGS $(CONFIG_OVERRIDE)
>
> +# XXX Why does one branch of this set MLLIBS and the other MLOBJS?
> ifeq ("$(filter csharp% java%,$(GRADE))","")
> MLLIBS += $(THREAD_LIBS)
> else
> @@ -65,7 +66,7 @@ JAVACFLAGS += -J\"-Xmx2048m\"
> endif
>
> # The default C stack size of 1Mb on Windows is not enough to bootcheck the
> -# system using a Mercury compiler built in the hlc.gc grade with MinGW64 GCC,
> +# system using a Mercury compiler built in the hlc.gc grade with MinGW-w64 GCC,
> # Cygwin GCC or MinGW64 clang.
> # XXX For MSVC, we currently set the stack size in the ml script.
> ifneq ("$(USING_MICROSOFT_CL_COMPILER)", "yes")
> @@ -77,6 +78,13 @@ LDFLAGS += -Wl,--stack=8388608
> endif
> endif
>
> +# If we are compiling using MSVC, then enable the use of the C runtime library
> +# extension that enables wildcard expansion for command lines. On Windows,
> +# wildcard is expansion is *not* done by the shell.
> +ifeq ("$(USING_MICROSOFT_CL_COMPILER)", "yes")
> +MLFLAGS += --use-msvc-setargv-extension
> +endif
> +
> #-----------------------------------------------------------------------------#
>
> # Targets.
> diff --git a/scripts/ml.in b/scripts/ml.in
> index ab803013b..a4665c216 100644
> --- a/scripts/ml.in
> +++ b/scripts/ml.in
> @@ -559,17 +559,21 @@ case "${MKFIFO}" in
> ;;
> esac
>
> +# Changes to the value of MSVC_SETARGV below, may require changes to
> +# value of the variable main_func in ../util/mkinit.c.
> +MSVC_SETARGV=
> +NOLOGO_OPTS=
> case "${C_COMPILER_TYPE}" in
> msvc*)
> NOLOGO_OPTS="-nologo"
> - ;;
> - *)
> - NOLOGO_OPTS=""
> + case "${use_msvc_setargv_extension}" in
> + true) MSVC_SETARGV="wsetargv.obj" ;;
> + esac
> ;;
> esac
Please document the meaning of this variable.
Zoltan.
More information about the reviews
mailing list