[Mingw-w64-public] [PATCH v3] configure: Use ucrt for msvcrt by default.

2023-06-19 Thread Jacek Caban via Mingw-w64-public

---
 mingw-w64-crt/configure.ac   |  4 +-
 mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt | 58 
 mingw-w64-headers/configure.ac   | 12 ++--
 3 files changed, 66 insertions(+), 8 deletions(-)
 create mode 100644 mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt

diff --git a/mingw-w64-crt/configure.ac b/mingw-w64-crt/configure.ac
index 05f40b261..ced7745ca 100644
--- a/mingw-w64-crt/configure.ac
+++ b/mingw-w64-crt/configure.ac
@@ -267,9 +267,9 @@ AC_MSG_RESULT([$enable_delay_import_libs])
 AC_MSG_CHECKING([what to provide as libmsvcrt.a])
 AC_ARG_WITH([default-msvcrt],
   [AS_HELP_STRING([--with-default-msvcrt=LIB],
-[Lib to provide as libmsvcrt.a (default: msvcrt-os)])],
+[Lib to provide as libmsvcrt.a (default: ucrt)])],
   [],
-  [with_default_msvcrt=msvcrt-os])
+  [with_default_msvcrt=ucrt])
 if test "$with_default_msvcrt" = "msvcrt"; then
   with_default_msvcrt=msvcrt-os
 fi
diff --git a/mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt b/mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt
new file mode 100644
index 0..3cc3329ad
--- /dev/null
+++ b/mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt
@@ -0,0 +1,58 @@
+== Summary ==
+
+Starting from mingw-w64 version 12 and onwards, UCRT (Universal C Runtime) will
+be the default CRT runtime, unless specified otherwise during the minwgw-64
+build process. We believe that this configuration is the best choice for the
+majority of users. While we encourage users to consider switching to UCRT, we
+understand that it may not always be desirable, especially for compatibility
+reasons. Therefore, all previously supported configurations will continue to
+be supported. Users who wish to continue using msvcrt.dll can easily do so by
+adding the --with-default-msvcrt=msvcrt argument to both the
+mingw-w64-headers and mingw-w64-crt configure scripts.
+
+
+== Background ==
+
+mingw-w64 provides C runtime libraries that directly or indirectly utilize
+Microsoft DLLs at runtime. Over the years, Microsoft has released various
+versions of these DLLs, some of which were designed for specific MSVC versions
+while others aimed for backward compatibility. When building the mingw-w64
+toolchain, users can specify a version of the runtime DLL using the
+--with-default-msvcrt= configure option. The most commonly used versions are
+ucrt (utilizing ucrtbase.dll) and msvcrt (utilizing msvcrt.dll).
+
+The implementation of msvcrt.dll dates back to the Windows 9x era. While it has
+been extended for a period, it eventually became frozen in favor of providing
+separate DLLs for future MSVC versions. Although msvcrt.dll continues to be
+shipped with modern Windows versions, it remains compatible with the version
+from the 1990s. msvcrt.dll is known to deviate from standard behavior in many
+aspects. mingw-w64 includes compatibility wrappers and extensions to improve
+standard compatibility, but there are limitations to what can be practically
+achieved.
+
+On the other hand, ucrtbase.dll was introduced with MSVC 14 and is currently
+included with all Windows versions supported by Microsoft. It is also available
+as a redistributable package for older versions of Windows. ucrtbase.dll aims to
+replace MSVC version-specific DLLs and has been used by all MSVC versions since
+its introduction. It offers a more modern approach compared to msvcrt.dll and
+provides better standard compatibility out of the box, reducing overhead on the
+mingw-w64 side.
+
+
+== Compatibility ==
+
+When switching between toolchains that use different runtime libraries, it is
+generally advised not to mix static libraries, unless certain exceptions apply.
+If in doubt, it is recommended to rebuild all static libraries when switching
+the toolchain's runtime DLL.
+
+Dynamic libraries are less likely to be affected. If the CRT is not part of the
+ABI of a library you intend to use, meaning it does not involve passing FILE
+structs or similar types between modules or depending on the CRT allocator of
+other modules, it should remain unaffected. Otherwise, a compatible build of
+that library will be required.
+
+
+== See Also ==
+
+"MSVCRT vs UCRT": https://www.msys2.org/docs/environments/
diff --git a/mingw-w64-headers/configure.ac b/mingw-w64-headers/configure.ac
index d82280cd7..d6809d147 100644
--- a/mingw-w64-headers/configure.ac
+++ b/mingw-w64-headers/configure.ac
@@ -144,9 +144,9 @@ AC_SUBST([DEFAULT_WIN32_WINNT])
 AC_MSG_CHECKING([default msvcrt])
 AC_ARG_WITH([default-msvcrt],
   [AS_HELP_STRING([--with-default-msvcrt=LIB],
-[Default msvcrt to target (default: msvcrt)])],
+[Default msvcrt to target (default: ucrt)])],
   [],
