Skip to content

Commit e44d8a9

Browse files
author
David Ungar
committed
Add -driver-force-response-files to enable testing.
1 parent 56e47cc commit e44d8a9

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
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/ToolChain.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,15 @@ std::unique_ptr<Job> ToolChain::constructJob(
116116

117117
const char *responseFilePath = nullptr;
118118
const char *responseFileArg = nullptr;
119-
if (invocationInfo.allowsResponseFiles &&
120-
!llvm::sys::commandLineFitsWithinSystemLimits(
121-
executablePath, invocationInfo.Arguments)) {
119+
120+
const bool forceResponseFiles =
121+
C.getArgs().hasArg(options::OPT_driver_force_response_files);
122+
assert((invocationInfo.allowsResponseFiles || !forceResponseFiles) &&
123+
"Cannot force response file if platform does not allow it");
124+
125+
if (forceResponseFiles || (invocationInfo.allowsResponseFiles &&
126+
!llvm::sys::commandLineFitsWithinSystemLimits(
127+
executablePath, invocationInfo.Arguments))) {
122128
responseFilePath = context.getTemporaryFilePath("arguments", "resp");
123129
responseFileArg = C.getArgs().MakeArgString(Twine("@") + responseFilePath);
124130
}
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

0 commit comments

Comments
 (0)