[m-rev.] diff: support bootchecking in the MSYS2 MSYS environment

Julien Fischer jfischer at opturion.com
Sun Jan 4 02:58:38 AEDT 2026


Support bootchecking in the MSYS2 MSYS environment.

MSYS2's MSYS environment is similar to Cygwin and shares a lot of its
underlying code. Executables in this environment are linked with
msys-2.0.dll, which is a POSIX-emulation layer similar to cygwin1.dll.
The change of configuration triple for this environment last year from
x86_64-pc-msys to x86_64-pc-cygwin means that we can trivially support
Mercury in it by virtue of the fact that we already support Cygwin.

This diff makes some changes required to allow Mercury to bootcheck in
the MSYS2 MSYS environment.

configure.ac:
    Modify the error message we print if we detect *-pc-msys
    architecture.

tools/bootcheck:
    Do not abort if we detect the MSYS2 MSYS environment.

    Extend the comment describing the handling of the different MSYS2
    environment.

    Give a variable a more accurate name.

Julien.

diff --git a/configure.ac b/configure.ac
index 7330133ac..35b82c52e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
 # vim: ts=4 sw=4 expandtab ft=sh
 #-----------------------------------------------------------------------------#
 # Copyright (C) 1995-2012 The University of Melbourne.
-# Copyright (C) 2013-2025 The Mercury team.
+# Copyright (C) 2013-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.
 #-----------------------------------------------------------------------------#
@@ -285,14 +285,15 @@ fi

 #-----------------------------------------------------------------------------#

-# Ensure that the user does not try to build MSYS executables; we do not
-# (currently) support that.
+# Check that we are not using an older version of the MSYS2 MSYS environment
+# where the configuration triple is *-pc-msys. Those do not work. Versions
+# that return the configuration triple as *-pc-cygwin *do* work.

 case "$host" in *-pc-msys)
     AC_MSG_ERROR(
 [
 ***** The $host architecture is not supported.
-***** You probably meant to use one of: x86_64-pc-mingw32, x86_64-pc-mingw64.])
+***** You will need to update to a more recent version of MSYS2.])
     ;;
 esac

diff --git a/tools/bootcheck b/tools/bootcheck
index 3c78b8177..da7615c39 100755
--- a/tools/bootcheck
+++ b/tools/bootcheck
@@ -2,7 +2,7 @@
 # vim: ts=4 sw=4 et ft=sh
 #---------------------------------------------------------------------------#
 # Copyright (C) 1995-2008, 2010-2011 The University of Melbourne.
-# Copyright (C) 2013-2025 The Mercury team.
+# Copyright (C) 2013-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.
 #---------------------------------------------------------------------------#
@@ -613,7 +613,7 @@ fi
 # libraries or executables must be built using a single invocation of
 # mmc --make. Multiple invocation of mmc --make in the same directory
 # will conflict with each other.
-# XXX This should not prevent us from using paralelism *within* a single
+# XXX This should not prevent us from using parallelism *within* a single
 # invocations of mmc --make.
 #
 # Directories containing target code only, such as the runtime and trace
@@ -656,27 +656,42 @@ SED=${SED:-sed}

 #-----------------------------------------------------------------------------#

-# Work out if we are running in one of the MSYS2 environments on Windows.
-# On these systems some tools, e.g. the shell and make, use POSIX style paths
-# overlaid on Windows file system, but the Mercury compiler uses Windows style
-# paths. There is some automatic translation done between the two, but we need
-# to ensure that paths put in .options or _FLAGS files are in the appropriate
-# format. For the MSYS2 environment, we also need to set some things up (e.g.
-# options to diff) for the test suite to work properly.
+# Are we in one of the MSYS2 environments on Windows? If so, the work out which
+# one and set up any necessary path translation and diff options. We are
+# concerned with two classes of MSYS2 environment:
+#
+# 1. MSYS. This environment is similar to Cygwin. Executables are linked
+# against msys-2.0.dll, which is a POSIX emulation layer. In this environment
+# we can use Unix-style paths and LF line endings.
+#
+# 2. Environments that create native Windows executables (e.g MING64, UCRT64).
+# In these environments, the shell and tools like make will use POSIX-style
+# paths (overlaid on the Windows file system), but the Mercury compiler will
+# use Windows-style paths. There is some automatic translation done between the
+# two, but we need to ensure that paths put in .options or _FLAGS files are in
+# the appropriate format. We also need to set some things for the test suite
+# to work properly (e.g. tell diff to ignore differences due the presence of
+# CRLF line endings).
+
 case "${MSYSTEM}" in

     MINGW64|MINGW32|UCRT64|CLANG64)
-        env_is_msys2=true
+        env_is_msys2_native=true
+        windows=true
+        ;;
+
+    MSYS)
+        env_is_msys2_native=false
         windows=true
         ;;

-    CLANGARM64|MSYS)
+    CLANGARM64)
         echo "bootchecking using MSYS2 environment ${MSYSTEM} is not
supported."
         exit 1
         ;;

     *)
-        env_is_msys2=false
+        env_is_msys2_native=false
         ;;
 esac

@@ -2146,7 +2161,7 @@ then
         stage2_insert=""
     fi

-    if "$env_is_msys2"
+    if "$env_is_msys2_native"
     then
         WORKSPACE=$($CYGPATH "${root}${stage2_insert}")
     else
@@ -2172,7 +2187,7 @@ then
     export DIFF_OPTS
 fi

-if "$env_is_msys2"
+if "$env_is_msys2_native"
 then
     DIFF_OPTS="${DIFF_OPTS:-} -u --strip-trailing-cr"
     export DIFF_OPTS


More information about the reviews mailing list