<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - powerpc target cross compiling fails when /usr/lib32 path exists"
   href="https://llvm.org/bugs/show_bug.cgi?id=25863">25863</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>powerpc target cross compiling fails when /usr/lib32 path exists
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Driver
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>lordartis@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hello everbody,

I have a very simple C hello world that does not cross compile into ppc32.

#include <stdio.h>

int main(){
  printf("Hello\n");
  return 0;
}

clang -target powerpc-linux ./main.c -L /usr/powerpc-linux-gnu/lib/ -v

clang version 3.8.0 (trunk 255649)
Target: powerpc--linux
Thread model: posix
InstalledDir: MY_LLVM_PATH/build/bin
Found candidate GCC installation: /usr/lib/gcc-cross/powerpc-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc-cross/powerpc-linux-gnu/4.9.2
Selected GCC installation: /usr/lib/gcc-cross/powerpc-linux-gnu/4.9
Candidate multilib: .;@m32
Candidate multilib: 64;@m64
Selected multilib: .;@m32
 "MY_LLVM_PATH/build/bin/clang-3.8" -cc1 -triple powerpc--linux -emit-obj
-mrelax-all -disable-free -main-file-name main.c -mrelocation-model static
-mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -fuse-init-array -target-cpu ppc -mfloat-abi hard -v
-dwarf-column-info -resource-dir MY_LLVM_PATH/build/bin/../lib/clang/3.8.0
-internal-isystem /usr/local/include -internal-isystem
MY_LLVM_PATH/build/bin/../lib/clang/3.8.0/include -internal-externc-isystem
/include -internal-externc-isystem /usr/include -fdebug-compilation-dir
/tmp/hello -ferror-limit 19 -fmessage-length 140 -fno-signed-char
-fobjc-runtime=gcc -fdiagnostics-show-option -o /tmp/main-261e40.o -x c
./main.c
clang -cc1 version 3.8.0 based upon LLVM 3.8.0svn default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 MY_LLVM_PATH/build/bin/../lib/clang/3.8.0/include
 /usr/include
End of search list.

"/usr/lib/gcc-cross/powerpc-linux-gnu/4.9/../../../../powerpc-linux-gnu/bin/ld"
-z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf32ppclinux
-dynamic-linker /lib/ld.so.1 -o a.out
/usr/lib/gcc-cross/powerpc-linux-gnu/4.9/../../../../lib32/crt1.o
/usr/lib/gcc-cross/powerpc-linux-gnu/4.9/../../../../lib32/crti.o
/usr/lib/gcc-cross/powerpc-linux-gnu/4.9/crtbegin.o
-L/usr/powerpc-linux-gnu/lib/ -L/usr/lib/gcc-cross/powerpc-linux-gnu/4.9
-L/usr/lib/gcc-cross/powerpc-linux-gnu/4.9/../../../../lib32 -L/lib/../lib32
-L/usr/lib/../lib32
-L/usr/lib/gcc-cross/powerpc-linux-gnu/4.9/../../../../powerpc-linux-gnu/lib
-L/usr/lib/gcc-cross/powerpc-linux-gnu/4.9/../../..
-LMY_LLVM_PATH/build/bin/../lib -L/lib -L/usr/lib /tmp/main-3a1191.o -lgcc
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib/gcc-cross/powerpc-linux-gnu/4.9/crtend.o
/usr/lib/gcc-cross/powerpc-linux-gnu/4.9/../../../../lib32/crtn.o
/usr/lib/gcc-cross/powerpc-linux-gnu/4.9/../../../../powerpc-linux-gnu/bin/ld:
/usr/lib/gcc-cross/powerpc-linux-gnu/4.9/../../../../lib32/crt1.o: Réadressages
en format ELF générique (EM: 3)
/usr/lib/gcc-cross/powerpc-linux-gnu/4.9/../../../../lib32/crt1.o: error adding
symbols: Fichier dans un mauvais format
clang-3.8: error: linker command failed with exit code 1 (use -v to see
invocation)



The error is due to crt1.o, crri.o, crtn.o objects, in fact
'powerpc-linux-gnu-ld' tries to link the main.o (ppc format) with
/usr/lib32/crt1.o (and crti.o crtn.o)  (x86 32bit format).
I notice if I remove the /usr/lib32 repertory the compilation works because the
crt1.o used is the correct one (in /usr/powerpc-linux-gnu/lib/)  



Here my clang version :

clang version 3.8.0 (trunk 255649)
Target: x86_64-unknown-linux-gnu
Thread model: posix

And my llvm version :

LLVM (<a href="http://llvm.org/">http://llvm.org/</a>):
  LLVM version 3.8.0svn
  DEBUG build with assertions.
  Built Dec 15 2015 (17:49:25).
  Default target: x86_64-unknown-linux-gnu
  Host CPU: sandybridge





I tried to seach the file concerned in the source code, the only interesting
file that matches "crl1.o" is "/lib/Driver/ToolChains.cpp"
<a href="https://github.com/llvm-mirror/clang/blob/815cde37f487611c4a710a04c849983b37ca4974/lib/Driver/ToolChains.cpp#L3070-L3075">https://github.com/llvm-mirror/clang/blob/815cde37f487611c4a710a04c849983b37ca4974/lib/Driver/ToolChains.cpp#L3070-L3075</a>

The detection of /usr/lib32/crt1.o is hard-coded when target is x86 or ppc but
I maybe wrong because the code seems to concern only FreeBSD and not Linux



What do you think about this bug ?
Best Regards</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>