From 8305666db7570a530105d846bab3e3da428ecb62 Mon Sep 17 00:00:00 2001
From: Mohamed Akram <mohd.akram@outlook.com>
Date: Sun, 26 Apr 2026 12:51:27 +0400
Subject: [PATCH] build: fix install name when using link_whole

---
 mesonbuild/build.py                                      | 2 +-
 test cases/darwin/1 rpath removal on install/meson.build | 5 +++++
 unittests/darwintests.py                                 | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 7cc2dc092000..703feba80b9f 100644
--- mesonbuild/build.py
+++ mesonbuild/build.py
@@ -1331,7 +1331,7 @@ def get_link_deps_mapping(self, prefix: str) -> T.Mapping[str, str]:
     @lru_cache(maxsize=None)
     def get_transitive_link_deps_mapping(self, prefix: str) -> T.Mapping[str, str]:
         result: T.Dict[str, str] = {}
-        for i in self.link_targets:
+        for i in itertools.chain(self.link_targets, self.link_whole_targets):
             mapping = i.get_link_deps_mapping(prefix)
             #we are merging two dictionaries, while keeping the earlier one dominant
             result_tmp = mapping.copy()
diff --git a/test cases/darwin/1 rpath removal on install/meson.build b/test cases/darwin/1 rpath removal on install/meson.build
index 5ce4c722a42a..512701e46e6d 100644
--- test cases/darwin/1 rpath removal on install/meson.build	
+++ test cases/darwin/1 rpath removal on install/meson.build	
@@ -15,3 +15,8 @@ main = executable('main', 'main.c',
   link_with: bar_internal,
   install: true,
 )
+
+main_whole = executable('main-whole', 'main.c',
+  link_whole: bar_internal,
+  install: true,
+)
diff --git a/unittests/darwintests.py b/unittests/darwintests.py
index fe292dd5cc1f..7b31168538e9 100644
--- unittests/darwintests.py
+++ unittests/darwintests.py
@@ -182,6 +182,8 @@ def test_darwin_meson_rpaths_removed_on_install(self):
         self.assertListEqual(rpaths, [])
         libs = self._get_darwin_rpath_libraries(os.path.join(self.installdir, 'usr/bin/main'))
         self.assertListEqual(libs, [])
+        libs = self._get_darwin_rpath_libraries(os.path.join(self.installdir, 'usr/bin/main-whole'))
+        self.assertListEqual(libs, [])
 
     @skip_if_not_language('rust')
     def test_rust_apple_framework_rlib(self):
