Re: meson: Add _static and _shared suffixes to the library names

From: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: meson: Add _static and _shared suffixes to the library names
Date: 2025-08-13 06:36:23
Message-ID: CAN55FZ2_oyp0+dKCjBkZA1sFjM23gF-5TSh7t=isNCLov9JZGA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Thank you all for sharing your thoughts and I am sorry for the first
proposal. It is a mistake on my part, I should have thought more.

On Tue, 12 Aug 2025 at 21:47, Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>
> On 12.08.25 18:37, Jacob Champion wrote:
> > On Tue, Aug 12, 2025 at 9:27 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >>> Is there a way to work around this problem in a way that affects Windows only?
> >>
> >> Even on Windows, the proposal is unacceptable.
> >
> > Sure, but I'm hoping that there's some Windows-specific Meson
> > twiddling that can be done to disambiguate the debug files on disk.
>
> Here is an older discussion that also involved having concurrent
> shared_library() and static_library() on Windows, and the general
> sentiment there appeared to be that this should (be made to) work:
> https://github.com/mesonbuild/meson/issues/459

I think the problem in the link you shared is different, we have
problems with Windows debug files (*.pdb files) but they have problems
with the library files themselves. Our problem is that the latest
built library tries to overwrite the early built library's .pdb file
and the build fails. So, my guess is that the libraries are in
different paths but their .pdb files are still in the same path. I did
a quick check and found that we have only one .pdb file after the
build, which I think confirms my guess. After the #1 fix applied, we
have two .pdb files; one .pdb file for each library type.

> So I don't know what changed now, but I think we should think about in
> terms of what changed rather than fixing our code.

I think we had this problem for a long time but the new ninja version
showed that problem.

I found two ways to fix that problem, both approaches fix the problem
by themselves:

1- Setting different names for .pdb files for shared libraries only on
the Windows OS. I think that is the correct fix, it just adds _shared
suffix to .pdb files of shared libraries on the Windows OS.

2- Using '/DEBUG:FULL' instead of '/DEBUG:FASTLINK' in the Windows CI
task but this causes more memory to be used. It seems that the error
appears only when the '/DEBUG:FASTLINK' is set. '/DEBUG:FULL' is a
default option, so we may decide to not add it at all. I explicitly
added it as I found this easier to understand. This approach fixes the
build but I think it is not the correct fix, we will have one .pdb
file after this fix; not one for each library type.

Here is how the directories look like after the fixes are applied:

$ dir C:\cirrus\build\src\interfaces\libpq ->

master with old ninja (master with new ninja fails):

Directory of C:\cirrus\build\src\interfaces\libpq

08/13/2025 05:47 AM <DIR> .
08/13/2025 05:47 AM <DIR> ..
08/13/2025 05:47 AM 4,483 exports.def
08/13/2025 05:47 AM 973,700 libpq.a
08/13/2025 05:47 AM <DIR> libpq.a.p
08/13/2025 05:47 AM 450,560 libpq.dll
08/13/2025 05:47 AM <DIR> libpq.dll.p
08/13/2025 05:47 AM 41,952 libpq.lib
08/13/2025 05:47 AM 1,413,120 libpq.pdb
08/13/2025 05:47 AM 700,416
lnk{6BBDFFB2-4393-4C5B-AE04-F33F1E9BBA12}.tmp
08/13/2025 05:47 AM <DIR> test
6 File(s) 3,584,231 bytes
5 Dir(s) 22,671,282,176 bytes free
--------------------------------------------------
#1 fix with new ninja:

Directory of C:\cirrus\build\src\interfaces\libpq

08/13/2025 05:55 AM <DIR> .
08/13/2025 05:53 AM <DIR> ..
08/13/2025 05:53 AM 4,483 exports.def
08/13/2025 05:55 AM 973,700 libpq.a
08/13/2025 05:54 AM <DIR> libpq.a.p
08/13/2025 05:53 AM 450,560 libpq.dll
08/13/2025 05:53 AM <DIR> libpq.dll.p
08/13/2025 05:53 AM 41,952 libpq.lib
08/13/2025 05:54 AM 700,416 libpq.pdb
08/13/2025 05:53 AM 1,413,120 libpq_shared.pdb
08/13/2025 05:55 AM <DIR> test
6 File(s) 3,584,231 bytes
5 Dir(s) 22,891,589,632 bytes free
----------------------------------------
#1 fix with old ninja:

Directory of C:\cirrus\build\src\interfaces\libpq

08/13/2025 06:19 AM <DIR> .
08/13/2025 06:19 AM <DIR> ..
08/13/2025 06:19 AM 4,483 exports.def
08/13/2025 06:19 AM 973,700 libpq.a
08/13/2025 06:19 AM <DIR> libpq.a.p
08/13/2025 06:19 AM 450,560 libpq.dll
08/13/2025 06:19 AM <DIR> libpq.dll.p
08/13/2025 06:19 AM 41,952 libpq.lib
08/13/2025 06:19 AM 700,416 libpq.pdb
08/13/2025 06:19 AM 1,413,120 libpq_shared.pdb
08/13/2025 06:19 AM <DIR> test
6 File(s) 3,584,231 bytes
5 Dir(s) 22,671,474,688 bytes free

--------------------------------------------------
#2 fix with new ninja:

Directory of C:\cirrus\build\src\interfaces\libpq

08/13/2025 06:04 AM <DIR> .
08/13/2025 06:02 AM <DIR> ..
08/13/2025 06:02 AM 4,483 exports.def
08/13/2025 06:04 AM 973,700 libpq.a
08/13/2025 06:03 AM <DIR> libpq.a.p
08/13/2025 06:02 AM 450,560 libpq.dll
08/13/2025 06:02 AM <DIR> libpq.dll.p
08/13/2025 06:02 AM 41,952 libpq.lib
08/13/2025 06:03 AM 1,961,984 libpq.pdb
08/13/2025 06:04 AM <DIR> test
5 File(s) 3,432,679 bytes
5 Dir(s) 22,859,337,728 bytes free
----------------------------------------
#2 fix with old ninja:

Directory of C:\cirrus\build\src\interfaces\libpq

08/13/2025 06:07 AM <DIR> .
08/13/2025 06:07 AM <DIR> ..
08/13/2025 06:07 AM 4,483 exports.def
08/13/2025 06:07 AM 973,700 libpq.a
08/13/2025 06:07 AM <DIR> libpq.a.p
08/13/2025 06:07 AM 450,560 libpq.dll
08/13/2025 06:07 AM <DIR> libpq.dll.p
08/13/2025 06:07 AM 41,952 libpq.lib
08/13/2025 06:07 AM 1,961,984 libpq.pdb
08/13/2025 06:07 AM <DIR> test
5 File(s) 3,432,679 bytes
5 Dir(s) 22,639,058,944 bytes free

- We have one .pdb file and one .tmp file on the master. I think this
.tmp file is a corrupted .pdb file
- #1 fix has correct .pdb files on both ninja versions.
- We have only one .pdb file with the #2 fix on both ninja versions,
there should be one for each library type.

--
Regards,
Nazir Bilal Yavuz
Microsoft

Attachment Content-Type Size
v2-0001-meson-windows-Add-_shared-suffix-to-the-.pdb-file.patch text/x-patch 5.3 KB
v2-0002-ci-windows-Use-DEBUG-FULL-instead-of-DEBUG-FASTLI.patch text/x-patch 1.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2025-08-13 06:39:07 Re: Enhance Makefiles to rebuild objects on map file changes
Previous Message jian he 2025-08-13 06:33:40 Re: on_error table, saving error info to a table