Hi,

I've been hacking on addressing some of the complaints (after having been
off-work in a somewhat unplanned way for most of the last two weeks).  With
some already opened and soon-to-be-proposed PRs to Dave's winbuild and the
attached changes I think the concerns can largely be addressed.


Here's the current set of changes:

0001: meson: Add missing argument to gssapi.h check
  Largely independent, but included to avoid conflicts

0002: Don't define HAVE_[GSSAPI_]GSSAPI_EXT_H
  Largely independent, but included to avoid conflicts

0003: meson: Add support for detecting gss without pkg-config
0004: meson: Add support for detecting ossp-uuid without pkg-config
  Do what it says on the tin. Neither includes dependency information via
  pkg-config or cmake in their upstream repos.

0005: meson: Add dependency lookups via names used by cmake

  This adds support for the alternative names used by cmake lookups. That
  addresses

0006: meson: nls: Handle intl requiring iconv
  This afaict is only required when dealing with a static libc, so it might be
  considered independent

0007: windows-tab-complete-workaround
  Just included so the build doesn't fail for me with all the dependencies
  installed.

0008: krb-vs-openssl-workaround
  Just included so the build doesn't fail for me with all the dependencies
  installed. There's a separate thread to discuss the right fix.

0009: wip: meson: reduce linker noise for executables

  This is mainly a minor quality of life thing for me when hacking on this. If
  a static libintl is used, link.exe outputs a message for every binary, which
  makes it harder to see warnings.

0010: meson: wip: tcl
  This is just some preliminary hacking needs more work.


Note that cmake is automatically installed as part of visual studio these
days.

Greetings,

Andres Freund
>From 4e036f77bad5264cda625222068b706555d7f85a Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Mon, 8 Jul 2024 15:28:04 -0700
Subject: [PATCH v2 01/10] meson: Add missing argument to gssapi.h check

These were missing since the initial introduction of the meson based build, in
e6927270cd18. As-is this is unlikely to cause an issue, but a future commit
will add support for detecting gssapi without use of dependency(), which could
fail due to this.

Backpatch: 16-, where the meson based build was added
---
 meson.build | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index 5387bb6d5fd..102b1e98a27 100644
--- a/meson.build
+++ b/meson.build
@@ -621,7 +621,8 @@ if not gssapiopt.disabled()
   elif cc.check_header('gssapi/gssapi.h', dependencies: gssapi, required: false,
       args: test_c_args, include_directories: postgres_inc)
     cdata.set('HAVE_GSSAPI_GSSAPI_H', 1)
-  elif cc.check_header('gssapi.h', args: test_c_args, dependencies: gssapi, required: gssapiopt)
+  elif cc.check_header('gssapi.h', dependencies: gssapi, required: gssapiopt,
+      args: test_c_args, include_directories: postgres_inc)
     cdata.set('HAVE_GSSAPI_H', 1)
   else
     have_gssapi = false
@@ -631,7 +632,8 @@ if not gssapiopt.disabled()
   elif cc.check_header('gssapi/gssapi_ext.h', dependencies: gssapi, required: false,
       args: test_c_args, include_directories: postgres_inc)
     cdata.set('HAVE_GSSAPI_GSSAPI_EXT_H', 1)
-  elif cc.check_header('gssapi_ext.h', args: test_c_args, dependencies: gssapi, required: gssapiopt)
+  elif cc.check_header('gssapi_ext.h', dependencies: gssapi, required: gssapiopt,
+      args: test_c_args, include_directories: postgres_inc)
     cdata.set('HAVE_GSSAPI_EXT_H', 1)
   else
     have_gssapi = false
-- 
2.44.0.279.g3bd955d269

>From 9f7c96dfab4d807e668c9d32b44db5f4ff122e15 Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Mon, 8 Jul 2024 15:55:56 -0700
Subject: [PATCH v2 02/10] Don't define HAVE_[GSSAPI_]GSSAPI_EXT_H

