@@ -430,11 +430,6 @@ private func adjustSwiftCompilerArgumentsForIndexStoreUpdate(
430
430
. option( " output-file-map " , [ . singleDash] , [ . separatedBySpace, . separatedByEqualSign] ) ,
431
431
]
432
432
433
- let removeFrontendFlags = [
434
- " -experimental-skip-non-inlinable-function-bodies " ,
435
- " -experimental-skip-all-function-bodies " ,
436
- ]
437
-
438
433
var result : [ String ] = [ ]
439
434
result. reserveCapacity ( compilerArguments. count)
440
435
var iterator = compilerArguments. makeIterator ( )
@@ -448,18 +443,14 @@ private func adjustSwiftCompilerArgumentsForIndexStoreUpdate(
448
443
case nil :
449
444
break
450
445
}
451
- if argument == " -Xfrontend " {
452
- if let nextArgument = iterator. next ( ) {
453
- if removeFrontendFlags. contains ( nextArgument) {
454
- continue
455
- }
456
- result += [ argument, nextArgument]
457
- continue
458
- }
459
- }
460
446
result. append ( argument)
461
447
}
448
+ result += supplementalClangIndexingArgs. flatMap { [ " -Xcc " , $0] }
462
449
result += [
450
+ // Preparation produces modules with errors. We should allow reading them.
451
+ " -Xfrontend " , " -experimental-allow-module-with-compiler-errors " ,
452
+ // Avoid emitting the ABI descriptor, we don't need it
453
+ " -Xfrontend " , " -empty-abi-descriptor " ,
463
454
" -index-file " ,
464
455
" -index-file-path " , fileToIndex. pseudoPath,
465
456
// batch mode is not compatible with -index-file
@@ -520,12 +511,40 @@ private func adjustClangCompilerArgumentsForIndexStoreUpdate(
520
511
}
521
512
result. append ( argument)
522
513
}
514
+ result += supplementalClangIndexingArgs
523
515
result. append (
524
516
" -fsyntax-only "
525
517
)
526
518
return result
527
519
}
528
520
521
+ #if compiler(>=6.1)
522
+ #warning(
523
+ " Remove -fmodules-validate-system-headers from supplementalClangIndexingArgs once all supported Swift compilers have https://github.com/apple/swift/pull/74063 "
524
+ )
525
+ #endif
526
+
527
+ fileprivate let supplementalClangIndexingArgs : [ String ] = [
528
+ // Retain extra information for indexing
529
+ " -fretain-comments-from-system-headers " ,
530
+ // Pick up macro definitions during indexing
531
+ " -Xclang " , " -detailed-preprocessing-record " ,
532
+
533
+ // libclang uses 'raw' module-format. Match it so we can reuse the module cache and PCHs that libclang uses.
534
+ " -Xclang " , " -fmodule-format=raw " ,
535
+
536
+ // Be less strict - we want to continue and typecheck/index as much as possible
537
+ " -Xclang " , " -fallow-pch-with-compiler-errors " ,
538
+ " -Xclang " , " -fallow-pcm-with-compiler-errors " ,
539
+ " -Wno-non-modular-include-in-framework-module " ,
540
+ " -Wno-incomplete-umbrella " ,
541
+
542
+ // sourcekitd adds `-fno-modules-validate-system-headers` before https://github.com/apple/swift/pull/74063.
543
+ // This completely disables system module validation and never re-builds pcm for system modules. The intended behavior
544
+ // is to only re-build those PCMs once per sourcekitd session.
545
+ " -fmodules-validate-system-headers " ,
546
+ ]
547
+
529
548
fileprivate extension Sequence {
530
549
/// Returns `true` if this sequence contains an element that is equal to an element in `otherSequence` when
531
550
/// considering two elements as equal if they satisfy `predicate`.
0 commit comments