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
4 changes: 4 additions & 0 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ def driver_force_one_batch_repartition : Flag<["-"], "driver-force-one-batch-rep
InternalDebugOpt,
HelpText<"Force one batch repartitioning for testing">;

def driver_force_response_files : Flag<["-"], "driver-force-response-files">,
InternalDebugOpt,
HelpText<"Force the use of response files for testing">;

def driver_always_rebuild_dependents :
Flag<["-"], "driver-always-rebuild-dependents">, InternalDebugOpt,
HelpText<"Always rebuild dependents of files that have been modified">;
Expand Down
3 changes: 1 addition & 2 deletions lib/Driver/Job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,8 @@ bool Job::writeArgsToResponseFile() const {
return true;
}
for (const char *arg : Arguments) {
OS << "\"";
escapeAndPrintString(OS, arg);
OS << "\" ";
OS << " ";
}
OS.flush();
return false;
Expand Down
13 changes: 10 additions & 3 deletions lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "swift/Driver/Compilation.h"
#include "swift/Driver/Driver.h"
#include "swift/Driver/Job.h"
#include "swift/Option/Options.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Option/ArgList.h"
Expand Down Expand Up @@ -116,9 +117,15 @@ std::unique_ptr<Job> ToolChain::constructJob(

const char *responseFilePath = nullptr;
const char *responseFileArg = nullptr;
if (invocationInfo.allowsResponseFiles &&
!llvm::sys::commandLineFitsWithinSystemLimits(
executablePath, invocationInfo.Arguments)) {

const bool forceResponseFiles =
C.getArgs().hasArg(options::OPT_driver_force_response_files);
assert((invocationInfo.allowsResponseFiles || !forceResponseFiles) &&
"Cannot force response file if platform does not allow it");

if (forceResponseFiles || (invocationInfo.allowsResponseFiles &&
!llvm::sys::commandLineFitsWithinSystemLimits(
executablePath, invocationInfo.Arguments))) {
responseFilePath = context.getTemporaryFilePath("arguments", "resp");
responseFileArg = C.getArgs().MakeArgString(Twine("@") + responseFilePath);
}
Expand Down
6 changes: 6 additions & 0 deletions test/Driver/force-response-files.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Ensure that -driver-force-response-files works.


// RUN: %swiftc_driver -driver-force-response-files -typecheck %S/../Inputs/empty.swift -### 2>&1 | %FileCheck %s
// CHECK: @
// CHECK: .resp
4 changes: 4 additions & 0 deletions test/Driver/response-files-with-spaces-in-filenames.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// RUN: %empty-directory(%t)
// RUN: touch "%t/f i l e.swift"
//
// RUN: %target-build-swift -driver-force-response-files -parse "%t/f i l e.swift"