Skip to content

Commit 48df948

Browse files
committed
Update: Overriding COMPILER_INDEX_STORE_ENABLE to NO for non-Apple Clangs
1 parent b4367d0 commit 48df948

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

Sources/SWBCore/SpecImplementations/Tools/CCompiler.swift

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,15 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
612612
var commandLine = Array<String>()
613613

614614
// Add the arguments from the specification.
615-
commandLine += self.commandLineFromOptions(producer, scope: scope, inputFileType: inputFileType, optionContext: optionContext).map(\.asString)
615+
commandLine += self.commandLineFromOptions(producer, scope: scope, inputFileType: inputFileType, optionContext: optionContext,lookup: { declaration in
616+
if declaration.name == "CLANG_INDEX_STORE_ENABLE" && optionContext is DiscoveredClangToolSpecInfo {
617+
let clangToolInfo = optionContext as! DiscoveredClangToolSpecInfo
618+
if !clangToolInfo.isAppleClang {
619+
return BuiltinMacros.namespace.parseString("NO")
620+
}
621+
}
622+
return nil
623+
}).map(\.asString)
616624

617625
// Add the common header search paths.
618626
let headerSearchPaths = GCCCompatibleCompilerSpecSupport.headerSearchPathArguments(producer, scope, usesModules: scope.evaluate(BuiltinMacros.CLANG_ENABLE_MODULES))
@@ -653,19 +661,6 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
653661
let sparseSDKSearchPaths = GCCCompatibleCompilerSpecSupport.sparseSDKSearchPathArguments(producer.sparseSDKs, headerSearchPaths.headerSearchPaths, frameworkSearchPaths.frameworkSearchPaths)
654662
commandLine += sparseSDKSearchPaths.searchPathArguments(for: self, scope: scope)
655663

656-
if let clangInfo = optionContext as? DiscoveredClangToolSpecInfo, !clangInfo.isAppleClang {
657-
var filteredCommandLine: [String] = []
658-
var iterator = commandLine.makeIterator()
659-
while let arg = iterator.next() {
660-
if arg == "-index-store-path" {
661-
_ = iterator.next()
662-
} else {
663-
filteredCommandLine.append(arg)
664-
}
665-
}
666-
commandLine = filteredCommandLine
667-
}
668-
669664
if scope.evaluate(BuiltinMacros.CLANG_USE_RESPONSE_FILE) && (optionContext?.toolPath.basenameWithoutSuffix == "clang" || optionContext?.toolPath.basenameWithoutSuffix == "clang++") {
670665
var responseFileCommandLine: [String] = []
671666
var regularCommandLine: [String] = []

0 commit comments

Comments
 (0)