On 18 July 2012 15:24, salvatore benedetto <salvatore.benedetto at gmail.com> wrote:> I'm not sure how to interpret the above output, but I don't understand > why if say -triple armv4t-none--gnueabi .Ok, we're getting there... ;) I think these errors are due to Clang not finding the libraries/includes/etc for the target you're building. If you have CodeSourcery's GCC, use that (via --sysroot or -ccc-gcc-name I said earlier), it's by far the easiest way. I'm not sure compiler-rt is ready for prime time (someone else might chip in), but that might be an alternative, though I have no idea how to use it. -- cheers, --renato http://systemcall.org/
salvatore benedetto
2012-Jul-18 14:46 UTC
[LLVMdev] Setting up a cross-compiler for cortex-m3
On Wed, Jul 18, 2012 at 4:31 PM, Renato Golin <rengolin at systemcall.org> wrote:> On 18 July 2012 15:24, salvatore benedetto > <salvatore.benedetto at gmail.com> wrote: >> I'm not sure how to interpret the above output, but I don't understand >> why if say -triple armv4t-none--gnueabi . > > Ok, we're getting there... ;)Glad you are confident. :-)> I think these errors are due to Clang not finding the > libraries/includes/etc for the target you're building. > > If you have CodeSourcery's GCC, use that (via --sysroot or > -ccc-gcc-name I said earlier), it's by far the easiest way.emitrax at xartimequad:~/programming$ which arm-none-linux-gnueabi-g++ /home/emitrax/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-g++ emitrax at xartimequad:~/programming$ find /home/emitrax/CodeSourcery/Sourcery_G++_Lite/ -name libc /home/emitrax/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc $ clang++ -ccc-host-triple thumbv7m-none-gnueabi testReference.cpp -c --sysroot=/home/emitrax/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc/ -v clang version 3.2 (http://llvm.org/git/clang.git 88237bf587581026dcfc8386abf055cb201aa487) (http://llvm.org/git/llvm.git 18a1b616ea123548b61a037c4f4fea4133aac1b5) Target: thumbv7m-none--gnueabi Thread model: posix "/home/emitrax/bin/llvm/bin/clang" -cc1 -triple armv4t-none--gnueabi -S -disable-free -main-file-name testReference.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -mconstructor-aliases -target-abi aapcs-linux -target-cpu arm7tdmi -mfloat-abi soft -target-feature +soft-float-abi -target-linker-version 2.21.53.20110810 -momit-leaf-frame-pointer -v -coverage-file /tmp/testReference-IcBmdF.s -resource-dir /home/emitrax/bin/llvm/bin/../lib/clang/3.2 -isysroot /home/emitrax/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc/ -fmodule-cache-path /var/tmp/clang-module-cache -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir /home/emitrax/programming -ferror-limit 19 -fmessage-length 106 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/testReference-IcBmdF.s -x c++ testReference.cpp clang -cc1 version 3.2 based upon LLVM 3.2svn default target x86_64-unknown-linux-gnu ignoring nonexistent directory "/home/emitrax/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc//usr/local/include" #include "..." search starts here: #include <...> search starts here: /home/emitrax/bin/llvm/bin/../lib/clang/3.2/include /home/emitrax/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc//usr/include End of search list. "/usr/bin/g++" --sysroot=/home/emitrax/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc/ -v -c -o testReference.o -x assembler /tmp/testReference-IcBmdF.s Using built-in specs. COLLECT_GCC=/usr/bin/g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3) COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'testReference.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' as --64 -o testReference.o /tmp/testReference-IcBmdF.s /tmp/testReference-IcBmdF.s: Assembler messages: /tmp/testReference-IcBmdF.s:1: Error: unknown pseudo-op: `.syntax' and so on..> I'm not sure compiler-rt is ready for prime time (someone else might > chip in), but that might be an alternative, though I have no idea how > to use it.I've also tried with a simpler source file without include statements but I'm still getting errors. $ clang++ -ccc-host-triple thumbv7m-none-gnueabi noInclude.cpp -c --sysroot=/home/emitrax/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc/ -v clang version 3.2 (http://llvm.org/git/clang.git 88237bf587581026dcfc8386abf055cb201aa487) (http://llvm.org/git/llvm.git 18a1b616ea123548b61a037c4f4fea4133aac1b5) Target: thumbv7m-none--gnueabi Thread model: posix "/home/emitrax/bin/llvm/bin/clang" -cc1 -triple armv4t-none--gnueabi -S -disable-free -main-file-name noInclude.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -mconstructor-aliases -target-abi aapcs-linux -target-cpu arm7tdmi -mfloat-abi soft -target-feature +soft-float-abi -target-linker-version 2.21.53.20110810 -momit-leaf-frame-pointer -v -coverage-file /tmp/noInclude-YFkpA6.s -resource-dir /home/emitrax/bin/llvm/bin/../lib/clang/3.2 -isysroot /home/emitrax/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc/ -fmodule-cache-path /var/tmp/clang-module-cache -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir /home/emitrax/programming -ferror-limit 19 -fmessage-length 106 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/noInclude-YFkpA6.s -x c++ noInclude.cpp clang -cc1 version 3.2 based upon LLVM 3.2svn default target x86_64-unknown-linux-gnu ignoring nonexistent directory "/home/emitrax/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc//usr/local/include" #include "..." search starts here: #include <...> search starts here: /home/emitrax/bin/llvm/bin/../lib/clang/3.2/include /home/emitrax/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc//usr/include End of search list. "/usr/bin/g++" --sysroot=/home/emitrax/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc/ -v -c -o noInclude.o -x assembler /tmp/noInclude-YFkpA6.s Using built-in specs. COLLECT_GCC=/usr/bin/g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3) COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'noInclude.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' <------------------------------ Is this correct? as --64 -o noInclude.o /tmp/noInclude-YFkpA6.s /tmp/noInclude-YFkpA6.s: Assembler messages: /tmp/noInclude-YFkpA6.s:1: Error: unknown pseudo-op: `.syntax' /tmp/noInclude-YFkpA6.s:2: Error: unknown pseudo-op: `.eabi_attribute' /tmp/noInclude-YFkpA6.s:3: Error: unknown pseudo-op: `.eabi_attribute' /tmp/noInclude-YFkpA6.s:4: Error: unknown pseudo-op: `.eabi_attribute' /tmp/noInclude-YFkpA6.s:5: Error: unknown pseudo-op: `.eabi_attribute' /tmp/noInclude-YFkpA6.s:6: Error: unknown pseudo-op: `.eabi_attribute' /tmp/noInclude-YFkpA6.s:13: Error: too many memory references for `sub' /tmp/noInclude-YFkpA6.s:14: Error: expecting operand after ','; got nothing /tmp/noInclude-YFkpA6.s:15: Error: invalid char '[' beginning operand 2 `[sp' /tmp/noInclude-YFkpA6.s:16: Error: invalid char '[' beginning operand 2 `[sp' /tmp/noInclude-YFkpA6.s:17: Error: invalid char '[' beginning operand 2 `[sp' /tmp/noInclude-YFkpA6.s:18: Error: invalid char '[' beginning operand 2 `[sp' /tmp/noInclude-YFkpA6.s:19: Error: too many memory references for `mov' /tmp/noInclude-YFkpA6.s:20: Error: invalid char '[' beginning operand 2 `[sp]' /tmp/noInclude-YFkpA6.s:21: Error: too many memory references for `add' /tmp/noInclude-YFkpA6.s:22: Error: no such instruction: `bx lr' clang: error: assembler (via gcc) command failed with exit code 1 (use -v to see invocation) $ cat noInclude.cpp int main(int argc, char** argv) { return 0; } Any idea? Thanks, S.
On 18 July 2012 15:46, salvatore benedetto <salvatore.benedetto at gmail.com> wrote:> $ clang++ -ccc-host-triple thumbv7m-none-gnueabi noInclude.cpp -c > --sysroot=/home/emitrax/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc/Try -ccc-gcc-name arm-none-linux-gnueabi-g++ -ccc-host-triple thumbv7m-none-linux-gnueabi Sometimes it's better than sysroot, as it finds it all by itself. -- cheers, --renato http://systemcall.org/