@@ -689,15 +689,32 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
689
689
let sparseSDKSearchPaths = GCCCompatibleCompilerSpecSupport . sparseSDKSearchPathArguments ( producer. sparseSDKs, headerSearchPaths. headerSearchPaths, frameworkSearchPaths. frameworkSearchPaths)
690
690
commandLine += sparseSDKSearchPaths. searchPathArguments ( for: self , scope: scope)
691
691
692
+ // Extract arguments to write to the response file, if enabled.
692
693
if scope. evaluate ( BuiltinMacros . CLANG_USE_RESPONSE_FILE) && ( optionContext? . toolPath. basenameWithoutSuffix == " clang " || optionContext? . toolPath. basenameWithoutSuffix == " clang++ " ) {
693
694
var responseFileCommandLine : [ String ] = [ ]
694
695
var regularCommandLine : [ String ] = [ ]
695
696
697
+ // Filter out select arguments from the response file.
696
698
var iterator = commandLine. makeIterator ( )
697
699
var previousArg : ByteString ? = nil
698
700
while let arg = iterator. next ( ) {
699
701
let argAsByteString = ByteString ( encodingAsUTF8: arg)
700
- if ClangSourceFileIndexingInfo . skippedArgsWithValues. contains ( argAsByteString) || arg == " -include " {
702
+ if arg == " -target " {
703
+ // Exclude -target from the response file to make reading the build log easier.
704
+ regularCommandLine. append ( arg)
705
+ if let nextArg = iterator. next ( ) {
706
+ regularCommandLine. append ( nextArg)
707
+ }
708
+ }
709
+ else if arg == " -isysroot " || arg == " --sysroot " {
710
+ // Exclude the options to pass the path to the base SDK from the response file to make reading the build log easier.
711
+ // Sparse SDK options do not get similar treatment since they are passed as normal search paths.
712
+ regularCommandLine. append ( arg)
713
+ if let nextArg = iterator. next ( ) {
714
+ regularCommandLine. append ( nextArg)
715
+ }
716
+ }
717
+ else if ClangSourceFileIndexingInfo . skippedArgsWithValues. contains ( argAsByteString) || arg == " -include " {
701
718
// Relevant to indexing, so exclude arg and value from response file.
702
719
regularCommandLine. append ( arg)
703
720
if let nextArg = iterator. next ( ) {
@@ -713,6 +730,7 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
713
730
// Exclude from response file.
714
731
regularCommandLine. append ( arg)
715
732
} else {
733
+ // All other args get added to the response file.
716
734
responseFileCommandLine. append ( arg)
717
735
}
718
736
previousArg = argAsByteString
0 commit comments