title: clang linker problem
body: <p>I just tried out the latest llvm and clang trunk versions. They compiled without a single warning out of the box but I'm having trouble linking a hello world example. My Code is</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main(){
    printf("hello\n");
  }
  </code></pre>
  
  <p>If I compile using </p>
  
  <pre><code>clang test.c
  </code></pre>
  
  <p>I get the following error</p>
  
  <pre><code>/usr/bin/ld: crt1.o: No such file: No such file or directory
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <p>Using -v shows that the gnu ld is invoked as </p>
  
  <pre><code>"/usr/bin/ld" --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o a.out crt1.o crti.o crtbegin.o -L -L/../../.. /tmp/cc-0XJTsG.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed crtend.o crtn.o
  </code></pre>
  
  <p>But I have the crt1.o object file!</p>
  
  <pre><code>$ locate crt1.o
  /usr/lib/Mcrt1.o
  /usr/lib/Scrt1.o
  /usr/lib/crt1.o
  /usr/lib/gcrt1.o
  </code></pre>
  
  <p>What also works is</p>
  
  <pre><code>clang -c test.c
  gcc test.o
  </code></pre>
  
  <p>and of course</p>
  
  <pre><code>gcc test.c
  </code></pre>
  
  <p>What I further tried:</p>
  
  <pre><code>$ clang -Xlinker "-L /usr/lib" test.c 
  /usr/bin/ld: crt1.o: No such file: No such file or directory
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  $ clang -Xlinker "-L /usr/lib" test.c -v 
  "/usr/bin/ld" --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o a.out crt1.o crti.o crtbegin.o -L -L/../../.. -L /usr/lib /tmp/cc-YsI9ES.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed crtend.o
  </code></pre>
  
  <p>I also tried copying the crt1.o file into the current directory. That seemed to work. Well it didn't compile because after that crti.o was missing.</p>
  
  <p>My distro is Ubuntu.</p>
  
  <p>Well I don't really know what to try next. I don't see how I could fix clang nor do I have an idea on how to inject the necessary path in the ld invocation. Any ideas?</p>