From e12e01699f9207130aef3c3e5373881ed071518e Mon Sep 17 00:00:00 2001 From: designgears Date: Tue, 1 Dec 2026 13:53:16 -0700 Subject: [PATCH 1/2] swbuild-events: x86Sim's per-run variables kept out of Swift Build's environment Swift Build keys its build description by the environment too: the wrapper's events file path (and the stand-in's notes path), different on every run, made every build compute a new description and rerun each product's Info.plist, CopySwiftLibs and CodeSign tasks. Without them a second build reuses the description as Xcode's does (a package's next build: PruneExplicitPrecompiledModules only, as Apple's). Co-Authored-By: Claude Opus 5.5 --- swiftbuild/swbuild-events | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/swiftbuild/swbuild-events b/swiftbuild/swbuild-events index 6827b19f..1a4a8dc0 100755 --- a/swiftbuild/swbuild-events +++ b/swiftbuild/swbuild-events @@ -22,6 +22,10 @@ import sys import time +# x86Sim's own variables that change from run to run and that Swift Build and its tools do not read +PER_RUN = ("X86SIM_SWBUILD_EVENTS", "X86SIM_SWBUILD_REAL", "X86SIM_XCODEBUILD_NOTES", "XCODEBUILD_SWBUILD_EVENTS") + + def main(): real = os.environ.get("X86SIM_SWBUILD_REAL") or os.path.join( os.environ.get("XDG_DATA_HOME") or os.path.expanduser("~/.local/share"), @@ -48,6 +52,11 @@ def main(): os.environ["X86SIM_PROVISIONING_REAL"] = os.environ["SWEETPAD_PROVISIONING"] os.environ["SWEETPAD_PROVISIONING"] = prov out = os.environ.get("X86SIM_SWBUILD_EVENTS") + # Swift Build's build description is keyed by its environment, too: a path that differs on every run (this + # wrapper's events file, the stand-in's notes) made every build a new description, with the tasks it reruns + # (Info.plist, CopySwiftLibs, CodeSign of each product) where Xcode's next build reuses its description + for k in PER_RUN: + os.environ.pop(k, None) if not out: os.execv(real, [real] + sys.argv[1:]) p = subprocess.Popen([real] + sys.argv[1:], stdout=subprocess.PIPE) From 3812f7f1fb1df018b52bee89dac14efea83ffb55 Mon Sep 17 00:00:00 2001 From: designgears Date: Tue, 1 Dec 2026 14:21:08 -0700 Subject: [PATCH 2/2] xcodebuild stand-in: packages built with Swift Build by default (XCODEBUILD_PACKAGE_ENGINE=swiftpm: SwiftPM's own build) Measured against Apple's goldens (x86sim tests/xctest-parity, packages from empty derived data on both sides): multi-swt 400 differences (4111 with SwiftPM's build), multi-all 200 (363), multi-sel-swt 137 (310) on iOS. Co-Authored-By: Claude Opus 5.5 --- linux-bin/xcodebuild | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-bin/xcodebuild b/linux-bin/xcodebuild index c1f30c22..3995d2f0 100755 --- a/linux-bin/xcodebuild +++ b/linux-bin/xcodebuild @@ -1674,9 +1674,9 @@ def package_test(a, argv): def package_engine(): - """how a package builds: "swiftbuild" (as Xcode: SwiftPM's package PIF built by Swift Build, swiftbuild/pkgbuild.py) - or "swiftpm" (x86sim test --spm: SwiftPM's own build); $XCODEBUILD_PACKAGE_ENGINE""" - return os.environ.get("XCODEBUILD_PACKAGE_ENGINE", "swiftpm") + """how a package builds: "swiftbuild" (default: as Xcode, SwiftPM's package PIF built by Swift Build, + swiftbuild/pkgbuild.py) or "swiftpm" (x86sim test --spm: SwiftPM's own build); $XCODEBUILD_PACKAGE_ENGINE""" + return os.environ.get("XCODEBUILD_PACKAGE_ENGINE", "swiftbuild") def package_swiftbuild(a, name, x, phones):