Skip to content

Conversation

@pepicrft
Copy link

@pepicrft pepicrft commented Dec 19, 2025

When building projects with many targets using the swiftbuild backend, the process crashes with a stack overflow. The teco project, which has 522 targets, is an example of this.

The lookupMacroDeclaration and lookupConditionParameter methods traverse parent namespaces recursively. With hundreds of nested namespaces, this blows the call stack.

This PR converts those recursive lookups to iterative ones using a while loop, which can handle any depth.

Fixes swiftlang/swift-package-manager#9270

Convert recursive namespace lookups to iteration to prevent stack
overflow when building projects with many targets.
@pepicrft pepicrft force-pushed the fix/macro-namespace-stack-overflow branch from 6496f02 to e237e73 Compare December 19, 2025 21:02
@jakepetroules
Copy link
Collaborator

@swift-ci test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Parity] swift-build crashes with large packages (many targets)

2 participants