-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Index] Apply -index-ignore-system-modules to system clang modules #32024
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
[Index] Apply -index-ignore-system-modules to system clang modules #32024
Conversation
I'd like to add tests, any suggestions? The only current test using |
Ignoring whitespace: https://github.com/apple/swift/pull/32024/files?diff=unified&w=1 |
Yeah adding a new test there makes sense. You need to use -Fsystem to import modules as system modules and should make sure we still list them as dependencies even if we don't output units for them. Something like the below: // RUN: %empty-directory(%t)
// Make a basic clang framework to import
//
// RUN: %empty-directory(%t/MySystemFramework.framework/Headers)
// RUN: %empty-directory(%t/MySystemFramework.framework/Modules)
// RUN: echo 'void someSystemFunc(int arg);' > %t/MySystemFramework.framework/Headers/MySystemFramework.h
// RUN: echo 'framework module MySystemFramework { umbrella header "MySystemFramework.h" export * }' > %t/MySystemFramework.framework/Modules/module.modulemap
import MySystemFramework
someSystemFunc(2)
// Index this file with and without ignoring system frameworks
//
// RUN: %target-swiftc_driver -index-store-path %t/idx1 -o %t/file.o -Fsystem %t -typecheck %s
// RUN: %target-swiftc_driver -index-store-path %t/idx2 -o %t/file.o -index-ignore-system-modules -Fsystem %t -typecheck %s
// RUN: c-index-test core -print-unit %t/idx1 | %FileCheck --check-prefixes=ALLOWSYSTEM,BOTH %s
// RUN: c-index-test core -print-unit %t/idx2 | %FileCheck --check-prefixes=IGNORESYSTEM,BOTH %s
// We should always get a dependency on the system framework in the unit for this file's module.
//
// BOTH: DEPEND START
// BOTH: Unit | system | MySystemFramework |
// BOTH: DEPEND END
// We should get a unit for the system framework if not ignoring them.
//
// ALLOWSYSTEM: provider: clang
// ALLOWSYSTEM-NEXT: is-system: 1
// ALLOWSYSTEM-NEXT: is-module: 1
// ALLOWSYSTEM-NEXT: module-name: MySystemFramework
// But shouldn't if we are.
//
// IGNORESYSTEM-NOT: module-name: MySystemFramework I think that should pass with your changes (it fails in my local build without them), but might need fixes in a few places. |
The test you provided passes with these changes. Nicely written test! |
I named the file with a |
Yeah, "ignore-system-clang-modules" or similar is probably clearer for what it's really doing. |
Renamed. |
@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.
LGTM!
Build failed |
Do I need to squash this PR? Not sure what to make of the failure.
|
No, it's expected. The important bit is just after that:
|
Build failed |
@swift-ci please test OS X Platform |
Build failed |
@swift-ci please test OS X Platform |
Conditionally disable indexing of system clang modules when using
-index-ignore-system-modules
.The
-index-ignore-system-modules
flag currently prevents indexing of system Swift modules. This change expands the behavior to system clang modules too.This change can be beneficial to builds that don't share a global indexstore across all compiles. For example in Bazel, each module can have its own unshared indexstore, and by using
-index-ignore-system-modules
the time and space needed for indexing can be reduced.