Windows question: when is LC_MESSAGES defined?

Поиск
Список
Период
Сортировка
Искать

Windows question: when is LC_MESSAGES defined?

От:
Jeff Davis <pgsql@j-davis.com>
Дата:
I was trying to exercise the function IsoLocaleName(), which is
surrounded by:

   #if defined(WIN32) && defined(LC_MESSAGES)

but, at least in CI, that combination never seems to be true, which
surprised me. What platforms exercise this code path?

Regards,
	Jeff Davis



Re: Windows question: when is LC_MESSAGES defined?

От:
Thomas Munro <thomas.munro@gmail.com>
Дата:
On Thu, Jul 10, 2025 at 5:32 AM Jeff Davis  wrote:
> I was trying to exercise the function IsoLocaleName(), which is
> surrounded by:
>
>    #if defined(WIN32) && defined(LC_MESSAGES)
>
> but, at least in CI, that combination never seems to be true, which
> surprised me. What platforms exercise this code path?

.cirrus.tasks.yml says:

   # disable -Dnls as the number of files it creates cause a noticable
slowdown...

   configure_script: |
    %BASH% -c "meson setup -Ddebug=true -Doptimization=g
-Dcassert=true -Dinjection_points=true -Db_pch=true -Dnls=disabled
-DTAR=%TAR% build"

If you turn that on then the next problem to solve is:

[03:28:24.318] Program msgfmt found: NO

It gets past that and enables NLS and compiles that code in the
optional MinGW build (assuming you enable it in meson).


Re: Windows question: when is LC_MESSAGES defined?

От:
Thomas Munro <thomas.munro@gmail.com>
Дата:
On Thu, Jul 10, 2025 at 3:45 PM Thomas Munro  wrote:
> [03:28:24.318] Program msgfmt found: NO

Correction, that ^ is the reason it's not reached on the MSVC task,
while -Dnls=disabled is the reason for the MinGW task.  But the
conclusion is the same: MinGW is the easiest way to test this code
on CI, if you're hacking on it.

Given that the build farm also doesn't test Windows + NLS, it's a
small miracle that it even compiles.  Hmm, I guess that the EDB
installer build must have it enabled, so I suppose they'd tell us if
we broke it.  I guess that because sometimes we see reports of
encoded-garbled error messages in other languages on the lists, which
also tells us that it might have bugs in that department.  What I
don't recall is whether they looked like the
"some-contexts-have-no-defined-encoding" problem (that exists on Unix
too but no one cares anymore since we all switched everything to UTF-8
ages ago), or something else...


Re: Windows question: when is LC_MESSAGES defined?

От:
Nazir Bilal Yavuz <byavuz81@gmail.com>
Дата:
Hi,

On Thu, 10 Jul 2025 at 07:34, Thomas Munro  wrote:
>
> On Thu, Jul 10, 2025 at 3:45 PM Thomas Munro  wrote:
> > [03:28:24.318] Program msgfmt found: NO
>
> Correction, that ^ is the reason it's not reached on the MSVC task,
> while -Dnls=disabled is the reason for the MinGW task.  But the
> conclusion is the same: MinGW is the easiest way to test this code
> on CI, if you're hacking on it.
>
> Given that the build farm also doesn't test Windows + NLS, it's a
> small miracle that it even compiles.  Hmm, I guess that the EDB
> installer build must have it enabled, so I suppose they'd tell us if
> we broke it.  I guess that because sometimes we see reports of
> encoded-garbled error messages in other languages on the lists, which
> also tells us that it might have bugs in that department.  What I
> don't recall is whether they looked like the
> "some-contexts-have-no-defined-encoding" problem (that exists on Unix
> too but no one cares anymore since we all switched everything to UTF-8
> ages ago), or something else...

I spent some time on enabling NLS on MSVC:

x86:

* x86 files are available here [1]. I downloaded 'Complete package,
except sources' from this page, installed it and set related bin_dir,
extra_include_dirst and extra_lib_dirs. Then I was able to compile
Postgres with nls being enabled. I did not run tests as it was taking
too much time on the Windows VM instance (not CI instance, regular
Google Cloud VM created by using our Windows CI images).

x64:

* I downloaded Dave Page's Windows gettext artifact from [2]. I am
able to configure Postgres with nls being enabled but then compilation
failed with:
```
[349/2500] Building translation
src/interfaces/libpq/po/cs/LC_MESSAGES/libpq5-19-cs.mo
FAILED: src/interfaces/libpq/po/cs/LC_MESSAGES/libpq5-19.mo
"C:\Users\byavuz81\Downloads\gettext-0.25-win64\bin\msgfmt.EXE" "-o"
"src/interfaces/libpq/po/cs/LC_MESSAGES/libpq5-19.mo"
"../src/interfaces/libpq/po/cs.po"
C:\Users\byavuz81\Downloads\gettext-0.25-win64\bin\msgfmt.EXE: iconv
failure: No error
[354/2500] Compiling C object
src/interfaces/libpq/libpq.dll.p/fe-auth-oauth.c.obj
```

* Another option is using vcpkg [3] to install gettext. I tried that
~1 year ago and I remember gettext was working on Windows + MSVC but
not sure about its current status.

* Another option could be to download gettext [4] and then compile it locally.


[1] https://gnuwin32.sourceforge.net/packages/gettext.htm
[2] https://github.com/dpage/winpgbuild/actions/runs/16211024479
[3] https://vcpkg.io
[4] https://www.gnu.org/software/gettext

