-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ParseableInterface] Make the module caches relocatable and respect -track-system-dependencies #23665
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
Conversation
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick read and it looks pretty good. @harlanhaskins should probably take a look too, and I'll get back to it a second time later today.
test/ParseableInterface/ModuleCache/SDKDependencies.swiftinterface
Outdated
Show resolved
Hide resolved
I've come to a conclusion on this: if we compile the prebuilt modules out of order, they will load swiftmodules from the regular module cache, and it would be bad to mark those as dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comment, otherwise this looks great!
03716cb
to
491d11c
Compare
Good point! I've updated the SDKDependencies.swift test to build the prebuilt modules in both orders and check they don't have any FILE_DEPENDENCY entries containing the module cache path in either case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, went through it again and I think it's good! Minor comments only.
d52c19c
to
1e05cff
Compare
@swift-ci please test |
Build failed |
@swift-ci please test OS X Platform |
1 similar comment
@swift-ci please test OS X Platform |
@swift-ci please smoke test OS X Platform |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
// If Dep is itself a .swiftmodule in the cache dir, pull out its deps | ||
// and include them in our own, so we have a single-file view of | ||
// transitive deps: removes redundancies, and avoids opening and reading | ||
// multiple swiftmodules during future loads. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like pulling these in was redundant? I think everything still works because whenever we load/depend on something from the cache we end up adding its serialized dependencies to the dependency tracker when validating that it's up to date, so they show up as one of the initial dependencies here and get serialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't sound right. What if it's out of date and then we rebuild it and discover it doesn't depend on some of those files anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ParseableInterfaceModuleLoaderImpl::dependenciesAreUpToDate()
is called by both forwardingModuleIsUpToDate()
and swiftModuleIsUpDate()
and adds the dependencies to the tracker regardless of whether they are out of date or not, so looks like that's a bug. I'll add a test for it and update the code to only add them to the tracker if they're all up to date.
In the case that they're not up to date though, we then go down the path of generating the swiftmodule from the interface again, and that adds all the SubInstance
's dependencies to the tracker (in collectDepsForSerialization()
). Since all of its dependencies must be either up to date or rebuilt too, I think us pulling out the serialized deps here is redundant regardless. Does that make sense, or am I still missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised that dependenciesAreUpToDate
adds dependencies to the outer tracker at all. That doesn't seem like its job, and that would explain why this code is here. But having it do that does save us a bit of effort in reading from the cached compiled module twice. It at least deserves to be commented loudly, though, since that name sounds like a pure predicate function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, dependenciesAreUpToDate
should probably be renamed here. Good catch noticing that it doesn't check if they actually are up to date 😳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up making it not add the dependencies and added them a few levels up in findOrBuildLoadableModule
and updated it's doc to mention that it adds the dependencies to the dependencyTracker too.
@swift-ci please test |
Build failed |
ff30b30
to
0227614
Compare
@swift-ci please test |
Build failed |
Build failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, only small comments left.
0227614
to
46e5c86
Compare
@swift-ci please test |
Build failed |
Build failed |
One interesting thing here is that the decision of whether or not to track system dependencies ends up going into the cache key for a swiftmodule built from a parseable interface, because it affects that module's up-to-date check. If we didn't include -track-system-dependencies in the cache key, we could end up tracking system dependencies for some modules but not others in the same build. There's a bit of a bug here where they're /not/ honored if the top-level invocation isn't tracking /any/ dependencies, but given how uncommon this flag is in practice that's probably okay for now. Still TODO: honor this for -build-swiftmodule-from-parseable-interface as well. That's currently not tracking dependencies at all and it probably should.
…odule-from-parseable-interface Updates the subinvocation that builds the parseable interface to respect the -track-system-dependencies flag of the top-level invocation if present, by including system dependencies in the produced .swiftmodule.
This allows the SDK to be relocated without automatically resulting in a rebuild. Based on an old patch from Jordan Rose.
…module cache or prebuilt module cache *Their* dependencies are already being serialized out, so this shouldn't affect up-to-date-checking except by alowing the regular and prebuilt module caches to be relocated without invalidating their contents. In the case of the prebuilt module cache, this gets us closer to supporting relocation across machines.
…citly check serialized dependencies Also use the existing check-is-forwarding-module.py script to check for forwarding modules, rather than doing it manually.
… adding cached modules to the dependency tracker This patch modifies ParseableInterfaceBuilder::CollectDepsForSerialization to avoid serializing dependencies from the runtime resource path into the swiftmodules generated from .swiftinterface files. This means the module cache should now be relocatable across machines. It also modifies ParseableInterfaceModuleLoader to never add any dependencies from the module cache and prebuilt cache to the dependency tracker (in addition to the existing behaviour of not serializing them in the generated swiftmodules). As a result, CollectDepsForSerialization no longer checks if the dependencies it is given come from the cache as they are provided by the dependency tracker. It now asserts that's the case instead.
…ent dependency tracker We previously added dependencies to the tracker inline while validating a cached module's dependencies were up to date. If one of its dependencies ended up being out of date though, we shouldn't have added the previous dependencies, as that means the dependency list itself was also out of date. This patch changes the behavior to only add the module's dependencies once we've verified they're all up to date.
46e5c86
to
7144dab
Compare
@swift-ci please smoke test |
This caused a regression in the Windows build! https://dev.azure.com/compnerd/windows-swift/_build/results?buildId=971 |
-track-system-dependencies
when building parseable interfaces on demand-track-system-dependencies
with-build-module-from-parseable-interface
.swiftmodule
dependencies that are from the regular and prebuilt module caches.swiftmodule
s in the regular module cache still get reported to the dependency tracker. Is this what we want?Resolves rdar://problem/49292914