Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Sources/SWBCore/SpecImplementations/Tools/CCompiler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -689,15 +689,32 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
let sparseSDKSearchPaths = GCCCompatibleCompilerSpecSupport.sparseSDKSearchPathArguments(producer.sparseSDKs, headerSearchPaths.headerSearchPaths, frameworkSearchPaths.frameworkSearchPaths)
commandLine += sparseSDKSearchPaths.searchPathArguments(for: self, scope: scope)

// Extract arguments to write to the response file, if enabled.
if scope.evaluate(BuiltinMacros.CLANG_USE_RESPONSE_FILE) && (optionContext?.toolPath.basenameWithoutSuffix == "clang" || optionContext?.toolPath.basenameWithoutSuffix == "clang++") {
var responseFileCommandLine: [String] = []
var regularCommandLine: [String] = []

// Filter out select arguments from the response file.
var iterator = commandLine.makeIterator()
var previousArg: ByteString? = nil
while let arg = iterator.next() {
let argAsByteString = ByteString(encodingAsUTF8: arg)
if ClangSourceFileIndexingInfo.skippedArgsWithValues.contains(argAsByteString) || arg == "-include" {
if arg == "-target" {
// Exclude -target from the response file to make reading the build log easier.
regularCommandLine.append(arg)
if let nextArg = iterator.next() {
regularCommandLine.append(nextArg)
}
}
else if arg == "-isysroot" || arg == "--sysroot" {
// Exclude the options to pass the path to the base SDK from the response file to make reading the build log easier.
// Sparse SDK options do not get similar treatment since they are passed as normal search paths.
regularCommandLine.append(arg)
if let nextArg = iterator.next() {
regularCommandLine.append(nextArg)
}
}
else if ClangSourceFileIndexingInfo.skippedArgsWithValues.contains(argAsByteString) || arg == "-include" {
// Relevant to indexing, so exclude arg and value from response file.
regularCommandLine.append(arg)
if let nextArg = iterator.next() {
Expand All @@ -713,6 +730,7 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
// Exclude from response file.
regularCommandLine.append(arg)
} else {
// All other args get added to the response file.
responseFileCommandLine.append(arg)
}
previousArg = argAsByteString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ fileprivate struct ClangResponseFileTaskConstructionTests: CoreBasedTests {

// The command arguments in the response file vary vastly between different platforms, so just check for some basics present in the content.
let contentAsString = contents.asString
#expect(contentAsString.contains("-target "))
#expect(contentAsString.contains("Test-generated-files.hmap"))
#expect(contentAsString.contains("Test-own-target-headers.hmap"))
#expect(contentAsString.contains("Test-all-target-headers.hmap"))
Expand Down
Loading