Skip to content

[Preview] Fix preview support for swift caching build #562

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cachemeifyoucan
Copy link
Contributor

@cachemeifyoucan cachemeifyoucan commented Jun 5, 2025

Add support for swift caching build when swift compiler supports the new option that allows swift compiler performs an uncached build but loading module dependencies from CAS.

It also does few adjustment to make sure preview build shares the same dependencies with regular build as caching build has a stricter rule for invalidation:

  • The VFS overlay used by preview is applied after swift driver invocation and onto the frontend invocation directly. This makes sure the VFS overlay doesn't invalidate all the module dependencies.
  • BridgingHeader PCH was disabled as a workaround when swift driver doesn't produce deterministic output path when planning for PCH jobs. Properly fix this issue by requesting the same path when planning both build and don't use this workaround in certain configurations.

This should allow preview to build thunk correctly when swift caching is enabled for the regular build.

rdar://152107465

@cachemeifyoucan
Copy link
Contributor Author

This uses the flag introduced here: swiftlang/swift#81990

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please test

Add support for swift caching build when swift compiler supports the new
option that allows swift compiler performs an uncached build but loading
module dependencies from CAS.

It also does few adjustment to make sure preview build shares the same
dependencies with regular build as caching build has a stricter rule for
invalidation:

* The VFS overlay used by preview is applied after swift driver
  invocation and onto the frontend invocation directly. This makes sure
  the VFS overlay doesn't invalidate all the module dependencies.
* BridgingHeader PCH was disabled as a workaround when swift driver
  doesn't produce deterministic output path when planning for PCH jobs.
  Properly fix this issue by requesting the same path when planning both
  build and don't use this workaround in certain configurations.

This should allow preview to build thunk correctly when swift caching is
enabled for the regular build.

rdar://152107465
@cachemeifyoucan
Copy link
Contributor Author

Re-request review after properly fixed the bridging header PCH path mismatch.

@swift-ci please test

@@ -3397,10 +3401,12 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
removeWithParameter(arg)
}

// We need to ignore precompiled headers due to:
// For some old version of swift driver, the output path for bridging header pch is not stable,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any compatibility requirement for older swift-driver? If we only need to support recent swift-driver, this workaround can be removed to make preview build faster

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally speaking I try not to immediately break compatibility with old drivers to minimize revlock when building the package for local development. But supporting a driver that's more than a few weeks old is a non-goal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change in swift-driver I am talking about is: swiftlang/swift-driver#1832

It has been few months but not in official release yet.

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please test

@owenv
Copy link
Collaborator

owenv commented Jun 6, 2025

The latest changes seem reasonable to me

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.

2 participants