From e7bb256c36a003e7252caac6499e116a8655d87d Mon Sep 17 00:00:00 2001 From: RobotLeopard86 <63123751+RobotLeopard86@users.noreply.github.com> Date: Fri, 21 Nov 2025 19:34:20 -0800 Subject: [PATCH] build: Add de-duplication for non-result targets in get_all_link_deps --- mesonbuild/build.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 138f1ae03233..678fe268925f 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1174,20 +1174,23 @@ def get_all_link_deps(self) -> ImmutableListProtocol[BuildTargetTypes]: at link time, see get_dependencies() for that. """ result: OrderedSet[BuildTargetTypes] = OrderedSet() + nonresults: T.Set[BuildTargetTypes] = set() stack: T.Deque[BuildTargetTypes] = deque() stack.appendleft(self) while stack: t = stack.pop() - if t in result: + if t in result or t in nonresults: continue if isinstance(t, CustomTargetIndex): stack.appendleft(t.target) continue if isinstance(t, SharedLibrary): result.add(t) + else: + nonresults.add(t) if isinstance(t, BuildTarget): - stack.extendleft(t.link_targets) - stack.extendleft(t.link_whole_targets) + stack.extendleft((t2 for t2 in t.link_targets if t2 not in nonresults)) + stack.extendleft((t2 for t2 in t.link_whole_targets if t2 not in nonresults)) return list(result) @lru_cache(maxsize=None)