The check for gssapi_ext.h was added in f7431bca8b0. As we require
gssapi_ext.h to be present, there's no point in defining symbols for the
header presence.

While at it, use cc.has_header() instead of cc.check_header(), that's a bit
cheaper and it seems improbably that gssapi.h would compile while gssapi_ext.h
would not.

Author:
Reviewed-by:
Discussion: https://postgr.es/m/
Backpatch:
---
 meson.build                | 15 ++++-----------
 configure.ac               |  4 ++--
 src/include/pg_config.h.in |  6 ------
 configure                  | 12 ------------
 4 files changed, 6 insertions(+), 31 deletions(-)

diff --git a/meson.build b/meson.build
index 102b1e98a27..f1912d83ce6 100644
--- a/meson.build
+++ b/meson.build
@@ -620,25 +620,18 @@ if not gssapiopt.disabled()
   if not have_gssapi
   elif cc.check_header('gssapi/gssapi.h', dependencies: gssapi, required: false,
       args: test_c_args, include_directories: postgres_inc)
+    cc.has_header('gssapi/gssapi_ext.h', dependencies: gssapi, required: true,
+      args: test_c_args, include_directories: postgres_inc)
     cdata.set('HAVE_GSSAPI_GSSAPI_H', 1)
   elif cc.check_header('gssapi.h', dependencies: gssapi, required: gssapiopt,
       args: test_c_args, include_directories: postgres_inc)
+    cc.has_header('gssapi_ext.h', dependencies: gssapi, required: true,
+      args: test_c_args, include_directories: postgres_inc)
     cdata.set('HAVE_GSSAPI_H', 1)
   else
     have_gssapi = false
   endif
 
-  if not have_gssapi
-  elif cc.check_header('gssapi/gssapi_ext.h', dependencies: gssapi, required: false,
-      args: test_c_args, include_directories: postgres_inc)
-    cdata.set('HAVE_GSSAPI_GSSAPI_EXT_H', 1)
-  elif cc.check_header('gssapi_ext.h', dependencies: gssapi, required: gssapiopt,
-      args: test_c_args, include_directories: postgres_inc)
-    cdata.set('HAVE_GSSAPI_EXT_H', 1)
-  else
-    have_gssapi = false
-  endif
-
   if not have_gssapi
   elif cc.has_function('gss_store_cred_into', dependencies: gssapi,
       args: test_c_args, include_directories: postgres_inc)
diff --git a/configure.ac b/configure.ac
index ab2d51c21ce..7cd7e95ae49 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1532,8 +1532,8 @@ fi
 if test "$with_gssapi" = yes ; then
   AC_CHECK_HEADERS(gssapi/gssapi.h, [],
 	[AC_CHECK_HEADERS(gssapi.h, [], [AC_MSG_ERROR([gssapi.h header file is required for GSSAPI])])])
-  AC_CHECK_HEADERS(gssapi/gssapi_ext.h, [],
-	[AC_CHECK_HEADERS(gssapi_ext.h, [], [AC_MSG_ERROR([gssapi_ext.h header file is required for GSSAPI])])])
+  AC_CHECK_HEADER(gssapi/gssapi_ext.h, [],
+	[AC_CHECK_HEADER(gssapi_ext.h, [], [AC_MSG_ERROR([gssapi_ext.h header file is required for GSSAPI])])])
 fi
 
 PGAC_PATH_PROGS(OPENSSL, openssl)
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index f8d3e3b6b84..e0c0b51c5c1 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -180,12 +180,6 @@
 /* Define to 1 if you have the `getpeerucred' function. */
 #undef HAVE_GETPEERUCRED
 
-/* Define to 1 if you have the <gssapi_ext.h> header file. */
-#undef HAVE_GSSAPI_EXT_H
-
-/* Define to 1 if you have the <gssapi/gssapi_ext.h> header file. */
-#undef HAVE_GSSAPI_GSSAPI_EXT_H
-
 /* Define to 1 if you have the <gssapi/gssapi.h> header file. */
 #undef HAVE_GSSAPI_GSSAPI_H
 
