diff options
| author | Martin Storsjo <martin@martin.st> | 2019-06-10 20:10:10 +0000 |
|---|---|---|
| committer | Martin Storsjo <martin@martin.st> | 2019-06-10 20:10:10 +0000 |
| commit | bb12396f9175eaf4586d8e5c76441977d97ccf93 (patch) | |
| tree | 3a578fc9a7a734f5ce14c16be2d381e4eb5289c8 /lld/tools | |
| parent | 78c0d75697067a3bea70ca28013b930a0deb06b3 (diff) | |
| download | bcm5719-llvm-bb12396f9175eaf4586d8e5c76441977d97ccf93.tar.gz bcm5719-llvm-bb12396f9175eaf4586d8e5c76441977d97ccf93.zip | |
[Driver] Look for -m in response files as well
Also expand response files in the MinGW driver.
This should fix PR42135.
Differential Revision: https://reviews.llvm.org/D63024
llvm-svn: 362977
Diffstat (limited to 'lld/tools')
| -rw-r--r-- | lld/tools/lld/lld.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/lld/tools/lld/lld.cpp b/lld/tools/lld/lld.cpp index c6be7f8f872..cd0eaf7b49e 100644 --- a/lld/tools/lld/lld.cpp +++ b/lld/tools/lld/lld.cpp @@ -26,9 +26,13 @@ //===----------------------------------------------------------------------===// #include "lld/Common/Driver.h" +#include "lld/Common/Memory.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/ADT/Triple.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/InitLLVM.h" #include "llvm/Support/Path.h" #include <cstdlib> @@ -59,12 +63,30 @@ static Flavor getFlavor(StringRef S) { .Default(Invalid); } -static bool isPETarget(const std::vector<const char *> &V) { +static cl::TokenizerCallback getDefaultQuotingStyle() { + if (Triple(sys::getProcessTriple()).getOS() == Triple::Win32) + return cl::TokenizeWindowsCommandLine; + return cl::TokenizeGNUCommandLine; +} + +static bool isPETargetName(StringRef S) { + return S == "i386pe" || S == "i386pep" || S == "thumb2pe" || S == "arm64pe"; +} + +static bool isPETarget(std::vector<const char *> &V) { for (auto It = V.begin(); It + 1 != V.end(); ++It) { if (StringRef(*It) != "-m") continue; - StringRef S = *(It + 1); - return S == "i386pe" || S == "i386pep" || S == "thumb2pe" || S == "arm64pe"; + return isPETargetName(*(It + 1)); + } + // Expand response files (arguments in the form of @<filename>) + // to allow detecting the -m argument from arguments in them. + SmallVector<const char *, 256> ExpandedArgs(V.data(), V.data() + V.size()); + cl::ExpandResponseFiles(Saver, getDefaultQuotingStyle(), ExpandedArgs); + for (auto It = ExpandedArgs.begin(); It + 1 != ExpandedArgs.end(); ++It) { + if (StringRef(*It) != "-m") + continue; + return isPETargetName(*(It + 1)); } return false; } |

