Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify swift-bootstrap with swift-build and swift-test #8153

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

MaxDesiatov
Copy link
Contributor

@MaxDesiatov MaxDesiatov commented Dec 3, 2024

Motivation:

Existing code in swift-bootstrap mostly follows swift-build/swift-test in an ad-hoc manner, but somewhat deviates from that swift-test such that environmental builds are not possible with the current setup. Let's unify this code to avoid the divergence and make maintenance easier.

This is a prerequisite for enabling incremental builds when running ./Utillities/bootstrap build --release and ./Utilities/bootstrap test --release in sequence.

Modifications:

  1. Moved required APIs like AsyncSwiftCommand extensions from Commands to CoreCommands.
  2. Added a dependency on CoreCommands to swift-bootstrap.
  3. Converted swift-bootstrap from top-level code to @main.
  4. Renamed SwiftBoostrapBuildTool to SwiftBootstrapCommand for consistency with other commands.
  5. Added AsyncSwiftCommand conformance to SwiftBootstrapCommand.
  6. Added a trivial but sufficient func run(_: SwiftCommandState) implementation to SwiftBootstrapCommand.
  7. Removed old code that became unused.

Result:

Made swift-bootstrap behavior more consistent and predictable, ~450 LoC removed.

This is a prerequisite for enabling incremental builds when running `./Utillities/bootstrap build --release` and `./Utilities/bootstrap test --release` in sequence.
@MaxDesiatov MaxDesiatov added enhancement bootstrap Bootstrapping script & swift-bootstrap labels Dec 3, 2024
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test linux

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@dschaefer2
Copy link
Member

Mind you, I find the title funny. swift-build and swift-test aren't necessary consistent with each other. But that's a separate issue :).

@MaxDesiatov
Copy link
Contributor Author

Certainly more consistent with each other WRT incremental builds than either of them is with swift-bootstrap.

@neonichu
Copy link
Contributor

neonichu commented Dec 9, 2024

Note that the point of swift-bootstrap was to only require a minimal set of modules and dependencies for bootstrapping. It will transitively depend on Workspace (i.e. "everything") with this change, so I'd recommend to just use swift-build for bootstrapping at that point.

@dschaefer2
Copy link
Member

Note that the point of swift-bootstrap was to only require a minimal set of modules and dependencies for bootstrapping. It will transitively depend on Workspace (i.e. "everything") with this change, so I'd recommend to just use swift-build for bootstrapping at that point.

Yeah, I guess I've haven't quite figured out what the bootstrap was supposed to be for. If it's doing a build, wouldn't you need the Workspace, and then yeah, why not just use swift-build?

@MaxDesiatov
Copy link
Contributor Author

MaxDesiatov commented Dec 10, 2024

If it's doing a build, wouldn't you need the Workspace

You wouldn't, a build system can be created without a Workspace.

and then yeah, why not just use swift-build?

swift build pulls in too much stuff, like package registries code and swift-crypto, which causes the current build issues on CI. Those are apparently due to wrong BoringSSL or swift-crypto libraries, maybe coming from the host instead of freshly built ones, IDK.

I'm going to refactor the PR to allow using SwiftCommandState (or a subset of it) without needing a Workspace, but still preserve the rest of swift-build logic and SwiftCommandState logic of build parameters preparation, which is apparently what breaks incremental builds in the first place.

@MaxDesiatov MaxDesiatov marked this pull request as draft December 10, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bootstrap Bootstrapping script & swift-bootstrap enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants