Skip to content

Include toolchain search paths in the build description signature - #1800

Open
cybercussion wants to merge 1 commit into
swiftlang:mainfrom
cybercussion:toolchain-path-in-build-description-signature
Open

cybercussion wants to merge 1 commit into
swiftlang:mainfrom
cybercussion:toolchain-path-in-build-description-signature

Conversation

@cybercussion

Copy link
Copy Markdown

Fixes #1798.

Problem

The Metal Toolchain component is a cryptex mounted at /var/run/com.apple.security.cryptexd/mnt/com.apple.MobileAsset.MetalToolchain-v<version>.<random>, and the random suffix changes on every mount (e.g. after a reboot). SwiftPM passes that mount point to the build service as EXTERNAL_TOOLCHAINS_DIR (SwiftBuildSystem.swift), and tool paths resolved from it (TOOLCHAIN_DIR, the metal compiler) are baked into the build description.

BuildDescriptionSignatureComponents records nothing about where toolchains were found. After a remount the cached description is reused, and the build fails:

error: unable to spawn process '/var/run/com.apple.security.cryptexd/mnt/com.apple.MobileAsset.MetalToolchain-v27.1.266.1.zFisgc/Metal.xctoolchain/usr/bin/metal' (No such file or directory)

(The toolchain was now mounted at …gTiXky, and it works.)

Fix

This follows the pattern of #1792 (sdkInputsSignature):

  • Core.toolchainSearchPathsSignature: the resolved toolchain search paths, including EXTERNAL_TOOLCHAINS_DIR entries.
  • It is included in BuildDescriptionSignatureComponents, so a moved toolchain forces a fresh build description.

Unchanged search paths give an identical signature, so a normal incremental build still reuses its build description.

Testing

  • New CoreTests.toolchainSearchPathsSignatureTracksExternalToolchainMount: the same Metal toolchain under two different mount suffixes gives different signatures, and the same mount gives equal ones.
  • swift test --filter "SWBTaskExecutionTests|SWBCoreTests": 598 tests pass. The 2 known issues were already marked as known (MultiPlatformDependencyResolverTests).
  • Found in real use: a package depending on SwiftTerm (which ships Shaders.metal), on Xcode 27.0 (27A266a), macOS 26.6.2, MetalToolchain v27.1.266.1, swift build failing the morning after a reboot.

🤖 Generated with Claude Code

The Metal Toolchain component is a cryptex mounted under a new random
directory name each time (e.g. after a reboot). SwiftPM passes that mount
point to the build service as EXTERNAL_TOOLCHAINS_DIR, and tool paths
resolved from it (TOOLCHAIN_DIR, the `metal` compiler) are baked into the
build description. Nothing in the build description signature captured
where toolchains were found, so after a remount the cached description was
reused and the build failed with "unable to spawn process
'<old mount>/…/metal' (No such file or directory)".

Add Core.toolchainSearchPathsSignature (the resolved toolchain search
paths, including EXTERNAL_TOOLCHAINS_DIR entries) and include it in
BuildDescriptionSignatureComponents, mirroring sdkInputsSignature (swiftlang#1792),
so a moved toolchain forces a fresh build description.

Fixes swiftlang#1798

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

Cached build plan keeps the Metal Toolchain's old cryptex mount path; swift build fails after a remount/reboot

1 participant