-  [with_default_msvcrt=msvcrt])
+  [with_default_msvcrt=ucrt])
 case $with_default_msvcrt in
 msvcrt10*)
   default_msvcrt_version=0x100
@@ -178,12 +178,12 @@ msvcr110*)
 msvcr120*)
   default_msvcrt_version=0xC00
   ;;
-ucrt*)
-  default_msvcrt_version=0xE00
-  ;;
-msvcrt|*)
+msvcrt*)
   default_msvcrt_version=0x700
   ;;
+ucrt*|*)
+ 

Re: [Mingw-w64-public] [PATCH v2] configure: Use ucrt for msvcrt by default.

2023-06-19 Thread Jacek Caban via Mingw-w64-public

On 6/19/23 14:20, Martin Storsjö wrote:

On Mon, 19 Jun 2023, Jacek Caban via Mingw-w64-public wrote:

v2 includes changes suggested by Martin. It also includes a 
documentation change to clarify the situation.


---
mingw-w64-crt/configure.ac   |  4 +-
mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt | 58 
mingw-w64-headers/configure.ac   | 12 ++--
3 files changed, 66 insertions(+), 8 deletions(-)
create mode 100644 mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt


+be supported. Users who wish to continue using msvcrt.dll can easily 
do so by

+adding the --with-default-msvcrt=msvcrt-os argument to both the
+mingw-w64-headers and mingw-w64-crt configure scripts.


Actually, you can do just --with-default-msvcrt=msvcrt - the 
distinction between msvcrt vs msvcrt-os is handled within 
mingw-w64-crt/configure.ac - so we don't need to expose that detail to 
users in this doc.


Same thing in the paragraph below, we could just name it "msvcrt" there.



Oh, right, that's better. I sent a new version with suggested changes.


Thanks,

Jacek



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH v2] configure: Use ucrt for msvcrt by default.

2023-06-19 Thread Martin Storsjö

On Mon, 19 Jun 2023, Jacek Caban via Mingw-w64-public wrote:

v2 includes changes suggested by Martin. It also includes a documentation 
change to clarify the situation.


---
mingw-w64-crt/configure.ac   |  4 +-
mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt | 58 
mingw-w64-headers/configure.ac   | 12 ++--
3 files changed, 66 insertions(+), 8 deletions(-)
create mode 100644 mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt



+be supported. Users who wish to continue using msvcrt.dll can easily do so by
+adding the --with-default-msvcrt=msvcrt-os argument to both the
+mingw-w64-headers and mingw-w64-crt configure scripts.


Actually, you can do just --with-default-msvcrt=msvcrt - the distinction 
between msvcrt vs msvcrt-os is handled within mingw-w64-crt/configure.ac - 
so we don't need to expose that detail to users in this doc.


Same thing in the paragraph below, we could just name it "msvcrt" there.


+== See Also ==
+
+"MSVCRT vs UCRT": https://www.msys2.org/docs/environments/
\ No newline at end of file


Nit: Add the missing newline here.

Other than that, I think this looks quite reasonable if we want to go down 
this path, and good to have some sort of official docs on the matter.


// Martin




___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH v2] configure: Use ucrt for msvcrt by default.

2023-06-19 Thread Jacek Caban via Mingw-w64-public
v2 includes changes suggested by Martin. It also includes a 
documentation change to clarify the situation.


---
 mingw-w64-crt/configure.ac   |  4 +-
 mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt | 58 
 mingw-w64-headers/configure.ac   | 12 ++--
 3 files changed, 66 insertions(+), 8 deletions(-)
 create mode 100644 mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt

diff --git a/mingw-w64-crt/configure.ac b/mingw-w64-crt/configure.ac
index 05f40b261..ced7745ca 100644
--- a/mingw-w64-crt/configure.ac
+++ b/mingw-w64-crt/configure.ac
@@ -267,9 +267,9 @@ AC_MSG_RESULT([$enable_delay_import_libs])
 AC_MSG_CHECKING([what to provide as libmsvcrt.a])
 AC_ARG_WITH([default-msvcrt],
   [AS_HELP_STRING([--with-default-msvcrt=LIB],
-[Lib to provide as libmsvcrt.a (default: msvcrt-os)])],
+[Lib to provide as libmsvcrt.a (default: ucrt)])],
   [],
