Skip to content

Add AsyncBuildOperation alternative to BuildOperation - #7367

Closed
MaxDesiatov wants to merge 24 commits into
mainfrom
maxd/async-build-operation
Closed

MaxDesiatov wants to merge 24 commits into
mainfrom
maxd/async-build-operation

Conversation

@MaxDesiatov

@MaxDesiatov MaxDesiatov commented Feb 24, 2024

Copy link
Copy Markdown
Contributor

Depends on #7365.

For now this is mostly a copy of BuildOperation, but with async entrypoints. This can be expanded to use more structured concurrency features in the future as we migrate more code. It is disabled by default, for testing purposes I'm exposing it as swift build --build-system experimental-async, which creates and uses AsyncBuildOperation instead of blocking synchronous BuildOperation.

These details should not leak outside of the SwiftPM package. In the (hopefully temporary) absence of `package` access control, we can hide build system-related APIs with `@_spi` annotations.
@MaxDesiatov MaxDesiatov added concurrency build system Changes to interactions with build systems swift build Changes impacting `swift build` labels Feb 24, 2024
For now this is mostly a copy of `BuildOperation`, but with `async` entrypoints. This can be expanded to use more structured concurrency features in the future as we migrate more code. It is disabled by default, for testing purposes I'm exposing it as `swift build --experimental-async-build-system`, which creates and uses `AsyncBuildOperation` instead of blocking synchronous `BuildOperation`.
@MaxDesiatov
MaxDesiatov force-pushed the maxd/async-build-operation branch from d081d46 to ea9e940 Compare February 24, 2024 17:32
@MaxDesiatov
MaxDesiatov changed the base branch from maxd/spi-build-system to main February 24, 2024 17:32
@MaxDesiatov

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@MaxDesiatov MaxDesiatov self-assigned this Feb 24, 2024
Due to a bug in Swift 5.9, we can't have multiple executables with `async` entrypoints linked into test products. This was the reason why we weren't able to make `swift-build` entrypoint `async`. Since we have a single `swift-package-manager` executable anyway, we can link that one into tests instead, and pass "simulated" executable name via an environment variable. This allows us to work around the bug and start using structured concurrency from `swift-build` entrypoint.
…xd/async-swift-build

# Conflicts:
#	Sources/Commands/SwiftBuildCommand.swift
#	Sources/swift-build/Entrypoint.swift
#	Sources/swift-package-manager/SwiftPM.swift
…ge-manager into maxd/async-build-operation

# Conflicts:
#	Sources/Commands/SwiftBuildCommand.swift
#	Sources/swift-build/Entrypoint.swift
#	Sources/swift-package-manager/SwiftPM.swift
@MaxDesiatov

Copy link
Copy Markdown
Contributor Author

@swift-ci test

…xd/spi-build-system

# Conflicts:
#	Sources/Commands/SwiftBuildCommand.swift
#	Sources/Commands/SwiftRunCommand.swift
#	Sources/Commands/SwiftTestCommand.swift
#	Sources/CoreCommands/BuildSystemSupport.swift
#	Sources/CoreCommands/SwiftCommandState.swift
#	Sources/swift-package-manager/SwiftPM.swift
@MaxDesiatov

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@MaxDesiatov

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@MaxDesiatov

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@MaxDesiatov

Copy link
Copy Markdown
Contributor Author

@swift-ci test windows

MaxDesiatov added a commit that referenced this pull request Feb 26, 2024
Due to a bug in Swift 5.9, we can't have multiple executables with
`async` entrypoints linked into test products. This was the reason why
we weren't able to make `swift-build` entrypoint `async`. Since we have
a single `swift-package-manager` executable anyway, we can link that one
into tests instead, and pass "simulated" executable name via an
environment variable. This allows us to work around the bug and start
using structured concurrency from `swift-build` entrypoint.

This change is a prerequisite for
#7367.
…xd/async-build-operation

# Conflicts:
#	Sources/swift-build/Entrypoint.swift
#	Sources/swift-build/main.swift
#	Sources/swift-run/Entrypoint.swift
@MaxDesiatov

Copy link
Copy Markdown
Contributor Author

@swift-ci test

…xd/spi-build-system

# Conflicts:
#	Sources/Commands/SwiftBuildCommand.swift
#	Sources/Commands/SwiftRunCommand.swift
Comment thread Sources/swift-build/CMakeLists.txt Outdated
@MaxDesiatov MaxDesiatov added the WIP Work in progress label Feb 27, 2024
@MaxDesiatov
MaxDesiatov marked this pull request as draft February 27, 2024 11:32
@MaxDesiatov

Copy link
Copy Markdown
Contributor Author

Marking as draft, it's currently not possible to fully implement due to BuildSystemDelegate protocol of llbuild not supporting async.

@MaxDesiatov
MaxDesiatov deleted the maxd/async-build-operation branch April 11, 2024 00:41
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
Due to a bug in Swift 5.9, we can't have multiple executables with
`async` entrypoints linked into test products. This was the reason why
we weren't able to make `swift-build` entrypoint `async`. Since we have
a single `swift-package-manager` executable anyway, we can link that one
into tests instead, and pass "simulated" executable name via an
environment variable. This allows us to work around the bug and start
using structured concurrency from `swift-build` entrypoint.

This change is a prerequisite for
swiftlang#7367.
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
Due to a bug in Swift 5.9, we can't have multiple executables with
`async` entrypoints linked into test products. This was the reason why
we weren't able to make `swift-build` entrypoint `async`. Since we have
a single `swift-package-manager` executable anyway, we can link that one
into tests instead, and pass "simulated" executable name via an
environment variable. This allows us to work around the bug and start
using structured concurrency from `swift-build` entrypoint.

This change is a prerequisite for
swiftlang#7367.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build system Changes to interactions with build systems concurrency swift build Changes impacting `swift build` WIP Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant