From c17f5ca2b404a1b2ed973a0f8f352a6e0e40cb43 Mon Sep 17 00:00:00 2001 From: Christopher Wellons Date: Mon, 12 Jun 2023 22:17:52 -0400 Subject: [PATCH] Use --with-default-msvcrt=msvcrt-os with Mingw-w64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Mingw-w64 default may change to UCRT in the future, possibly soon, but w64devkit will continue with the original msvcrt.dll for as long as possible. It has far better compatibility with older systems, and UCRT has limited availability prior to Windows 10. The only benefits of linking UCRT that I know are better compatibility when statically linking with UCRT-based toolchains, particularly MSVC, and actually-working assertions (something Mingw-w64 could fix, as it does printf, etc.). That's it! Mingw-w64 already fills in the missing C99 bits. The Mingw-w64 documentation vaguely mentions a UTF-8 locale, but it is either false or useless depending on the meaning. UCRT has all the same narrow API limitations of MSVCRT — *the* biggest and thorniest issue with Windows CRTs. Trading away a ton of backwards compatibility just for better static linking with MSVC sounds like a poor cost-benefit trade-off. In that light, the choice of CRT seems obvious regardless of the Mingw-w64 default. My own view is that Windows CRTs have been poorly implemented and are generally not worth using, so they should be avoided in the first place, i.e. define {main,WinMain}CRTStartup, call Win32 directly, and compile with -nostartfiles. https://sourceforge.net/p/mingw-w64/mailman/message/37853546/ --- Dockerfile | 4 ++++ src/variant-i686.patch | 18 +++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 350c900..498931e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -90,6 +90,7 @@ WORKDIR /x-mingw-headers RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-headers/configure \ --prefix=/bootstrap/$ARCH \ --host=$ARCH \ + --with-default-msvcrt=msvcrt-os \ && make -j$(nproc) \ && make install @@ -127,6 +128,7 @@ RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-crt/configure \ --prefix=/bootstrap/$ARCH \ --with-sysroot=/bootstrap/$ARCH \ --host=$ARCH \ + --with-default-msvcrt=msvcrt-os \ --disable-dependency-tracking \ --disable-lib32 \ --enable-lib64 \ @@ -212,6 +214,7 @@ WORKDIR /mingw-headers RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-headers/configure \ --prefix=$PREFIX/$ARCH \ --host=$ARCH \ + --with-default-msvcrt=msvcrt-os \ && make -j$(nproc) \ && make install @@ -220,6 +223,7 @@ RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-crt/configure \ --prefix=$PREFIX/$ARCH \ --with-sysroot=$PREFIX/$ARCH \ --host=$ARCH \ + --with-default-msvcrt=msvcrt-os \ --disable-dependency-tracking \ --disable-lib32 \ --enable-lib64 \ diff --git a/src/variant-i686.patch b/src/variant-i686.patch index dbdb8f8..32f7f24 100644 --- a/src/variant-i686.patch +++ b/src/variant-i686.patch @@ -5,39 +5,39 @@ -ARG ARCH=x86_64-w64-mingw32 +ARG ARCH=i686-w64-mingw32 -@@ -92,2 +92,3 @@ RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-headers/configure \ - --host=$ARCH \ +@@ -93,2 +93,3 @@ RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-headers/configure \ + --with-default-msvcrt=msvcrt-os \ + --with-default-win32-winnt=0x0501 \ && make -j$(nproc) \ -@@ -98,2 +99,5 @@ RUN ln -s $ARCH mingw +@@ -99,2 +100,5 @@ RUN ln -s $ARCH mingw +# Disable UTF-8 manifest for Windows XP (#58) +RUN echo >/gcc-$GCC_VERSION/gcc/config/i386/winnt-utf8.manifest + WORKDIR /x-gcc -@@ -103,2 +107,3 @@ RUN /gcc-$GCC_VERSION/configure \ +@@ -104,2 +108,3 @@ RUN /gcc-$GCC_VERSION/configure \ --target=$ARCH \ + --with-arch=pentium4 \ --enable-static \ -@@ -130,4 +135,4 @@ RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-crt/configure \ +@@ -132,4 +137,4 @@ RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-crt/configure \ --disable-dependency-tracking \ - --disable-lib32 \ - --enable-lib64 \ + --enable-lib32 \ + --disable-lib64 \ CFLAGS="-Os" \ -@@ -214,2 +219,3 @@ RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-headers/configure \ - --host=$ARCH \ +@@ -217,2 +222,3 @@ RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-headers/configure \ + --with-default-msvcrt=msvcrt-os \ + --with-default-win32-winnt=0x0501 \ && make -j$(nproc) \ -@@ -223,4 +229,4 @@ RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-crt/configure \ +@@ -227,4 +233,4 @@ RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-crt/configure \ --disable-dependency-tracking \ - --disable-lib32 \ - --enable-lib64 \ + --enable-lib32 \ + --disable-lib64 \ CFLAGS="-Os" \ -@@ -249,2 +255,3 @@ RUN /gcc-$GCC_VERSION/configure \ +@@ -239,2 +245,3 @@ RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-libraries/winpthreads/configure \ --host=$ARCH \ + --with-arch=pentium4 \ --enable-static \