@@ -689,15 +689,32 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
689689 let sparseSDKSearchPaths = GCCCompatibleCompilerSpecSupport . sparseSDKSearchPathArguments ( producer. sparseSDKs, headerSearchPaths. headerSearchPaths, frameworkSearchPaths. frameworkSearchPaths)
690690 commandLine += sparseSDKSearchPaths. searchPathArguments ( for: self , scope: scope)
691691
692+ // Extract arguments to write to the response file, if enabled.
692693 if scope. evaluate ( BuiltinMacros . CLANG_USE_RESPONSE_FILE) && ( optionContext? . toolPath. basenameWithoutSuffix == " clang " || optionContext? . toolPath. basenameWithoutSuffix == " clang++ " ) {
693694 var responseFileCommandLine : [ String ] = [ ]
694695 var regularCommandLine : [ String ] = [ ]
695696
697+ // Filter out select arguments from the response file.
696698 var iterator = commandLine. makeIterator ( )
697699 var previousArg : ByteString ? = nil
698700 while let arg = iterator. next ( ) {
699701 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 " {
701718 // Relevant to indexing, so exclude arg and value from response file.
702719 regularCommandLine. append ( arg)
703720 if let nextArg = iterator. next ( ) {
@@ -713,6 +730,7 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
713730 // Exclude from response file.
714731 regularCommandLine. append ( arg)
715732 } else {
733+ // All other args get added to the response file.
716734 responseFileCommandLine. append ( arg)
717735 }
718736 previousArg = argAsByteString
0 commit comments