Skip to content

Commit 1758d42

Browse files
committed
Require ucrt if using MinGW.
Historically we tolerated the absence of various C runtime library features for the benefit of the MinGW tool chain, because it used ancient msvcrt.dll for a long period of time. It now uses ucrt by default (like Windows 10+, Visual Studio 2015+), and that's the only configuration we're testing. In practice, we effectively required ucrt already in PostgreSQL 17, when commit 8d9a9f0 required _create_locale etc, first available in msvcr120.dll (Visual Studio 2013, the last of the pre-ucrt series of runtimes), and for MinGW users that practically meant ucrt because it was difficult or impossible to use msvcr120.dll. That may even not have been the first such case, but old MinGW configurations had already dropped off our testing radar so we weren't paying much attention. This commit formalizes the requirement. It also removes a couple of obsolete comments that discussed msvcrt.dll limitations, and some tests of !defined(_MSC_VER) to imply msvcrt.dll. There are many more anachronisms, but it'll take some time to figure out how to remove them all. APIs affected relate to locales, UTF-8, threads, large files and more. Thanks to Peter Eisentraut for the documentation change. It's not really necessary to talk about ucrt explicitly in such a short section, since it's the default for MinGW-w64 and MSYS2. It's enough to prune references and broken links to much older tools. Reviewed-by: Peter Eisentraut <[email protected]> Discussion: https://postgr.es/m/d9e7731c-ca1b-477c-9298-fa51e135574a%40eisentraut.org
1 parent f1da075 commit 1758d42

File tree

2 files changed

+5
-74
lines changed

2 files changed

+5
-74
lines changed

doc/src/sgml/installation.sgml

+5-55
Original file line numberDiff line numberDiff line change
@@ -3582,33 +3582,9 @@ xcrun --show-sdk-path
35823582

35833583
<para>
35843584
PostgreSQL for Windows can be built using MinGW, a Unix-like build
3585-
environment for Microsoft operating systems.
3586-
The MinGW build procedure uses the normal build system described in
3587-
this chapter.
3588-
</para>
3589-
3590-
<para>
3591-
MinGW, the Unix-like build tools, and MSYS, a collection
3592-
of Unix tools required to run shell scripts
3593-
like <command>configure</command>, can be downloaded
3594-
from <ulink url="http://www.mingw.org/"></ulink>. Neither is
3595-
required to run the resulting binaries; they are needed only for
3596-
creating the binaries.
3597-
</para>
3598-
3599-
<para>
3600-
To build 64 bit binaries using MinGW, install the 64 bit tool set
3601-
from <ulink url="https://mingw-w64.org/"></ulink>, put its bin
3602-
directory in the <envar>PATH</envar>, and run
3603-
<command>configure</command> with the
3604-
<command>--host=x86_64-w64-mingw32</command> option.
3605-
</para>
3606-
3607-
<para>
3608-
After you have everything installed, it is suggested that you
3609-
run <application>psql</application>
3610-
under <command>CMD.EXE</command>, as the MSYS console has
3611-
buffering issues.
3585+
environment for Windows. It is recommended to use the <ulink
3586+
url="https://www.msys2.org/">MSYS2</ulink> environment for this and also
3587+
to install any prerequisite packages.
36123588
</para>
36133589

36143590
<sect3 id="mingw-crash-dumps">
@@ -3838,35 +3814,9 @@ make: *** [postgres] Error 1
38383814
<productname>Bison</productname> and <productname>Flex</productname> are
38393815
required. Only <productname>Bison</productname> versions 2.3 and later
38403816
will work. <productname>Flex</productname> must be version 2.5.35 or later.
3817+
Binaries can be downloaded from <ulink
3818+
url="https://github.com/lexxmark/winflexbison"></ulink>.
38413819
</para>
3842-
3843-
<para>
3844-
Both <productname>Bison</productname> and <productname>Flex</productname>
3845-
are included in the <productname>msys</productname> tool suite, available
3846-
from <ulink url="http://www.mingw.org/wiki/MSYS"></ulink> as part of the
3847-
<productname>MinGW</productname> compiler suite.
3848-
</para>
3849-
3850-
<para>
3851-
You will need to add the directory containing
3852-
<filename>flex.exe</filename> and <filename>bison.exe</filename> to the
3853-
PATH environment variable. In the case of MinGW, the directory is the
3854-
<filename>\msys\1.0\bin</filename> subdirectory of your MinGW
3855-
installation directory.
3856-
</para>
3857-
3858-
<note>
3859-
<para>
3860-
The Bison distribution from GnuWin32 appears to have a bug that
3861-
causes Bison to malfunction when installed in a directory with
3862-
spaces in the name, such as the default location on English
3863-
installations <filename>C:\Program Files\GnuWin32</filename>.
3864-
Consider installing into <filename>C:\GnuWin32</filename> or use the
3865-
NTFS short name path to GnuWin32 in your PATH environment setting
3866-
(e.g., <filename>C:\PROGRA~1\GnuWin32</filename>).
3867-
</para>
3868-
</note>
3869-
38703820
</listitem>
38713821
</varlistentry>
38723822
</variablelist>

src/backend/utils/adt/pg_locale.c

-19
Original file line numberDiff line numberDiff line change
@@ -1017,22 +1017,13 @@ cache_locale_time(void)
10171017
* get ISO Locale name directly by using GetLocaleInfoEx() with LCType as
10181018
* LOCALE_SNAME.
10191019
*
1020-
* MinGW headers declare _create_locale(), but msvcrt.dll lacks that symbol in
1021-
* releases before Windows 8. IsoLocaleName() always fails in a MinGW-built
1022-
* postgres.exe, so only Unix-style values of the lc_messages GUC can elicit
1023-
* localized messages. In particular, every lc_messages setting that initdb
1024-
* can select automatically will yield only C-locale messages. XXX This could
1025-
* be fixed by running the fully-qualified locale name through a lookup table.
1026-
*
10271020
* This function returns a pointer to a static buffer bearing the converted
10281021
* name or NULL if conversion fails.
10291022
*
10301023
* [1] https://docs.microsoft.com/en-us/windows/win32/intl/locale-identifiers
10311024
* [2] https://docs.microsoft.com/en-us/windows/win32/intl/locale-names
10321025
*/
10331026

1034-
#if defined(_MSC_VER)
1035-
10361027
/*
10371028
* Callback function for EnumSystemLocalesEx() in get_iso_localename().
10381029
*
@@ -1201,16 +1192,6 @@ IsoLocaleName(const char *winlocname)
12011192
return get_iso_localename(winlocname);
12021193
}
12031194

1204-
#else /* !defined(_MSC_VER) */
1205-
1206-
static char *
1207-
IsoLocaleName(const char *winlocname)
1208-
{
1209-
return NULL; /* Not supported on MinGW */
1210-
}
1211-
1212-
#endif /* defined(_MSC_VER) */
1213-
12141195
#endif /* WIN32 && LC_MESSAGES */
12151196

12161197

0 commit comments

Comments
 (0)