https://llvm.org/bugs/show_bug.cgi?id=25863
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: unassignedclangb...@nondot.org Reporter: lordar...@gmail.com CC: llvm-bugs@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(){ 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 (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" https://github.com/llvm-mirror/clang/blob/815cde37f487611c4a710a04c849983b37ca4974/lib/Driver/ToolChains.cpp#L3070-L3075 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.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs