Skip to content

Commit d5528a0

Browse files
author
David Ungar
committed
Fix response file quote bug, add flag for testing, add tests.
1 parent 2dfdbf2 commit d5528a0

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

include/swift/Option/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ def driver_force_one_batch_repartition : Flag<["-"], "driver-force-one-batch-rep
120120
InternalDebugOpt,
121121
HelpText<"Force one batch repartitioning for testing">;
122122

123+
def driver_force_response_files : Flag<["-"], "driver-force-response-files">,
124+
InternalDebugOpt,
125+
HelpText<"Force the use of response files for testing">;
126+
123127
def driver_always_rebuild_dependents :
124128
Flag<["-"], "driver-always-rebuild-dependents">, InternalDebugOpt,
125129
HelpText<"Always rebuild dependents of files that have been modified">;

lib/Driver/Job.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,8 @@ bool Job::writeArgsToResponseFile() const {
425425
return true;
426426
}
427427
for (const char *arg : Arguments) {
428-
OS << "\"";
429428
escapeAndPrintString(OS, arg);
430-
OS << "\" ";
429+
OS << " ";
431430
}
432431
OS.flush();
433432
return false;

lib/Driver/ToolChain.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,15 @@ ToolChain::constructJob(const JobAction &JA,
120120

121121
const char *responseFilePath = nullptr;
122122
const char *responseFileArg = nullptr;
123-
if (invocationInfo.allowsResponseFiles &&
124-
!llvm::sys::commandLineFitsWithinSystemLimits(
125-
executablePath, invocationInfo.Arguments)) {
123+
124+
const bool forceResponseFiles =
125+
C.getArgs().hasArg(options::OPT_driver_force_response_files);
126+
assert((invocationInfo.allowsResponseFiles || !forceResponseFiles) &&
127+
"Cannot force response file if platform does not allow it");
128+
129+
if (forceResponseFiles || (invocationInfo.allowsResponseFiles &&
130+
!llvm::sys::commandLineFitsWithinSystemLimits(
131+
executablePath, invocationInfo.Arguments))) {
126132
responseFilePath = context.getTemporaryFilePath("arguments", "resp");
127133
responseFileArg = C.getArgs().MakeArgString(Twine("@") + responseFilePath);
128134
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Ensure that -driver-force-response-files works.
2+
3+
4+
// RUN: %swiftc_driver -driver-force-response-files -typecheck %S/../Inputs/empty.swift -### 2>&1 | %FileCheck %s
5+
// CHECK: @
6+
// CHECK: .resp
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: touch "%t/f i l e.swift"
3+
//
4+
// RUN: %target-build-swift -driver-force-response-files -parse "%t/f i l e.swift"

0 commit comments

Comments
 (0)