diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-07-08 19:00:46 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-07-08 19:00:46 +0000 |
commit | 7a544f7327a4b158913a1bbe40b039f6bb7d8d86 (patch) | |
tree | c11274abac97a0e49309a07a1b84d08a0ebf8e0a /llvm/lib/LibDriver/LibDriver.cpp | |
parent | 3d5b610c864c8f5980eaa16c22b71ff1cf462fae (diff) | |
download | llvm-7a544f7327a4b158913a1bbe40b039f6bb7d8d86.zip llvm-7a544f7327a4b158913a1bbe40b039f6bb7d8d86.tar.gz llvm-7a544f7327a4b158913a1bbe40b039f6bb7d8d86.tar.bz2 |
LibDriver: Fix output path inference.
The inferred output file name is based on the first input file, not the
first one with extension .obj. The output file was also being written to
the wrong directory; it needs to be written to whichever directory on the
libpath it was found in. This change fixes both issues.
llvm-svn: 241710
Diffstat (limited to 'llvm/lib/LibDriver/LibDriver.cpp')
-rw-r--r-- | llvm/lib/LibDriver/LibDriver.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/llvm/lib/LibDriver/LibDriver.cpp b/llvm/lib/LibDriver/LibDriver.cpp index cb3278c..bc3ed46 100644 --- a/llvm/lib/LibDriver/LibDriver.cpp +++ b/llvm/lib/LibDriver/LibDriver.cpp @@ -56,17 +56,13 @@ public: } -static std::string getOutputPath(llvm::opt::InputArgList *Args) { +static std::string getOutputPath(llvm::opt::InputArgList *Args, + const llvm::NewArchiveIterator &FirstMember) { if (auto *Arg = Args->getLastArg(OPT_out)) return Arg->getValue(); - for (auto *Arg : Args->filtered(OPT_INPUT)) { - if (!StringRef(Arg->getValue()).endswith_lower(".obj")) - continue; - SmallString<128> Val = StringRef(Arg->getValue()); - llvm::sys::path::replace_extension(Val, ".lib"); - return Val.str(); - } - llvm_unreachable("internal error"); + SmallString<128> Val = FirstMember.getNew(); + llvm::sys::path::replace_extension(Val, ".lib"); + return Val.str(); } static std::vector<StringRef> getSearchPaths(llvm::opt::InputArgList *Args, @@ -143,8 +139,8 @@ int llvm::libDriverMain(llvm::ArrayRef<const char*> ArgsArr) { llvm::sys::path::filename(Arg->getValue())); } - std::pair<StringRef, std::error_code> Result = - llvm::writeArchive(getOutputPath(&Args), Members, /*WriteSymtab=*/true); + std::pair<StringRef, std::error_code> Result = llvm::writeArchive( + getOutputPath(&Args, Members[0]), Members, /*WriteSymtab=*/true); if (Result.second) { if (Result.first.empty()) Result.first = ArgsArr[0]; |