Repository navigation
Make the CMake build suitable for toolchain builds - #376
Merged
Merged
Conversation
Contributor
Author
|
Windows failure is addressed by #377 |
iCharlesHu
approved these changes
Oct 5, 2026
- Only require swift-system (SystemPackage) on non-Apple platforms. Apple platforms use the System framework, so the configure step no longer looks for, or vendors, swift-system there. - Add Subprocess_VENDOR_DEPENDENCIES (default ON). When swift-system is not found it is only fetched if this is enabled; otherwise configuration fails with a clear diagnostic. An explicitly provided SwiftSystem_DIR that does not contain swift-system is always an error, never a silent download. - Bump the vendored swift-system pin to 1.5.0 to match Package.swift. - Link SystemPackage PUBLIC, since its types are part of the public API, and have SwiftSubprocessConfig.cmake locate SwiftSystem (find_dependency) so clients only need SwiftSubprocess_DIR. - Add Subprocess_ENABLE_FOUNDATION (default ON), which defines the SubprocessFoundation trait like SwiftPM's default traits, so CMake and SwiftPM builds expose the same API. A Foundation package found via Foundation_DIR is linked on non-Apple platforms; otherwise the toolchain or SDK provides FoundationEssentials. - Build with the same language mode and upcoming features as Package.swift (Swift 6, NonisolatedNonsendingByDefault, ExistentialAny, MemberImportVisibility, InternalImportsByDefault). The SubprocessFoundation sources rely on InternalImportsByDefault.
Apple platforms use the System framework (`#if canImport(System)`), so SystemPackage does not need to be built or linked there.
…w 26 `Span.bytes` is only available on macOS 26 in the Swift 6.2 standard library (later SDKs back-deploy it). Build the RawSpan from `withUnsafeBytes`, as is already done for Array.
…ets below 26" This reverts commit 06efa67.
jakepetroules
force-pushed
the
jake-petroules/cmake
branch
from
October 5, 2026 21:52
962d605 to
9da1e16
Compare
Contributor
Author
|
@swift-ci build toolchain linux |
Contributor
Author
|
@swift-ci build toolchain macos |
Contributor
Author
|
@swift-ci build toolchain windows |
Contributor
Author
|
@swift-ci build windows toolchain |
Contributor
Author
|
@swift-ci Please Build Toolchain Windows Platform |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes swift-subprocess's CMake build work as part of a Swift toolchain build. swift-build needs this before it can adopt Subprocess (swiftlang/swift-build#638).
On macOS, swift-build's
cmake-smoke-testjob currently fails while configuring swift-subprocess. It prints-- Vendoring swift-systemand then tries togit cloneswift-system without network access. Apple platforms never use swift-system, though: they use the System framework.Changes
1. Only require swift-system on non-Apple platforms
SwiftSystem::SystemPackagewhenNOT APPLE.SystemPackageproduct dependency now has a condition: Linux, Windows, Android, WASI, OpenBSD and FreeBSD. This applies to the Subprocess target and both test targets, which all use the#if canImport(System)pattern. SwiftPM no longer builds SystemPackage on macOS.2. No silent network fetches
Subprocess_VENDOR_DEPENDENCIES, defaultON.OFF, configuration fails with a message explaining how to setSwiftSystem_DIR.SwiftSystem_DIRthat doesn't contain swift-system is always an error, even with vendoring on. A wrong path never turns into a silent download.61e4ca4b…), matchingfrom: "1.5.0"in Package.swift.ON: it keeps standalonecmake -B buildworking, and this repo's Linux CMake CI job relies on that. Toolchain builds don't depend on the default:SwiftSystem_DIR.-DSubprocess_VENDOR_DEPENDENCIES=OFFto fail loudly.3. SystemPackage is part of the public interface
PUBLICon non-Apple platforms, becauseFilePath,FileDescriptorand other SystemPackage types appear in the public API (public import SystemPackage).SwiftSubprocessConfig.cmakenow locates SwiftSystem itself withfind_dependency. The hint points at the swift-system Subprocess was built against, and a client'sSwiftSystem_DIRtakes precedence. Previously, a client had to defineSwiftSystem::SystemPackagebefore callingfind_package(SwiftSubprocess), or generation failed.4. Enable the SubprocessFoundation trait in CMake builds
Subprocess_ENABLE_FOUNDATION, defaultON, which definesSubprocessFoundation. CMake and SwiftPM builds of the same toolchain now expose the same API (Data input/output,Data(buffer:), etc.).Foundation_DIRis linked, following swift-tools-support-core. Otherwise FoundationEssentials comes from the toolchain or SDK, which is how build.ps1 builds Subprocess today.NonisolatedNonsendingByDefault,ExistentialAny,MemberImportVisibilityandInternalImportsByDefault. The SubprocessFoundation sources needInternalImportsByDefaultto compile. Reviewer note:NonisolatedNonsendingByDefaultchanges runtime behaviour compared with earlier CMake builds; it now matches SwiftPM builds.Settings for downstream projects such as swift-build
When building swift-subprocess:
-DSwiftSystem_DIR=<swift-system build>/cmake/modulesand, recommended in CI,-DSubprocess_VENDOR_DEPENDENCIES=OFFWhen building the consumer:
-DSwiftSubprocess_DIR=<swift-subprocess build>/cmake/modules-DSwiftSystem_DIR=…. The package config finds swift-system without it, but passing it is clearer.Testing
SwiftSystem_DIR, network blocked, targeting macOS 13:_depsdirectory.DataOutputsymbols are present.SwiftSystem_DIRand vendoring off, static and shared. Nothing was vendored, andDataOutputis in.aand.so.SwiftSystem_DIR, and a wrongSwiftSystem_DIR, both fail with a clear message and fetch nothing.Subprocess_ENABLE_FOUNDATION=OFFbuilds and omitsDataOutput.find_package(SwiftSubprocess), linksSwiftSubprocess::Subprocess, imports Subprocess, and runs a process with.data(limit:)output and aFilePathexecutable. It works on macOS and Linux, static and shared. On Linux it also works with onlySwiftSubprocess_DIRset.swift build/swift teston macOS: pass (171 tests) with an SDK newer than Xcode 26.0; see "Known issue" below.swift build --target Subprocesspasses, and SystemPackage is still built and linked.Not verified locally
swift test: couldn't run. My container hit aFileManagercopy failure on test resources; this looks environmental. CI covers it.Foundation_DIR: untested.Known issue, not addressed here:
Span.byteswith the Swift 6.2 SDKThis PR doesn't change it; the affected code is identical to
main. With the Xcode 26.0 / Swift 6.2 SDK, building for a macOS deployment target below 26 fails:CMAKE_OSX_DEPLOYMENT_TARGETto swiftc).The cause: in the Swift 6.2 SDK,
Span<BitwiseCopyable>.bytesis@available(macOS 26.0)and not@_alwaysEmitIntoClient. Newer SDKs declare it back-deployable to macOS 10.14.4 and inline it into callers.Possible fixes, for a follow-up:
withUnsafeBytes+RawSpan(_unsafeBytes:)), asArray._bytesalready does;