[PATCH] D22015: [ELF] Introduce a flag to parse response file according to windows rules
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 5 13:49:53 PDT 2016
davide created this revision.
davide added reviewers: rafael, filcab.
davide added a subscriber: llvm-commits.
Without this, paths in response file which contain backslashes are not escaped correctly.
example:
```
[davide at localhost bin]$ ./ld.lld @patatino.rsp
cannot open c:foogoopatatello: No such file or directory
[davide at localhost bin]$ cat patatino.rsp
c:\foo\goo\patatello
```
http://reviews.llvm.org/D22015
Files:
ELF/Config.h
ELF/Driver.cpp
ELF/DriverUtils.cpp
ELF/Options.td
test/ELF/basic.s
Index: test/ELF/basic.s
===================================================================
--- test/ELF/basic.s
+++ test/ELF/basic.s
@@ -190,6 +190,11 @@
# RUN: llvm-readobj -file-headers -sections -program-headers -symbols %t2 \
# RUN: | FileCheck %s
+# Test for response file (Windows rules)
+# RUN: echo " c:\blah\foo" > %t.responsefile
+# RUN: not ld.lld --use-windows-rsp %t @%t.responsefile 2>&1 | FileCheck %s --check-prefix=WINRSP
+# WINRSP: cannot open c:\blah\foo
+
# RUN: not ld.lld %t.foo -o %t2 2>&1 | \
# RUN: FileCheck --check-prefix=MISSING %s
# MISSING: cannot open {{.*}}.foo: {{[Nn]}}o such file or directory
Index: ELF/Options.td
===================================================================
--- ELF/Options.td
+++ ELF/Options.td
@@ -156,6 +156,9 @@
def unresolved_symbols: J<"unresolved-symbols=">,
HelpText<"Determine how to handle unresolved symbols">;
+def use_windows_rsp: F<"use-windows-rsp">,
+ HelpText<"Use Windows rules for parsing response files">;
+
def verbose: F<"verbose">, HelpText<"Verbose mode">;
def version: F<"version">, HelpText<"Display the version number">;
Index: ELF/DriverUtils.cpp
===================================================================
--- ELF/DriverUtils.cpp
+++ ELF/DriverUtils.cpp
@@ -58,7 +58,10 @@
// Expand response files. '@<filename>' is replaced by the file's contents.
SmallVector<const char *, 256> Vec(Argv.data(), Argv.data() + Argv.size());
StringSaver Saver(Alloc);
- cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Vec);
+ cl::TokenizerCallback TC = (Config->UseWindowsRsp)
+ ? cl::TokenizeWindowsCommandLine
+ : cl::TokenizeGNUCommandLine;
+ cl::ExpandResponseFiles(Saver, TC, Vec);
// Parse options and then do error checking.
opt::InputArgList Args = this->ParseArgs(Vec, MissingIndex, MissingCount);
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -358,6 +358,7 @@
Config->StripDebug = Args.hasArg(OPT_strip_debug);
Config->Threads = Args.hasArg(OPT_threads);
Config->Trace = Args.hasArg(OPT_trace);
+ Config->UseWindowsRsp = Args.hasArg(OPT_use_windows_rsp);
Config->Verbose = Args.hasArg(OPT_verbose);
Config->WarnCommon = Args.hasArg(OPT_warn_common);
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -101,6 +101,7 @@
bool SysvHash = true;
bool Threads;
bool Trace;
+ bool UseWindowsRsp;
bool Verbose;
bool VersionScriptGlobalByDefault = true;
bool WarnCommon;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22015.62786.patch
Type: text/x-patch
Size: 2664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160705/86d13fd7/attachment.bin>
More information about the llvm-commits
mailing list