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 <pe...@eisentraut.org> wrote: > > On 12.08.25 18:37, Jacob Champion wrote: > > On Tue, Aug 12, 2025 at 9:27 AM Tom Lane <t...@sss.pgh.pa.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
From 1db1c13d6cb6149ee529d1a9bcc2282a0728ed2e Mon Sep 17 00:00:00 2001 From: Nazir Bilal Yavuz <byavu...@gmail.com> Date: Tue, 12 Aug 2025 20:46:57 +0300 Subject: [PATCH v2 1/2] meson: windows: Add _shared suffix to the .pdb files of shared libraries Otherwise static and shared libraries overwrite each other's .pdb (debug) files. Suggested-by: Andres Freund <and...@anarazel.de> Author: Nazir Bilal Yavuz <byavu...@gmail.com> Reviewed-by: Jacob Champion <jacob.champ...@enterprisedb.com> Reviewed-by: Peter Eisentraut <pe...@eisentraut.org> Reviewed-by: Tom Lane <t...@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAN55FZ1RuBhJmPWs3Oi%3D9UoezDfrtO-VaU67db5%2B0_uy19uF%2BA%40mail.gmail.com --- src/interfaces/libpq/meson.build | 9 ++++++++- src/interfaces/ecpg/compatlib/meson.build | 9 ++++++++- src/interfaces/ecpg/ecpglib/meson.build | 9 ++++++++- src/interfaces/ecpg/pgtypeslib/meson.build | 9 ++++++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build index a74e885b169..d0203901fa7 100644 --- a/src/interfaces/libpq/meson.build +++ b/src/interfaces/libpq/meson.build @@ -66,6 +66,13 @@ libpq_st = static_library('libpq', kwargs: default_lib_args, ) +# Change shared library's .pdb name so it won't conflict with static library's +# .pdb file +libpq_pdb_args = [] +if host_system == 'windows' + libpq_pdb_args = ['/PDB:' + meson.current_build_dir() / 'libpq_shared.pdb'] +endif + libpq_so = shared_library('libpq', libpq_sources + libpq_so_sources, include_directories: [libpq_inc, postgres_inc], @@ -76,7 +83,7 @@ libpq_so = shared_library('libpq', darwin_versions: ['5', '5.' + pg_version_major.to_string()], dependencies: [frontend_shlib_code, libpq_deps], link_depends: export_file, - link_args: export_fmt.format(export_file.full_path()), + link_args: [export_fmt.format(export_file.full_path())] + libpq_pdb_args, kwargs: default_lib_args, ) diff --git a/src/interfaces/ecpg/compatlib/meson.build b/src/interfaces/ecpg/compatlib/meson.build index 56e0a21651b..42bc87869ff 100644 --- a/src/interfaces/ecpg/compatlib/meson.build +++ b/src/interfaces/ecpg/compatlib/meson.build @@ -26,6 +26,13 @@ ecpg_compat_st = static_library('libecpg_compat', ) ecpg_targets += ecpg_compat_st +# Change shared library's .pdb name so it won't conflict with static library's +# .pdb file +ecpg_compat_pdb_args = [] +if host_system == 'windows' + ecpg_compat_pdb_args = ['/PDB:' + meson.current_build_dir() / 'libecpg_compat_shared.pdb'] +endif + ecpg_compat_so = shared_library('libecpg_compat', ecpg_compat_sources + ecpg_compat_so_sources, include_directories: ecpg_compat_inc, @@ -35,7 +42,7 @@ ecpg_compat_so = shared_library('libecpg_compat', soversion: host_system != 'windows' ? '3' : '', darwin_versions: ['3', '3.' + pg_version_major.to_string()], version: '3.' + pg_version_major.to_string(), - link_args: export_fmt.format(export_file.full_path()), + link_args: [export_fmt.format(export_file.full_path())] + ecpg_compat_pdb_args, link_depends: export_file, kwargs: default_lib_args, ) diff --git a/src/interfaces/ecpg/ecpglib/meson.build b/src/interfaces/ecpg/ecpglib/meson.build index 8f478c6a73e..1d090489a69 100644 --- a/src/interfaces/ecpg/ecpglib/meson.build +++ b/src/interfaces/ecpg/ecpglib/meson.build @@ -36,6 +36,13 @@ ecpglib_st = static_library('libecpg', ) ecpg_targets += ecpglib_st +# Change shared library's .pdb name so it won't conflict with static library's +# .pdb file +ecpglib_pdb_args = [] +if host_system == 'windows' + ecpglib_pdb_args = ['/PDB:' + meson.current_build_dir() / 'libecpg_shared.pdb'] +endif + ecpglib_so = shared_library('libecpg', ecpglib_sources + ecpglib_so_sources, include_directories: ecpglib_inc, @@ -46,7 +53,7 @@ ecpglib_so = shared_library('libecpg', soversion: host_system != 'windows' ? '6' : '', darwin_versions: ['6', '6.' + pg_version_major.to_string()], version: '6.' + pg_version_major.to_string(), - link_args: export_fmt.format(export_file.full_path()), + link_args: [export_fmt.format(export_file.full_path())] + ecpglib_pdb_args, link_depends: export_file, kwargs: default_lib_args, ) diff --git a/src/interfaces/ecpg/pgtypeslib/meson.build b/src/interfaces/ecpg/pgtypeslib/meson.build index 02301ec9acb..80a1f0db28e 100644 --- a/src/interfaces/ecpg/pgtypeslib/meson.build +++ b/src/interfaces/ecpg/pgtypeslib/meson.build @@ -31,6 +31,13 @@ ecpg_pgtypes_st = static_library('libpgtypes', ) ecpg_targets += ecpg_pgtypes_st +# Change shared library's .pdb name so it won't conflict with static library's +# .pdb file +ecpg_pgtypes_pdb_args = [] +if host_system == 'windows' + ecpg_pgtypes_pdb_args = ['/PDB:' + meson.current_build_dir() / 'libpgtypes_shared.pdb'] +endif + ecpg_pgtypes_so = shared_library('libpgtypes', ecpg_pgtypes_sources + ecpg_pgtypes_so_sources, include_directories: ecpg_pgtypes_inc, @@ -40,7 +47,7 @@ ecpg_pgtypes_so = shared_library('libpgtypes', version: '3.' + pg_version_major.to_string(), soversion: host_system != 'windows' ? '3' : '', darwin_versions: ['3', '3.' + pg_version_major.to_string()], - link_args: export_fmt.format(export_file.full_path()), + link_args: [export_fmt.format(export_file.full_path())] + ecpg_pgtypes_pdb_args, link_depends: export_file, kwargs: default_lib_args, ) -- 2.50.1
From 45d25df523f1dd642d1877354755e905392e9359 Mon Sep 17 00:00:00 2001 From: Nazir Bilal Yavuz <byavu...@gmail.com> Date: Tue, 12 Aug 2025 19:41:59 +0300 Subject: [PATCH v2 2/2] ci: windows: Use DEBUG:FULL instead of DEBUG:FASTLINK while building Postgres DEBUG:FASTLINK causes the .pdb files of shared and static libraries that have the same names to conflict. So, use DEBUG:FULL altough it uses more memory. Suggested-by: Andres Freund <and...@anarazel.de> Author: Nazir Bilal Yavuz <byavu...@gmail.com> Reviewed-by: Jacob Champion <jacob.champ...@enterprisedb.com> Reviewed-by: Peter Eisentraut <pe...@eisentraut.org> Reviewed-by: Tom Lane <t...@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAN55FZ1RuBhJmPWs3Oi%3D9UoezDfrtO-VaU67db5%2B0_uy19uF%2BA%40mail.gmail.com --- .cirrus.tasks.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.yml index 1a366975d82..b8661dcce8c 100644 --- a/.cirrus.tasks.yml +++ b/.cirrus.tasks.yml @@ -730,10 +730,9 @@ task: echo 127.0.0.3 pg-loadbalancetest >> c:\Windows\System32\Drivers\etc\hosts type c:\Windows\System32\Drivers\etc\hosts - # Use /DEBUG:FASTLINK to avoid high memory usage during linking configure_script: | vcvarsall x64 - meson setup --backend ninja --buildtype debug -Dc_link_args=/DEBUG:FASTLINK -Dcassert=true -Dinjection_points=true -Db_pch=true -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=%TAR% build + meson setup --backend ninja --buildtype debug -Dc_link_args=/DEBUG:FULL -Dcassert=true -Dinjection_points=true -Db_pch=true -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=%TAR% build build_script: | vcvarsall x64 -- 2.50.1