diff options
author | Rui Ueyama <ruiu@google.com> | 2017-04-24 22:20:03 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2017-04-24 22:20:03 +0000 |
commit | 95fe8543325ad3b540636e46b272e644e89d1c4d (patch) | |
tree | 6ff04857e8377c8f61eb5f38c52b827bb1ec3cb2 | |
parent | b494578afb3a3f08e64fab2a9d612a3044c6b89d (diff) | |
download | bcm5719-llvm-95fe8543325ad3b540636e46b272e644e89d1c4d.tar.gz bcm5719-llvm-95fe8543325ad3b540636e46b272e644e89d1c4d.zip |
Handle _LINK_ env string as command line parameters.
"_LINK_" environment varaible should be appended to the command line.
https://msdn.microsoft.com/en-us/library/6y6t9esh.aspx
Fixes https://bugs.llvm.org/show_bug.cgi?id=32756
llvm-svn: 301264
-rw-r--r-- | lld/COFF/Driver.h | 2 | ||||
-rw-r--r-- | lld/COFF/DriverUtils.cpp | 23 | ||||
-rw-r--r-- | lld/test/COFF/linkenv.test | 4 |
3 files changed, 16 insertions, 13 deletions
diff --git a/lld/COFF/Driver.h b/lld/COFF/Driver.h index 4566f73eef3..ad725625e03 100644 --- a/lld/COFF/Driver.h +++ b/lld/COFF/Driver.h @@ -48,7 +48,7 @@ public: llvm::opt::InputArgList parse(llvm::ArrayRef<const char *> Args); // Concatenate LINK environment varirable and given arguments and parse them. - llvm::opt::InputArgList parseLINK(llvm::ArrayRef<const char *> Args); + llvm::opt::InputArgList parseLINK(std::vector<const char *> Args); // Tokenizes a given string and then parses as command line options. llvm::opt::InputArgList parse(StringRef S) { return parse(tokenize(S)); } diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp index 736e8463dd8..252590c7d87 100644 --- a/lld/COFF/DriverUtils.cpp +++ b/lld/COFF/DriverUtils.cpp @@ -699,17 +699,20 @@ opt::InputArgList ArgParser::parse(ArrayRef<const char *> ArgsArr) { return Args; } -// link.exe has an interesting feature. If LINK environment exists, -// its contents are handled as a command line string. So you can pass -// extra arguments using the environment variable. -opt::InputArgList ArgParser::parseLINK(ArrayRef<const char *> Args) { +// link.exe has an interesting feature. If LINK or _LINK_ environment +// variables exist, their contents are handled as command line strings. +// So you can pass extra arguments using them. +opt::InputArgList ArgParser::parseLINK(std::vector<const char *> Args) { // Concatenate LINK env and command line arguments, and then parse them. - Optional<std::string> Env = Process::GetEnv("LINK"); - if (!Env) - return parse(Args); - std::vector<const char *> V = tokenize(*Env); - V.insert(V.end(), Args.begin(), Args.end()); - return parse(V); + if (Optional<std::string> S = Process::GetEnv("LINK")) { + std::vector<const char *> V = tokenize(*S); + Args.insert(Args.begin(), V.begin(), V.end()); + } + if (Optional<std::string> S = Process::GetEnv("_LINK_")) { + std::vector<const char *> V = tokenize(*S); + Args.insert(Args.begin(), V.begin(), V.end()); + } + return parse(Args); } std::vector<const char *> ArgParser::tokenize(StringRef S) { diff --git a/lld/test/COFF/linkenv.test b/lld/test/COFF/linkenv.test index 5dfb875a7da..6033094d6db 100644 --- a/lld/test/COFF/linkenv.test +++ b/lld/test/COFF/linkenv.test @@ -1,4 +1,4 @@ -# RUN: env LINK=-help lld-link > %t.log -# RUN: FileCheck %s < %t.log +# RUN: env LINK=-help lld-link | FileCheck %s +# RUN: env _LINK_=-help lld-link | FileCheck %s CHECK: OVERVIEW: LLVM Linker |