<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 13, 2014 at 11:34 AM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="">On 26 February 2014 07:30, Khilan Gudka <<a href="mailto:Khilan.Gudka@cl.cam.ac.uk">Khilan.Gudka@cl.cam.ac.uk</a>> wrote:<br>

> Hi #llvm,<br>
><br>
> Sometimes when linking a very large number of bit code files together, it is not possible if the number exceeds that allowed by the shell. This patch adds a -dir flag to llvm-link that allows a single directory to be passed. For example:<br>

><br>
> llvm-link -o linked.bc -dir myDir<br>
><br>
> This follows the intended philosophy of keeping llvm-link simple (exclusively either a directory, or a list of files).<br>
<br>
</div>The normal solution for this is to use a response file. This is<br>
already implemented:<br>
<br>
$ echo test.o > list<br>
$ llvm-link -o foo.bc @list<br>
<br>
Can you use that instead?<br></blockquote><div><br></div><div>I think this is a useful feature to have. Response files force all invokers of llvm-link to know how to properly escape response files, which is an inconvenience (that I personally ran into last Summer; do you remember the hack that I had to use in order to feed all the files to llvm-link from the LTO script? This option would have simplified things a fair amount).</div>
<div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div><div class="h5"><br>
> <a href="http://llvm-reviews.chandlerc.com/D2885" target="_blank">http://llvm-reviews.chandlerc.com/D2885</a><br>
><br>
> Files:<br>
>   tools/llvm-link/llvm-link.cpp<br>
><br>
> Index: tools/llvm-link/llvm-link.cpp<br>
> ===================================================================<br>
> --- tools/llvm-link/llvm-link.cpp<br>
> +++ tools/llvm-link/llvm-link.cpp<br>
> @@ -19,19 +19,22 @@<br>
>  #include "llvm/IR/Module.h"<br>
>  #include "llvm/IRReader/IRReader.h"<br>
>  #include "llvm/Support/CommandLine.h"<br>
> +#include "llvm/Support/FileSystem.h"<br>
>  #include "llvm/Support/ManagedStatic.h"<br>
>  #include "llvm/Support/Path.h"<br>
>  #include "llvm/Support/PrettyStackTrace.h"<br>
>  #include "llvm/Support/Signals.h"<br>
>  #include "llvm/Support/SourceMgr.h"<br>
>  #include "llvm/Support/SystemUtils.h"<br>
> +#include "llvm/Support/system_error.h"<br>
>  #include "llvm/Support/ToolOutputFile.h"<br>
>  #include <memory><br>
>  using namespace llvm;<br>
> +using namespace llvm::sys::fs;<br>
><br>
>  static cl::list<std::string><br>
>  InputFilenames(cl::Positional, cl::OneOrMore,<br>
> -               cl::desc("<input bitcode files>"));<br>
> +               cl::desc("<input bitcode files|input bitcode directory>"));<br>
><br>
>  static cl::opt<std::string><br>
>  OutputFilename("o", cl::desc("Override output filename"), cl::init("-"),<br>
> @@ -50,6 +53,9 @@<br>
>  static cl::opt<bool><br>
>  DumpAsm("d", cl::desc("Print assembly as linked"), cl::Hidden);<br>
><br>
> +static cl::opt<bool><br>
> +Directory("dir", cl::desc("Input argument is a directory containing bitcode files"));<br>
> +<br>
>  // LoadFile - Read the specified bitcode file in and return it.  This routine<br>
>  // searches the link path for the specified file to try to find it...<br>
>  //<br>
> @@ -75,6 +81,26 @@<br>
>    llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.<br>
>    cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");<br>
><br>
> +  if (Directory) {<br>
> +    if (InputFilenames.size() > 1) {<br>
> +      errs() << "Error: More than one directory specified\n";<br>
> +      return -1;<br>
> +    }<br>
> +<br>
> +    // fill InputFilenames with the name of the files in the argument directory,<br>
> +    // thus allowing the code below to work with no changes<br>
> +    error_code ec; // output parameter to store error codes<br>
> +    std::string dir = InputFilenames[0];<br>
> +    InputFilenames.clear();<br>
> +    for (directory_iterator I = directory_iterator(dir, ec), E; I != E; I.increment(ec)) {<br>
> +      if (ec != ec.success()) {<br>
> +        errs() << "Error iterating directory: " << ec.message() << "\n";<br>
> +        return -1;<br>
> +      }<br>
> +      InputFilenames.push_back(I->path());<br>
> +    }<br>
> +  }<br>
> +<br>
>    unsigned BaseArg = 0;<br>
>    std::string ErrorMessage;<br>
><br>
</div></div>> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>