Skip to content

Commit eeb6230

Browse files
author
David Ungar
authored
Merge pull request #19321 from davidungar/rdar-44458502-fix-spaces-in-files-in-resp-files-swift-4.2
Fix response file quote bug, add flag for testing, add tests.
2 parents 2dfdbf2 + fa4297a commit eeb6230

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-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: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "swift/Driver/Compilation.h"
2222
#include "swift/Driver/Driver.h"
2323
#include "swift/Driver/Job.h"
24+
#include "swift/Option/Options.h"
2425
#include "llvm/ADT/STLExtras.h"
2526
#include "llvm/ADT/SetVector.h"
2627
#include "llvm/Option/ArgList.h"
@@ -120,9 +121,15 @@ ToolChain::constructJob(const JobAction &JA,
120121

121122
const char *responseFilePath = nullptr;
122123
const char *responseFileArg = nullptr;
123-
if (invocationInfo.allowsResponseFiles &&
124-
!llvm::sys::commandLineFitsWithinSystemLimits(
125-
executablePath, invocationInfo.Arguments)) {
124+
125+
const bool forceResponseFiles =
126+
C.getArgs().hasArg(options::OPT_driver_force_response_files);
127+
assert((invocationInfo.allowsResponseFiles || !forceResponseFiles) &&
128+
"Cannot force response file if platform does not allow it");
129+
130+
if (forceResponseFiles || (invocationInfo.allowsResponseFiles &&
131+
!llvm::sys::commandLineFitsWithinSystemLimits(
132+
executablePath, invocationInfo.Arguments))) {
126133
responseFilePath = context.getTemporaryFilePath("arguments", "resp");
127134
responseFileArg = C.getArgs().MakeArgString(Twine("@") + responseFilePath);
128135
}
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)