diff --git a/configure b/configure
index 76f06bd8fda..2a9d467be04 100755
--- a/configure
+++ b/configure
@@ -13677,32 +13677,20 @@ fi
 
 done
 
-  for ac_header in gssapi/gssapi_ext.h
-do :
   ac_fn_c_check_header_mongrel "$LINENO" "gssapi/gssapi_ext.h" "ac_cv_header_gssapi_gssapi_ext_h" "$ac_includes_default"
 if test "x$ac_cv_header_gssapi_gssapi_ext_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_GSSAPI_GSSAPI_EXT_H 1
-_ACEOF
 
 else
-  for ac_header in gssapi_ext.h
-do :
   ac_fn_c_check_header_mongrel "$LINENO" "gssapi_ext.h" "ac_cv_header_gssapi_ext_h" "$ac_includes_default"
 if test "x$ac_cv_header_gssapi_ext_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_GSSAPI_EXT_H 1
-_ACEOF
 
 else
   as_fn_error $? "gssapi_ext.h header file is required for GSSAPI" "$LINENO" 5
 fi
 
-done
 
 fi
 
-done
 
 fi
 
-- 
2.44.0.279.g3bd955d269

>From 2efdec3f9ae57004612717c1cb1af926909dddb7 Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Mon, 8 Jul 2024 16:12:39 -0700
Subject: [PATCH v2 03/10] meson: Add support for detecting gss without
 pkg-config

This is required as MIT Kerberos does provide neither pkg-config nor cmake
dependency information on windows.

Author:
Reviewed-by:
Discussion: https://postgr.es/m/
Backpatch:
---
 meson.build | 45 +++++++++++++++++++++++++++++++++++++++------
 1 file changed, 39 insertions(+), 6 deletions(-)

diff --git a/meson.build b/meson.build
index f1912d83ce6..9a54b6ea01b 100644
--- a/meson.build
+++ b/meson.build
@@ -614,18 +614,51 @@ gssapiopt = get_option('gssapi')
 krb_srvtab = ''
 have_gssapi = false
 if not gssapiopt.disabled()
-  gssapi = dependency('krb5-gssapi', required: gssapiopt)
+  gssapi = dependency('krb5-gssapi', required: false)
   have_gssapi = gssapi.found()
 
+  if have_gssapi
+      gssapi_deps = [gssapi]
+  elif not have_gssapi
+    # Hardcoded lookup for gssapi. This is necessary as gssapi on windows does
+    # not install neither pkg-config nor cmake dependency information.
+    if host_system == 'windows'
+      is_64  = cc.sizeof('void *', args: test_c_args) == 8
+      if is_64
+        gssapi_search_libs = ['gssapi64', 'krb5_64', 'comerr64']
+      else
+        gssapi_search_libs = ['gssapi32', 'krb5_32', 'comerr32']
+      endif
+    else
+      gssapi_search_libs = ['gssapi_krb5']
+    endif
+
+    gssapi_deps = []
+    foreach libname : gssapi_search_libs
+      lib = cc.find_library(libname, dirs: test_lib_d, required: false)
+      if lib.found()
+        have_gssapi = true
+        gssapi_deps += lib
+      endif
+    endforeach
+
+    if have_gssapi
+      # Meson before 0.57.0 did not support using check_header() etc with
+      # declare_dependency(). Thus the tests below use the library looked up
+      # above.  Once we require a newer meson version, we can simplify.
+      gssapi = declare_dependency(dependencies: gssapi_deps)
+    endif
+  endif
+
   if not have_gssapi
