Skip to content

Rdar 44142091 fix without test #19314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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 @@ -120,6 +120,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 << " ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…ouch. Good catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

}
OS.flush();
return false;
Expand Down
12 changes: 9 additions & 3 deletions lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,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