-  [with_default_msvcrt=msvcrt-os])
+  [with_default_msvcrt=ucrt])
 if test "$with_default_msvcrt" = "msvcrt"; then
   with_default_msvcrt=msvcrt-os
 fi
diff --git a/mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt b/mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt
new file mode 100644
index 0..445b8a067
--- /dev/null
+++ b/mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt
@@ -0,0 +1,58 @@
+== Summary ==
+
+Starting from mingw-w64 version 12 and onwards, UCRT (Universal C Runtime) will
+be the default CRT runtime, unless specified otherwise during the minwgw-64
+build process. We believe that this configuration is the best choice for the
+majority of users. While we encourage users to consider switching to UCRT, we
+understand that it may not always be desirable, especially for compatibility
+reasons. Therefore, all previously supported configurations will continue to
+be supported. Users who wish to continue using msvcrt.dll can easily do so by
+adding the --with-default-msvcrt=msvcrt-os argument to both the
+mingw-w64-headers and mingw-w64-crt configure scripts.
+
+
+== Background ==
+
+mingw-w64 provides C runtime libraries that directly or indirectly utilize
+Microsoft DLLs at runtime. Over the years, Microsoft has released various
+versions of these DLLs, some of which were designed for specific MSVC versions
+while others aimed for backward compatibility. When building the mingw-w64
+toolchain, users can specify a version of the runtime DLL using the
+--with-default-msvcrt= configure option. The most commonly used versions are
+ucrt (utilizing ucrtbase.dll) and msvcrt-os (utilizing msvcrt.dll).
+
+The implementation of msvcrt.dll dates back to the Windows 9x era. While it has
+been extended for a period, it eventually became frozen in favor of providing
+separate DLLs for future MSVC versions. Although msvcrt.dll continues to be
+shipped with modern Windows versions, it remains compatible with the version
+from the 1990s. msvcrt.dll is known to deviate from standard behavior in many
+aspects. mingw-w64 includes compatibility wrappers and extensions to improve
+standard compatibility, but there are limitations to what can be practically
+achieved.
+
+On the other hand, ucrtbase.dll was introduced with MSVC 14 and is currently
+included with all Windows versions supported by Microsoft. It is also available
+as a redistributable package for older versions of Windows. ucrtbase.dll aims to
+replace MSVC version-specific DLLs and has been used by all MSVC versions since
+its introduction. It offers a more modern approach compared to msvcrt.dll and
+provides better standard compatibility out of the box, reducing overhead on the
+mingw-w64 side.
+
+
+== Compatibility ==
+
+When switching between toolchains that use different runtime libraries, it is
+generally advised not to mix static libraries, unless certain exceptions apply.
+If in doubt, it is recommended to rebuild all static libraries when switching
+the toolchain's runtime DLL.
+
+Dynamic libraries are less likely to be affected. If the CRT is not part of the
+ABI of a library you intend to use, meaning it does not involve passing FILE
+structs or similar types between modules or depending on the CRT allocator of
+other modules, it should remain unaffected. Otherwise, a compatible build of
+that library will be required.
+
+
+== See Also ==
+
+"MSVCRT vs UCRT": https://www.msys2.org/docs/environments/
\ No newline at end of file
diff --git a/mingw-w64-headers/configure.ac b/mingw-w64-headers/configure.ac
index d82280cd7..d6809d147 100644
--- a/mingw-w64-headers/configure.ac
+++ b/mingw-w64-headers/configure.ac
@@ -144,9 +144,9 @@ AC_SUBST([DEFAULT_WIN32_WINNT])
 AC_MSG_CHECKING([default msvcrt])
 AC_ARG_WITH([default-msvcrt],
   [AS_HELP_STRING([--with-default-msvcrt=LIB],
-[Default msvcrt to target (default: msvcrt)])],
+[Default msvcrt to target (default: ucrt)])],
   [],
-  [with_default_msvcrt=msvcrt])
+  [with_default_msvcrt=ucrt])
 case $with_default_msvcrt in
 msvcrt10*)
   default_msvcrt_version=0x100
@@ -178,12 +178,12 @@ msvcr110*)
 msvcr120*)