From 9c46e7f588d2cd7f5d3b3e8c7b2b2b2f69b1b76a Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@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