-- 
Regards,
Nazir Bilal Yavuz
Microsoft


Re: Windows question: when is LC_MESSAGES defined?

От:
Dave Page <dpage@pgadmin.org>
Дата:
Hi

On Thu, 17 Jul 2025 at 09:01, Nazir Bilal Yavuz <byavuz81@gmail.com> wrote:
Hi,

On Thu, 10 Jul 2025 at 07:34, Thomas Munro <thomas.munro@gmail.com> wrote:
>
> On Thu, Jul 10, 2025 at 3:45 PM Thomas Munro <thomas.munro@gmail.com> wrote:
> > [03:28:24.318] Program msgfmt found: NO
>
> Correction, that ^ is the reason it's not reached on the MSVC task,
> while -Dnls=disabled is the reason for the MinGW task.  But the
> conclusion is the same: MinGW is the easiest way to test this code
> on CI, if you're hacking on it.
>
> Given that the build farm also doesn't test Windows + NLS, it's a
> small miracle that it even compiles.  Hmm, I guess that the EDB
> installer build must have it enabled, so I suppose they'd tell us if
> we broke it.  I guess that because sometimes we see reports of
> encoded-garbled error messages in other languages on the lists, which
> also tells us that it might have bugs in that department.  What I
> don't recall is whether they looked like the
> "some-contexts-have-no-defined-encoding" problem (that exists on Unix
> too but no one cares anymore since we all switched everything to UTF-8
> ages ago), or something else...

I spent some time on enabling NLS on MSVC:

x86:

* x86 files are available here [1]. I downloaded 'Complete package,
except sources' from this page, installed it and set related bin_dir,
extra_include_dirst and extra_lib_dirs. Then I was able to compile
Postgres with nls being enabled. I did not run tests as it was taking
too much time on the Windows VM instance (not CI instance, regular
Google Cloud VM created by using our Windows CI images).

x64:

* I downloaded Dave Page's Windows gettext artifact from [2]. I am
able to configure Postgres with nls being enabled but then compilation
failed with:
```
[349/2500] Building translation
src/interfaces/libpq/po/cs/LC_MESSAGES/libpq5-19-cs.mo
FAILED: src/interfaces/libpq/po/cs/LC_MESSAGES/libpq5-19.mo
"C:\Users\byavuz81\Downloads\gettext-0.25-win64\bin\msgfmt.EXE" "-o"
"src/interfaces/libpq/po/cs/LC_MESSAGES/libpq5-19.mo"
"../src/interfaces/libpq/po/cs.po"
C:\Users\byavuz81\Downloads\gettext-0.25-win64\bin\msgfmt.EXE: iconv
failure: No error
[354/2500] Compiling C object
src/interfaces/libpq/libpq.dll.p/fe-auth-oauth.c.obj

That build of gettext seems to work fine with the PostgreSQL builds in the winpgbuild repo, so there must be something different in your environment. I do remember spending some time trying to resolve the "iconv failure: No error" message myself though, but unfortunately I was just messing around in the GitHub editor trying to get it to work for giggles at the time with a bunch of trial and error builds with no useful commit messages so couldn't tell you what the issue was now :-/

I do also recall that gettext was the component that took me by far the longest to get working on that project.
 
--

Re: Windows question: when is LC_MESSAGES defined?

От:
Nazir Bilal Yavuz <byavuz81@gmail.com>
Дата:
Hi,

On Thu, 17 Jul 2025 at 11:19, Dave Page  wrote:
>
> On Thu, 17 Jul 2025 at 09:01, Nazir Bilal Yavuz  wrote:
>>
>> x64:
>>
>> * I downloaded Dave Page's Windows gettext artifact from [2]. I am
>> able to configure Postgres with nls being enabled but then compilation
>> failed with:
>> ```
>> [349/2500] Building translation
>> src/interfaces/libpq/po/cs/LC_MESSAGES/libpq5-19-cs.mo
>> FAILED: src/interfaces/libpq/po/cs/LC_MESSAGES/libpq5-19.mo
>> "C:\Users\byavuz81\Downloads\gettext-0.25-win64\bin\msgfmt.EXE" "-o"
>> "src/interfaces/libpq/po/cs/LC_MESSAGES/libpq5-19.mo"
>> "../src/interfaces/libpq/po/cs.po"
>> C:\Users\byavuz81\Downloads\gettext-0.25-win64\bin\msgfmt.EXE: iconv
>> failure: No error
>> [354/2500] Compiling C object
>> src/interfaces/libpq/libpq.dll.p/fe-auth-oauth.c.obj
>
>
> That build of gettext seems to work fine with the PostgreSQL builds in the winpgbuild repo, so there must be something different in your environment. I do remember spending some time trying to resolve the "iconv failure: No error" message myself though, but unfortunately I was just messing around in the GitHub editor trying to get it to work for giggles at the time with a bunch of trial and error builds with no useful commit messages so couldn't tell you what the issue was now :-/
>
> I do also recall that gettext was the component that took me by far the longest to get working on that project.

Thanks for the heads-up! Unfortunately, I tried that on a VM which I
have since deleted, so I no longer have access to that environment. I
am planning to retry this soon and will let you know if I make any
progress.

-- 
Regards,
Nazir Bilal Yavuz
Microsoft


FAQ