<div dir="ltr"><div>For post-commit review by anyone.</div><div><br></div><div>I have attached a copy of the update README, since that will be simpler to review.<br></div><div><br></div><div>----------------------------------<br></div><div><br></div><div>Rewrite and update the MSVC README.<br></div><div><br></div><div>The main changes are:<br><br>- Clarify what versions of MSVC are supported.<br>- Add a section about how to use the Mercury/MSVC compiler in the MSYS2 or<br>  Cygwin shells.<br>- Add a section about how to use the Mercury/MSVC compiler in the Windows<br>  Command Prompt.<br>- Delete the section on post-installation configuration. Those instructions are<br>  no longer necessary.<br>- Update the list of limitations.<br>- Reorganise the document and many minor rewrites.<br><br>Documentation/<a href="http://README.MS-VisualC.md">README.MS-VisualC.md</a>:<br>    As above.<br><br>NEWS.md:<br>    Clarify what version of MSVC is supported.<br><br>Julien.<br><br>diff --git a/Documentation/<a href="http://README.MS-VisualC.md">README.MS-VisualC.md</a> b/Documentation/<a href="http://README.MS-VisualC.md">README.MS-VisualC.md</a><br>index 864c75581..e146ebc29 100644<br>--- a/Documentation/<a href="http://README.MS-VisualC.md">README.MS-VisualC.md</a><br>+++ b/Documentation/<a href="http://README.MS-VisualC.md">README.MS-VisualC.md</a><br>@@ -1,206 +1,221 @@<br> Mercury with Microsoft Visual C++<br> =================================<br> <br>-This file documents the port of Mercury to Windows using Microsoft Visual<br>-C++ (MSVC) as a C compiler. Version 19.0 or later of MSVC is required.<br>-Version 19 shipped with Visual Studio 2022. Mercury is *not* supported<br>-with older versions of MSVC.<br>+This file documents the port of Mercury to Windows that uses Microsoft Visual<br>+C++ (MSVC) as a C compiler.<br> <br> With MSVC, you can install a Mercury compiler that generates either x86<br> (32-bit) or x64 (64-bit) Windows native code in C grades, but not both.<br> (You can, of course, have multiple Mercury installations that use MSVC,<br> and have one that targets x86 and another that targets x64.)<br> <br>-Setting up the build environment<br>---------------------------------<br>+Contents<br>+--------<br> <br>-A Unix-like environment is required for building and installing Mercury.<br>-[Cygwin](<a href="https://www.cygwin.com">https://www.cygwin.com</a>) or [MSYS2](<a href="https://www.msys2.org">https://www.msys2.org</a>) will<br>-suffice.<br>+* Supported MSVC versions<br>+* Setting up the build environment<br>+* Configuration and installation<br>+* Using Mercury in the MSYS2 or Cygwin shells<br>+* Limitations<br> <br>-A Unix-like environment is *not* required in order to use Mercury once it<br>-has been installed.<br>+Supported MSVC versions<br>+-----------------------<br> <br>-To make MSVC and its supporting tools available under the Cygwin or MSYS2<br>-shells do the following:<br>+You need version 19.3 or later of MSVC. Version 19.3 was included with<br>+Visual Studio 2022. Mercury is *not* supported with older versions of MSVC.<br>+Your Visual Studio installation needs the "Desktop development with C++"<br>+component to be installed.<br> <br>-1. Open the Visual Studio Command Prompt.<br>+Setting up the build environment<br>+--------------------------------<br> <br>-   This can typically be found in<br>+You need a Unix-like environment to build and install Mercury.<br>+You can use either [Cygwin](<a href="https://www.cygwin.com">https://www.cygwin.com</a>) or<br>+[MSYS2](<a href="https://www.msys2.org">https://www.msys2.org</a>).<br> <br>-         Start -> Visual Studio YYYY -> Visual Studio Tools<br>+You only need a Unix-like environment for the installation. You do not need<br>+one to run Mercury later.<br> <br>-   although the name and location vary between different versions and editions<br>-   of Visual Studio. (*YYYY* is the year.) Note that this will give you the<br>-   x86 version of MSVC.<br>+To make MSVC the toolchain available in the Cygwin or MSYS2 shells, do the<br>+following:<br> <br>-   The Visual Studio entry in the `Start` menu may also have items named<br>-   similarly to:<br>+1. Open the Visual Studio Command Prompt.<br> <br>-        * x64 Native Tools Command Prompt for VS 2022<br>-        * x86 Native Tools Command Prompt for VS 2022<br>+   Go to the correct tool in your Start Menu:<br> <br>-   These let you choose between the x64 and x86 versions of MSVC toolchain.<br>+       Start Menu<br>+       └── Visual Studio 2022<br>+           └── Visual Studio Tools<br>+               ├── x64 Native Tools Command Prompt for VS 2022<br>+               └── x86 Native Tools Command Prompt for VS 2022<br> <br>-   Alternatively, you can start a `cmd.exe` session and use the batch files supplied<br>-   with Visual Studio (e.g. `vcvarsall.bat`, `vcvars32.bat` or `vcvars64.bat`) to<br>-   set up the environment for MSVC.<br>+   Select x64 to target 64-bit Windows or x86 to target 32-bit Windows.<br> <br>-2. Enter the following command to start MSYS2 shell with 32-bit MSVC:<br>+   If you prefer not to use the Start Menu shortcuts, then you can manually set<br>+   up the environment variables by running one of the batch files supplied with<br>+   Visual Studio (e.g. `vcvars32.bat` for x86, `vcvars64.bat` for x64).<br> <br>-        C:\> C:\msys64\msys2_shell.cmd -use-full-path -mingw32<br>+2. Start the MSYS2 shell using this command:<br> <br>-   or this one to start the MSYS2 shell with 64-bit MSVC:<br>-        <br>-        C:\> C:\msys64\msys2_shell.cmd -use-full-path -mingw64<br>+       C:\> C:\msys64\msys2_shell.cmd -use-full-path<br> <br>-   or this one to start the Cygwin shell:<br>+   Or start the Cygwin shell using this command:<br> <br>-        C:\> C:\cygwin64\Cygwin.bat<br>+       C:\> C:\cygwin64\Cygwin.bat<br> <br>-(We assume the default installation locations for MSYS2 and Cygwin above.)<br>+   We assume the default installation locations for MSYS2 and Cygwin above.<br> <br>-Users of MSYS2 should note that it is required that the configuration type<br>-returned by autoconf match `*mingw*`; in particular it must *not* match<br>-`*-pc-msys`. You can use the `config.guess` script to see what configuration<br>-type autoconf detects.<br>+   To install the `csharp` grade, you must add a C# compiler to your Windows<br>+   `PATH`. See [<a href="http://README.CSharp.md">README.CSharp.md</a>](<a href="http://README.CSharp.md">README.CSharp.md</a>) for further details.<br> <br>-To install the C# or Java grades, you will need a C# or Java compiler<br>-respectively to be included in the Windows `PATH`.<br>-(See the relevant README files for further details, e.g.<br>-[<a href="http://README.Java.md">README.Java.md</a>](<a href="http://README.Java.md">README.Java.md</a>) etc)<br>+   To install the `java` grade, you must add a Java compiler to your Windows<br>+   `PATH`. See [<a href="http://README.Java.md">README.Java.md</a>](<a href="http://README.Java.md">README.Java.md</a>) for further details.<br> <br>-Configuration and Installation<br>+Configuration and installation<br> ------------------------------<br> <br>-The MSVC port of Mercury is compatible with the prebuilt C files contained in<br>-the Mercury source distribution. The `asm_fast*` and `reg*` grades will not work<br>-with MSVC (see below). When using the prebuilt C files the compiler will be<br>-built in the `hlc.gc.pregen` grade.<br>+You can install the MSVC port of Mercury directly from the Mercury source<br>+distribution.<br>+<br>+If you already have an existing Mercury installation that uses the<br>+[MinGW-w64](<a href="https://www.mingw-w64.org">https://www.mingw-w64.org</a>) ports of GCC or Clang, or one that uses<br>+the Cygwin port of GCC, then you can clone the Mercury source from the Git<br>+repository and use your existing installation to cross-compile the MSVC port.<br> <br>-Alternatively, if you have an existing Mercury installation that uses the<br>-MinGW-w64 or Cygwin GCC ports, or clang, then you can checkout the Mercury<br>-source from the git repository and use your existing installation to<br>-cross-compile the MSVC port.<br>+When using MSVC, you *must* set the Mercury installation directory using the<br>+`--prefix` option to `configure`. <br> <br>-In either case, to use MSVC as the C compiler with Mercury, invoke `configure`<br>-as follows:<br>+* Use a full Windows path with a drive letter (e.g., `C:/mercury`).<br> <br>-    ./configure --with-cc=cl [<any other options>]<br>+* **Important**: Use forward slashes (`/`), not backslashes (`\`) as path<br>+  separators (even though the latter is more usual on Windows).<br> <br>-On Cygwin, `configure` and `mmake` will do translation of Unix style paths, so<br>-you may specify the installation directory using either a Unix- or<br>-Windows-style path. On MSYS2, you must use a full Windows-style path with a<br>-drive letter, except that you must use `/` instead of `\` as a directory<br>-separator. For example, this is acceptable:<br>+For example, this is acceptable:<br> <br>     ./configure --prefix="c:/where/to/install/mercury"<br> <br> but this is not:<br>-<br>+    <br>     ./configure --prefix="c:\where\to\install\mercury"<br> <br>-Once `configure` has successfully finished, then do<br>+You *must* set the installation directory correctly, or the installation will<br>+fail.<br>+<br>+Run `configure` as follows:<br>+<br>+    ./configure --with-cc=cl --prefix=<install-dir> [<any other options>]<br>+<br>+Once `configure` has successfully finished, then do:<br> <br>     make<br> <br>-and then<br>+and then:<br> <br>     make install<br> <br> as normal.<br> <br>-Limitations<br>------------<br>+Using Mercury in the MSYS2 or Cygwin shells<br>+-------------------------------------------<br> <br>-The MSVC port currently has a number of limitations:<br>+This section describes how to use a Mercury compiler that was built using MSVC<br>+in the MSYS2 or Cygwin shells.<br> <br>-* The `asm_fast` and `reg` grades do not work with MSVC.<br>-  Both use GNU extensions to C that MSVC does not provide.<br>+Check that the MSVC toolchain is in the Windows `PATH` and that the required<br>+tools (`cl`, `link` and `lib`) are accessible from the Cygwin or MSYS2 shell.<br> <br>-* Time profiling does not (currently) work with MSVC.<br>-  Time profiling grades (those whose name contains the `prof` grade component)<br>-  will not be installed.<br>+Add the Mercury `bin` directory to the MSYS2 or Cygwin `PATH` using a<br>+Unix-style path. For example, if Mercury is installed in "C:\mercury", then you<br>+would add `/c/mercury/bin` to the MSYS2 `PATH` or `/cygdrive/c/mercury/bin` to<br>+the Cygwin `PATH`.<br> <br>-  Note that memory profiling _does_ work with MSVC. (Memory profiling grades<br>-  are those whose name contains the `memprof` grade component.)<br>+After the Mercury `bin` directory has been added to the MSYS2 or Cygwin `PATH`,<br>+then you should be able to use the Mercury compiler.<br> <br>-* Parallel grades (those whose name contains the `par` component) do not<br>-  currently work with MSVC.<br>+Using Mercury in the Windows Command Prompt<br>+-------------------------------------------<br> <br>-  In parallel grades the Mercury runtime currently requires the use of POSIX<br>-  threads; it has not currently been ported to use Windows threads.<br>-  (It might be possible to use the [pthreads-win32](<a href="https://sourceforge.net/projects/pthreads4w/">https://sourceforge.net/projects/pthreads4w/</a>)<br>-  library with MSVC to provide POSIX threads but we have not tested that yet.) <br>+This section explains how to use Mercury that was built using MSVC in the<br>+Windows Command Prompt (i.e. `cmd.exe`).<br> <br>-* Deep profiling (e.g. the `*.profdeep` grades) does not (currently) work<br>-  with MSVC. (In principle, it should work if the clock tick metric is<br>-  disabled.)<br>+Make sure that the following are present in the Windows `PATH`:<br> <br>-* The deep profiling tool (`mdprof_cgi`) does not currently work with MSVC.<br>-  This is due to it containing a number of Unix dependencies. (Other<br>-  tools that work with deep profiles should be fine.)<br>+1. The MSVC toolchain (`cl`, `link` and `lib`).<br> <br>-* When used directly from the Windows command prompt, mmake will not work.<br>-  You should use `mmc --make` instead. (`mmake` requires a POSIX-like shell<br>-  and GNU `make`; it will however work with the Cygwin or MSYS2 shells.)<br>-  We do not intend to support `mmake` directly on Windows.<br>+2. The Java toolchain (`javac`, `jar` and `java`), if the `java` grade was<br>+   installed.<br> <br>-* Creation of shared libraries (DLLs) is not currently supported.<br>+3. The C# toolchain (`csc`), if the `csharp` grade was installed.<br> <br>-* The `--c-debug` option currently has no effect with MSVC since enabling<br>-  it breaks parallel builds and disables some C compiler optimizations.<br>+4. The Mercury `bin` directory. For example, if Mercury is installed in<br>+   `C:\mercury`, then you would add `C:\mercury\bin` to the Windows `PATH`.<br> <br>-  If you *really* want to enable support for C level debugging, then enable the<br>-  commented out definition of `DEBUG_OPTS` in `scripts/<a href="http://mgnuc.in">mgnuc.in</a>` (in the `cl` case)<br>-  and also enable the commented out definition of `CFLAGS_FOR_DEBUG` in<br>-  `<a href="http://configure.ac">configure.ac</a>` (in the `msvc*` case). You will then need to regenerate<br>-  the `configure` script and rebuild the Mercury system.<br>-  (See [INSTALL.git](../INSTALL.git) for details of how to do this.)<br>+You can then run the Mercury compiler using the command `mercury`.<br>+This is a batch file that is the same as `mmc` in other environments.<br>+We use the name `mercury` instead of `mmc` in the Windows Command Prompt.<br>+This is because the name `mmc` is also used by the Microsoft Management<br>+Console.<br> <br>-Post-installation configuration<br>--------------------------------<br>+For example, to build the "Hello, World" example in the `samples` directory<br>+of the Mercury distribution, do:<br> <br>-The above instructions create a Mercury installation using MSVC that works<br>-from within the Cygwin or MSYS2 shells. If you want to be able to run the<br>-Mercury compiler directly from the Windows Command Prompt (e.g. `cmd.exe`)<br>-or PowerShell, then you need to manually edit some configuration files in the<br>-installation. (In future releases, this will all hopefully be automated.)<br>+    mercury hello.m<br> <br>-All references to files in the following are within the Mercury installation<br>-directory<br>+or, using the `--make` option:<br> <br>-* In the file `lib/mercury/conf/Mercury.config`:<br>-  <br>-  + Replace any Unix-style paths with their Windows-style equivalent. <br>+    mercury --make hello<br> <br>-* In the file `lib/mercury/mdb/mdbrc`<br>+Note that `mmake` is not supported in the Windows Command Prompt.<br>+<br>+Limitations<br>+-----------<br> <br>-  + The backslash character, `\`, is used as an escape character in mdbrc<br>-    files. It must be escaped it if it occurs in any paths used in the<br>-    argument of `source` commands, for example<br>+The MSVC port currently has the following limitations:<br> <br>-        source c:\mercury-11.07\lib\mercury\mdb\mdb_doc<br>+* The `asm_fast` and `reg` grades do not work.<br>+  Both use GNU extensions to C that MSVC does not provide.<br> <br>-    needs to be replaced with:<br>+* Time profiling does not (currently) work with MSVC.<br>+  Time profiling grades (those whose name contains the `.prof` grade component)<br>+  will not be installed.<br> <br>-        source c:\\mercury-11.07\\lib\\mercury\\mdb\\mdb_doc<br>+  Memory profiling _does_ work with MSVC. (Memory profiling grades<br>+  are those whose name contains the `.memprof` grade component.)<br> <br>-  + Delete the aliases for the `open` and `grep` commands.<br>-    The scripts that implement these commands assume a Unix-style environment.<br>+* Parallel grades do not work because the Mercury runtime uses POSIX threads.<br>+  It does not yet support Windows threads.<br>+  <br>+  (It might be possible to use the<br>+  [pthreads-win32](<a href="https://sourceforge.net/projects/pthreads4w/">https://sourceforge.net/projects/pthreads4w/</a>)<br>+  library with MSVC to provide POSIX threads, but we have not yet tested that.) <br> <br>-* The `bin` directory contains batch files equivalent to the `mmc`, `mdb` and<br>-  `mprof` scripts. Note that the batch file equivalent to the `mmc` script is<br>-   named `mercury.bat` in order to avoid clashing with the executable for the<br>-   Microsoft Management Console.<br>+* Deep profiling (e.g. the `.profdeep` grades) does not (currently) work<br>+  with MSVC. (In principle, it should work if the clock tick metric is<br>+  disabled.)<br>+<br>+* The deep profiling tool (`mdprof_cgi`) does not currently work with MSVC.<br>+  This is due to it containing Unix dependencies. (Other tools that work with<br>+  deep profiles should be fine.)<br>+<br>+* You cannot create libraries (DLLs) yet.<br>+<br>+* The `--c-debug` option is disabled with MSVC since enabling it breaks<br>+  parallel builds and disables some C compiler optimizations.<br>+<br>+  If you *really* want to enable support for C level debugging, then enable the<br>+  commented out definition of `DEBUG_OPTS` in `scripts/<a href="http://mgnuc.in">mgnuc.in</a>`<br>+  (for the `cl` case) and also enable the commented out definition of<br>+  `CFLAGS_FOR_DEBUG` in `<a href="http://configure.ac">configure.ac</a>` (for the `msvc` case). You will then need<br>+  to regenerate the `configure` script and rebuild the Mercury system.<br>+  (See [INSTALL.git](../INSTALL.git) for details of how to do this.)<br> <br>-* The following scripts do not currently have a Windows equivalent.<br>+* `mdb`'s `open` and `grep` commands do not work. The scripts that implement<br>+  these commands only work on Unix-like systems.<br> <br>-    + `mprof_merge_runs`<br>-    + `mtc`<br>+* The following shell scripts included with the Mercury distribution do not<br>+  work on Windows.<br> <br>-* The other shell scripts in the `bin` directory do not have (or need) Windows<br>-  equivalents. (Most of them are part of the implementation of `mmake` which<br>-  in the Windows Command Prompt or PowerShell.)<br>+  - `mprof_merge_runs`<br>+  - `mtc`<br> <br> -----------------------------------------------------------------------------<br>diff --git a/NEWS.md b/NEWS.md<br>index e0b8531d8..5e25f87f3 100644<br>--- a/NEWS.md<br>+++ b/NEWS.md<br>@@ -79,8 +79,8 @@ Changes that may break compatibility<br> <br> * We have dropped support for the x86 (32-bit) version of Cygwin.<br> <br>-* We have dropped support for versions of MSVC before version 19 (Visual Studio<br>-  2022).<br>+* We have dropped support for versions of MSVC before version 19.3<br>+  (Visual Studio 2022).<br> <br> * The `--use-subdirs` and `--use-grade-subdirs` options now cause `.mh` files<br>   to be placed in a `Mercury/mhs` subdirectory instead of the current<br></div><br></div>