-
Notifications
You must be signed in to change notification settings - Fork 10.5k
SILGen tests: always build modules and API notes when importing the mock SDK #4622
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
@jrose-apple Would you mind reviewing? |
@swift-ci Please test |
Build failed |
1ccb7f4
to
ad16044
Compare
@swift-ci Please test |
Build failed |
ad16044
to
c4abeed
Compare
@swift-ci Please clean test |
Build failed |
@swift-ci Please test |
…ock SDK Previously, only test/SILGen/objc_nonnull_lie_hack.swift would build the API notes for the 'gizmo' module. Depending on the order in which tests ran, the module cache would either contain the 'gizmo' module with nullability annotations, or without. If we were unlucky and the module cache was created by a test that did not build the API notes, test/SILGen/objc_nonnull_lie_hack.swift failed. This change also removes 46 instances of '-enable-source-import' (63 more left in the testsuite).
c4abeed
to
80c5cd1
Compare
@swift-ci Please smoke test |
It might be worth it at this point to fix the actual problem: we don't have a way to prepare the mock-SDK overlays beforehand. Building N copies of the overlays is silly and moderately expensive, and using a standard substitution is both including some unnecessary ones and (in some cases) leaving out some necessary ones as well. It doesn't help that the real overlays get used if the mock ones haven't been built. |
While I agree that would be the ultimate fix, this PR is an easy/mechanical change and I have prepared the patch. Are you opposed to landing it as is?
I measured, this change only added 1 second to total testing time on my machine. (Only measured the SilGen directory to cut down the noise.) |
You're right, getting |
These days nullability is not flipping often, so I don't care that much. What prompted me to create this PR is the difference between APINotes for the gizmo module. All tests importing it should see the apinotes, otherwise (as the PR description explains) depending on the run order, we get test failures. |
I agree about that, but that wasn't really the only change. The more I think about it the weirder it seems that The right answer to the API notes problem is to have API notes treated as a dependency for the module, and we should do that anyway. It's just not as straightforward as it should be (the bug has bounced between @DougGregor, @milseman, and me). |
I can add objc_protocols_Bas to the substitution as well, but it was used in only one test so I decided it is not worth the compilation time. If you are saying that |
My problem isn't with the name, it's that I have no idea what it does. Before I would assume it built the overlays equivalent to the real ones, i.e. anything related to the public SDK. (In practice these substitutions build a few things up to Foundation; no AppKit or UIKit and no support modules like Dispatch.) I'm realizing now that that is a shaky assumption as well. I don't want to get into this situation:
The answer might be "if it's used by more than one test", but that's not a very satisfying answer to me. The reason the substitutions were added were partially the repetition, but more because the dependencies of a module aren't obvious from the test. That doesn't apply to leaf modules imported by just the one test. |
@jrose-apple Are you opposed to this PR landing as is? I'm still getting spurious failures in the testsuite locally because of the reasons I explained in the PR description. We even had this on the bots: https://ci.swift.org/job/swift-PR-osx/3518/console |
If we're just looking for a quick fix, we can use a separate module cache for that one test. That shouldn't force the decision here. |
It builds an environment for the SILGen tests. You said:
If
So what would be the ideal solution? That the test source would be somehow scanned for dependencies and everything was automatically built? (But how do you determine build parameters then? Some tests require special parameters, for example, enabling resilience.) |
Discussed in swiftlang#4622. Filed rdar://problem/28313536 to make sure we re-enable it.
@gribozavr @jrose-apple What's the latest on this? I would love to see this get merged in. We really need to get rid of -enable-source-import. |
This is really only coincidentally related to -enable-source-import. The argument was mostly over what needs to be spelled out explicitly and what should be folded into a substitution. It's actually possible that with Doug fixing the issue of API notes not being included as module dependencies (apple/swift-clang@1bc5dd5) that we don't hit the original issue that prompted this whole thing, but that doesn't mean it's not worthwhile to get rid of -enable-source-import. |
@jrose-apple Gentle poke about this PR |
Doesn't deserve to be gentle. :-) Thanks, Slava. |
@jrose-apple What do you want to do about this pull request? |
Build failed |
Build failed |
I now/still believe #20957 is the right answer to this whole mess, but as neither me nor Dmitri are currently working on Swift… I do think it always makes sense to be consistent about API notes for mock modules, but that doesn't need this whole patch. |
Yeah, let's close this. |
Previously, only
test/SILGen/objc_nonnull_lie_hack.swift
would build the API notes for the 'gizmo' module. Depending on the order in which tests ran, the module cache would either contain the 'gizmo' module with nullability annotations, or without. If we were unlucky and the module cache was created by a test that did not build the API notes,test/SILGen/objc_nonnull_lie_hack.swift
failed.This change also removes 46 instances of
-enable-source-import
(63 more left in the testsuite).