[lld] r186648 - [PECOFF][Driver] Interpret "LIB" environment variable.

Rui Ueyama ruiu at google.com
Thu Jul 18 21:01:41 PDT 2013


Thank you for reviewing. I haven't thought about non-ASCII paths so I guess
it's broken not only at this place but also at other places. I'll try to
fix.


On Thu, Jul 18, 2013 at 8:54 PM, Aaron Ballman <aaron at aaronballman.com>wrote:

> On Thu, Jul 18, 2013 at 11:27 PM, Rui Ueyama <ruiu at google.com> wrote:
> > Author: ruiu
> > Date: Thu Jul 18 22:27:03 2013
> > New Revision: 186648
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=186648&view=rev
> > Log:
> > [PECOFF][Driver] Interpret "LIB" environment variable.
> >
> > Modified:
> >     lld/trunk/lib/Driver/WinLinkDriver.cpp
> >     lld/trunk/test/pecoff/importlib.test
> >
> > Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=186648&r1=186647&r2=186648&view=diff
> >
> ==============================================================================
> > --- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
> > +++ lld/trunk/lib/Driver/WinLinkDriver.cpp Thu Jul 18 22:27:03 2013
> > @@ -175,12 +175,32 @@ StringRef getDefaultOutputFileName(PECOF
> >    return info.allocateString(smallStr.str());
> >  }
> >
> > +// Split the given string with the path separator.
> > +std::vector<StringRef> splitPathList(StringRef str) {
> > +  std::vector<StringRef> ret;
> > +  while (!str.empty()) {
> > +    StringRef path;
> > +    llvm::tie(path, str) = str.split(';');
> > +    ret.push_back(path);
> > +  }
> > +  return std::move(ret);
> > +}
> > +
> > +// Process "LIB" environment variable. The variable contains a list of
> > +// search paths separated by semicolons.
> > +void processLibEnvVar(PECOFFTargetInfo &info) {
> > +  if (char *envp = ::getenv("LIB"))
>
> This really should be using _wgetenv when on Windows so that it
> supports non-ASCII paths.
>
> > +    for (StringRef path : splitPathList(envp))
> > +      info.appendInputSearchPath(info.allocateString(path));
> > +}
> > +
> >  } // namespace
> >
> >
> >  bool WinLinkDriver::linkPECOFF(int argc, const char *argv[],
> >                                 raw_ostream &diagnostics) {
> >    PECOFFTargetInfo info;
> > +  processLibEnvVar(info);
> >    if (parse(argc, argv, info, diagnostics))
> >      return true;
> >    return link(info, diagnostics);
> >
> > Modified: lld/trunk/test/pecoff/importlib.test
> > URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/importlib.test?rev=186648&r1=186647&r2=186648&view=diff
> >
> ==============================================================================
> > --- lld/trunk/test/pecoff/importlib.test (original)
> > +++ lld/trunk/test/pecoff/importlib.test Thu Jul 18 22:27:03 2013
> > @@ -8,6 +8,9 @@
> >  #
> >  # RUN: lld -flavor link -out %t1 -subsystem console -libpath %p/Inputs \
> >  # RUN:    -- %t.obj vars.lib && llvm-objdump -d %t1 | FileCheck %s
> > +#
> > +# RUN: LIB=%p/Inputs lld -flavor link -out %t1 -subsystem console \
> > +# RUN:    -- %t.obj vars.lib && llvm-objdump -d %t1 | FileCheck %s
> >
> >  CHECK: Disassembly of section .text:
> >  CHECK: .text:
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> ~Aaron
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130718/76c4c092/attachment.html>


More information about the llvm-commits mailing list