[llvm-bugs] [Bug 25863] New: powerpc target cross compiling fails when /usr/lib32 path exists

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 17 06:40:24 PST 2015


            Bug ID: 25863
           Summary: powerpc target cross compiling fails when /usr/lib32
                    path exists
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Driver
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lordartis at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Hello everbody,

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

#include <stdio.h>

int main(){
  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
clang -cc1 version 3.8.0 based upon LLVM 3.8.0svn default target
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
End of search list.

-z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf32ppclinux
-dynamic-linker /lib/ld.so.1 -o a.out
-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
-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/../../../../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

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 (http://llvm.org/):
  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"

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

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151217/dcb1c64a/attachment-0001.html>

More information about the llvm-bugs mailing list