-  elif cc.check_header('gssapi/gssapi.h', dependencies: gssapi, required: false,
+  elif cc.check_header('gssapi/gssapi.h', dependencies: gssapi_deps, required: false,
       args: test_c_args, include_directories: postgres_inc)
-    cc.has_header('gssapi/gssapi_ext.h', dependencies: gssapi, required: true,
+    cc.has_header('gssapi/gssapi_ext.h', dependencies: gssapi_deps, required: true,
       args: test_c_args, include_directories: postgres_inc)
     cdata.set('HAVE_GSSAPI_GSSAPI_H', 1)
-  elif cc.check_header('gssapi.h', dependencies: gssapi, required: gssapiopt,
+  elif cc.check_header('gssapi.h', dependencies: gssapi_deps, required: gssapiopt,
       args: test_c_args, include_directories: postgres_inc)
-    cc.has_header('gssapi_ext.h', dependencies: gssapi, required: true,
+    cc.has_header('gssapi_ext.h', dependencies: gssapi_deps, required: true,
       args: test_c_args, include_directories: postgres_inc)
     cdata.set('HAVE_GSSAPI_H', 1)
   else
@@ -633,7 +666,7 @@ if not gssapiopt.disabled()
   endif
 
   if not have_gssapi
-  elif cc.has_function('gss_store_cred_into', dependencies: gssapi,
+  elif cc.has_function('gss_store_cred_into', dependencies: gssapi_deps,
       args: test_c_args, include_directories: postgres_inc)
     cdata.set('ENABLE_GSS', 1)
 
-- 
2.44.0.279.g3bd955d269

>From fa9238d9a9362e8e9b8a851b4cbdff0f773ad15a Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Mon, 8 Jul 2024 22:28:12 -0700
Subject: [PATCH v2 04/10] meson: Add support for detecting ossp-uuid without
 pkg-config

This is necessary as ossp-uuid on windows installs neither a pkg-config nor a
cmake dependency information. Nor is there another supported uuid
implementation available on windows.

Author:
Reviewed-by:
Discussion: https://postgr.es/m/
Backpatch:
---
 meson.build | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 9a54b6ea01b..53b61aa4da2 100644
--- a/meson.build
+++ b/meson.build
@@ -1374,9 +1374,26 @@ if uuidopt != 'none'
     uuidfunc = 'uuid_to_string'
     uuidheader = 'uuid.h'
   elif uuidopt == 'ossp'
-    uuid = dependency('ossp-uuid', required: true)
+    uuid = dependency('ossp-uuid', required: false)
     uuidfunc = 'uuid_export'
     uuidheader = 'uuid.h'
+
+    # Hardcoded lookup for ossp-uuid. This is necessary as ossp-uuid on
+    # windows installs neither a pkg-config nor a cmake dependency
+    # information. Nor is there another supported uuid implementation
+    # available on windows.
+    #
+    # Sometimes the ossp-uuid library is named 'uuid' sometimes 'ossp-uuid'
+    if not uuid.found()
+      uuid = cc.find_library('ossp-uuid',
+        required: false, dirs: test_lib_d,
+        has_headers: uuidheader, header_include_directories: postgres_inc)
+    endif
+    if not uuid.found()
+      uuid = cc.find_library('uuid',
+        required: true, dirs: test_lib_d,
+        has_headers: uuidheader, header_include_directories: postgres_inc)
+    endif
   else
     error('unknown uuid build option value: @0@'.format(uuidopt))
   endif
-- 
2.44.0.279.g3bd955d269

>From 2f28645905efbc46cff9ad441de3b53152d99890 Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Mon, 8 Jul 2024 22:31:10 -0700
Subject: [PATCH v2 05/10] meson: Add dependency lookups via names used by
 cmake

Particularly on windows it's useful to look up dependencies via cmake, instead
of pkg-config. Meson supports doing so. Unfortunately the dependency names
used by various projects often differs between their pkg-config and cmake
files.

This would look a lot neater if we could rely on meson >= 0.60.0...

Author:
Reviewed-by:
Discussion: https://postgr.es/m/
Backpatch:
---
 meson.build | 44 ++++++++++++++++++++++++++++++++++++++------
 1 file changed, 38 insertions(+), 6 deletions(-)

diff --git a/meson.build b/meson.build
index 53b61aa4da2..04d5877212a 100644
--- a/meson.build
+++ b/meson.build
@@ -801,8 +801,20 @@ endif
 
 icuopt = get_option('icu')
 if not icuopt.disabled()
-  icu = dependency('icu-uc', required: icuopt)
-  icu_i18n = dependency('icu-i18n', required: icuopt)
+  icu = dependency('icu-uc', required: false)
+  if icu.found()
+    icu_i18n = dependency('icu-i18n', required: true)
+  endif
+
+  # Unfortunately the dependency is named differently with cmake
+  if not icu.found() # combine with above once meson 0.60.0 is required
+    icu = dependency('ICU', required: icuopt,
+                     components: ['uc'], modules: ['ICU::uc'], method: 'cmake')
+    if icu.found()
+      icu_i18n = dependency('ICU', required: true,
+                            components: ['i18n'], modules: ['ICU::i18n'])
+    endif
+  endif
 
   if icu.found()
     cdata.set('USE_ICU', 1)
@@ -821,7 +833,12 @@ endif
 
 libxmlopt = get_option('libxml')
 if not libxmlopt.disabled()
-  libxml = dependency('libxml-2.0', required: libxmlopt, version: '>= 2.6.23')
+  libxml = dependency('libxml-2.0', required: false, version: '>= 2.6.23')
+  # Unfortunately the dependency is named differently with cmake
+  if not libxml.found() # combine with above once meson 0.60.0 is required
+    libxml = dependency('LibXml2', required: libxmlopt, version: '>= 2.6.23',
+      method: 'cmake')
+  endif
 
   if libxml.found()
     cdata.set('USE_LIBXML', 1)
@@ -838,7 +855,11 @@ endif
 
 libxsltopt = get_option('libxslt')
 if not libxsltopt.disabled()
-  libxslt = dependency('libxslt', required: libxsltopt)
+  libxslt = dependency('libxslt', required: false)
+  # Unfortunately the dependency is named differently with cmake
+  if not libxslt.found() # combine with above once meson 0.60.0 is required
+    libxslt = dependency('LibXslt', required: libxsltopt, method: 'cmake')
+  endif
 
   if libxslt.found()
     cdata.set('USE_LIBXSLT', 1)
@@ -855,7 +876,13 @@ endif
 
 lz4opt = get_option('lz4')
 if not lz4opt.disabled()
-  lz4 = dependency('liblz4', required: lz4opt)
+  lz4 = dependency('liblz4', required: false)
+  # Unfortunately the dependency is named differently with cmake
+  if not lz4.found() # combine with above once meson 0.60.0 is required
+    lz4 = dependency('lz4', required: lz4opt,
+                     method: 'cmake', modules: ['LZ4::lz4_shared'],
+                    )
+  endif
 
   if lz4.found()
     cdata.set('USE_LZ4', 1)
@@ -1474,7 +1501,12 @@ endif
 
 zstdopt = get_option('zstd')
 if not zstdopt.disabled()
-  zstd = dependency('libzstd', required: zstdopt, version: '>=1.4.0')
+  zstd = dependency('libzstd', required: false, version: '>=1.4.0')
+  # Unfortunately the dependency is named differently with cmake
+  if not zstd.found() # combine with above once meson 0.60.0 is required
+    zstd = dependency('zstd', required: zstdopt, version: '>=1.4.0',
+                      method: 'cmake', modules: ['zstd::libzstd_shared'])
+  endif
 
   if zstd.found()
     cdata.set('USE_ZSTD', 1)
-- 
2.44.0.279.g3bd955d269

>From c5c1e55d8237291a1e7ff68ca2306b1c21875e05 Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Thu, 20 Jun 2024 00:33:49 -0700
Subject: [PATCH v2 06/10] meson: nls: Handle intl requiring iconv

This is e.g. the case when intl is a) not part of libc and b) statically
linked.

Author:
Reviewed-by:
Discussion: https://postgr.es/m/
Backpatch:
---
 meson.build | 36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/meson.build b/meson.build
index 04d5877212a..e4bfd105f4c 100644
--- a/meson.build
+++ b/meson.build
@@ -2757,19 +2757,45 @@ if not nlsopt.disabled()
   # warnings if not found.
   msgfmt = find_program('msgfmt', required: nlsopt, native: true)
 
+  intl_link_test = '''
+        #include <libintl.h>
+        int main(void)
+        {
+            return ngettext == 0;
+        }
+  '''
+
   # meson 0.59 has this wrapped in dependency('intl')
   if (msgfmt.found() and
       cc.check_header('libintl.h', required: nlsopt,
         args: test_c_args, include_directories: postgres_inc))
 
-    # in libc
     if cc.has_function('ngettext')
+      # gettext is part of libc
       libintl = declare_dependency()
     else
-      libintl = cc.find_library('intl',
-        has_headers: ['libintl.h'], required: nlsopt,
-        header_include_directories: postgres_inc,
-        dirs: test_lib_d)
+      # gettext is in a dedicated library
+      libintl_int = cc.find_library('intl',
+        required: nlsopt, disabler: true, dirs: test_lib_d,
+        has_headers: ['libintl.h'], header_include_directories: postgres_inc)
+
+      # On some platforms/configurations one needs to link to both intl and
+      # iconv. Test if that's the case.
+      if cc.links(intl_link_test,
+          name: 'ngettext', dependencies: libintl_int,
+          include_directories: postgres_inc, args: test_c_args)
+        # all good, libintl works without iconv
+        libintl = libintl_int
+      else
+        # need iconv as well
+        libiconv = cc.find_library('iconv',
+          required: nlsopt, disabler: true, dirs: test_lib_d)
+        if cc.links(intl_link_test,
+             name: 'ngettext', dependencies: [libintl_int, libiconv],
+             include_directories: postgres_inc, args: test_c_args)
+          libintl = declare_dependency(dependencies: [libintl_int, libiconv])
+        endif
+      endif
     endif
   endif
 
-- 
2.44.0.279.g3bd955d269

>From eca6d7c098755bcb72f18ddba9a871d90e113131 Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Wed, 19 Jun 2024 09:13:39 -0700
Subject: [PATCH v2 07/10] windows-tab-complete-workaround

---
 src/bin/psql/tab-complete.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index d453e224d93..8627eba346a 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1750,6 +1750,7 @@ psql_completion(const char *text, int start, int end)
 	 * commands.  So get the string to look at from rl_line_buffer instead.
 	 */
 	char	   *text_copy = pnstrdup(rl_line_buffer + start, end - start);
+	bool if_continues = false;
 	text = text_copy;
 
 	/* Remember last char of the given input word. */
@@ -3033,7 +3034,16 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatches("INDEX|CONCURRENTLY", MatchAny, "ON") ||
 			 TailMatches("INDEX|CONCURRENTLY", "ON"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexables);
+	else
+		if_continues = true;
 
+	/*
+	 * Complete CREATE|UNIQUE INDEX CONCURRENTLY with "ON" and existing
+	 * indexes
+	 */
+	if (!if_continues)
+	{
+	}
 	/*
 	 * Complete CREATE|UNIQUE INDEX CONCURRENTLY with "ON" and existing
 	 * indexes
-- 
2.44.0.279.g3bd955d269

>From 5fbe666193d0f7a200c6413b2f16e5dfa84232af Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Wed, 19 Jun 2024 09:13:17 -0700
Subject: [PATCH v2 08/10] krb-vs-openssl-workaround

---
 src/include/libpq/libpq-be.h | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h
index 05cb1874c58..3601fba92fc 100644
--- a/src/include/libpq/libpq-be.h
+++ b/src/include/libpq/libpq-be.h
@@ -19,10 +19,6 @@
 #define LIBPQ_BE_H
 
 #include <sys/time.h>
-#ifdef USE_OPENSSL
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#endif
 #include <netinet/tcp.h>
 
 #ifdef ENABLE_GSS
@@ -57,6 +53,17 @@ typedef struct
 #include "libpq/hba.h"
 #include "libpq/pqcomm.h"
 
+/*
+ * These SSL-related #includes must come after all system-provided headers.
+ * This ensures that OpenSSL can take care of conflicts with Windows'
+ * <wincrypt.h> by #undef'ing the conflicting macros.  (We don't directly
+ * include <wincrypt.h>, but some other Windows headers do.) Here <gssapi/gssapi.h>
+ * indirectly inlcudes <wincrypt.h> which cause conflicting macros. 
+ */
+#ifdef USE_OPENSSL
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+#endif
 
 /*
  * GSSAPI specific state information
-- 
2.44.0.279.g3bd955d269

>From 9c46e7f588d2cd7f5d3b3e8c7b2b2b2f69b1b76a Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Mon, 8 Jul 2024 23:19:50 -0700
Subject: [PATCH v2 09/10] wip: meson: reduce linker noise for executables

Author:
Reviewed-by:
Discussion: https://postgr.es/m/
Backpatch:
---
 meson.build             | 3 +++
 src/backend/meson.build | 3 +--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index e4bfd105f4c..fe07f7d67c7 100644
--- a/meson.build
+++ b/meson.build
@@ -100,6 +100,7 @@ ldflags = []
 ldflags_be = []
 ldflags_sl = []
 ldflags_mod = []
+ldflags_exec = []
 
 test_c_args = []
 
@@ -2020,6 +2021,7 @@ if cc.get_id() == 'msvc'
   # modules, we only import them dynamically, and they're also noisy.
   ldflags += '/NOEXP'
   ldflags_mod += '/NOIMPLIB'
+  ldflags_exec += '/NOIMPLIB'
 endif
 
 
@@ -2891,6 +2893,7 @@ default_mod_args = default_lib_args + {
 
 default_bin_args = default_target_args + {
   'install_dir': dir_bin,
+  'link_args': ldflags_exec,
 }
 
 if get_option('rpath')
diff --git a/src/backend/meson.build b/src/backend/meson.build
index 78c57268142..1baad1dabf4 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -129,13 +129,12 @@ postgres = executable('postgres',
   backend_input,
   sources: post_export_backend_sources,
   objects: backend_objs,
-  link_args: backend_link_args,
   link_with: backend_link_with,
   link_depends: backend_link_depends,
   export_dynamic: true,
   implib: 'postgres',
   dependencies: backend_build_deps,
-  kwargs: default_bin_args,
+  kwargs: default_bin_args + {'link_args': backend_link_args},
 )
 
 backend_targets += postgres
-- 
2.44.0.279.g3bd955d269

>From 97ab9f0bb1346559e5a3865d208470ef332c6802 Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Mon, 8 Jul 2024 23:12:15 -0700
Subject: [PATCH v2 10/10] meson: wip: tcl

Author:
Reviewed-by:
Discussion: https://postgr.es/m/
Backpatch:
---
 meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index fe07f7d67c7..cffd571fa3a 100644
--- a/meson.build
+++ b/meson.build
@@ -919,7 +919,8 @@ if not tclopt.disabled()
       dirs: test_lib_d)
   endif
 
-  if not cc.has_header('tcl.h', dependencies: tcl_dep, required: tclopt)
+  if not cc.has_header('tcl.h', dependencies: tcl_dep, required: tclopt,
+      args: test_c_args, include_directories: postgres_inc)
     tcl_dep = not_found_dep
   endif
 endif
-- 
2.44.0.279.g3bd955d269

Reply via email to