Skip to content

Run the Makefile's SwiftPM bin path lookup once per make process - #2349

Open
deadcaf3 wants to merge 1 commit into
apple:mainfrom
deadcaf3:fix/makefile-slowdown
Open

deadcaf3 wants to merge 1 commit into
apple:mainfrom
deadcaf3:fix/makefile-slowdown

Conversation

@deadcaf3

@deadcaf3 deadcaf3 commented Oct 4, 2026

Copy link
Copy Markdown

Type of Change

  • Bug fix

Motivation and Context

Fixes #2346.

BUILD_BIN_DIR was a recursive variable around $(shell swift build --show-bin-path), so every reference started SwiftPM again: 20 times for make all, about 12 s. It is now defined with :=, so each make process looks the path up once.

This is the line #221 changed from := to = because BUILD_CONFIGURATION changes during make release. Going back is safe for the current Makefile: the recipes that use the path under release run in the sub-make, which is started with BUILD_CONFIGURATION=release and resolves the release path when it parses the Makefile. STAGING_DIR, PKG_PATH and DSYM_DIR already rely on that.

One difference from =: a recipe that reads $(BUILD_BIN_DIR) in the top-level make under release would get the debug path. No target does that today, and none did when #221 landed: make -n release uses the release path both at #221 and at its parent commit.

Testing

  • Tested locally

  • make -n output for all, release, cli, dsym and coverage is byte-identical before and after. All 8 bin paths in make -n release stay under .build/out/Products/Release.

  • SwiftPM lookups in make -n all go from 20 to 2 (one per make process); coverage from 32 to 3; fmt and clean from 6 to 1.

  • time make -n all: 12.15 s, 11.98 s and 11.46 s before; 1.30 s, 1.37 s and 1.26 s after.

  • make all and make test pass.

GNU Make 3.81, macOS 26.6.2, Xcode 27.0.

This branch has not been deployed

No deployments
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.

[Bug]: Makefile re-runs swift build --show-bin-path on every $(BUILD_BIN_DIR) reference (20 times for make all)

1 participant