This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: First time user - basic question


Hello Trevor,

Thank you for your reply. I noticed that I've got my cross compiler binaries built from crosstool-ng in ~x-tools/arm-cortex_a8_blah_blah/bin.

So if I create some symlinks for gcc etc and set the path I can easily generate an executable for my ARM target by simply invoking gcc. Do I need to do anything else? What if I'm going to build a large package that comes with multiple Makefiles etc? It's easy enough to compile a single file. My question boils down to how do I use the cross-compiler ( what needs to be setup ) to build larger packages - such as the kernel etc...

I just don't know what has to be set in the environment.

Regards,
Jim



----- Message from twoerner@gmail.com ---------
    Date: Tue, 15 Mar 2011 18:28:00 -0400
    From: Trevor Woerner <twoerner@gmail.com>
 Subject: Re: First time user - basic question
      To: Rahul Gauba <rahul_gauba@yahoo.com>
      Cc: Jim Norton <jimnorton@jimnorton.org>, crossgcc@sourceware.org


On Sun, Mar 13, 2011 at 11:23 PM, Rahul Gauba <rahul_gauba@yahoo.com> wrote:
? ? Not sure about the ct-ng project. But if you plan to use compiler,
libraries, include paths from the cross-chain tool, you need to:

Your uncertainty about CT-NG specifically is noted :-)


1 -- ?Modify the environment variable PATH such that gcc is invoked from the
cross-chain.

...unless you'd like to use the full path every time you invoke the compiler... :-)

2 -- You should be using the shared libraries from cross-chain tool, so you need
to specify using -L<cross-chain-path> when linking. Your cross-chain build area
should have lib and usr/lib directories. So these need to specified with -L.
3 -- Also the include path for C/C++ headers from the cross-chain should be
mentioned using -I<cross-chain include directories>.

I'm quite sure the CT-NG project takes care of numbers 2 and 3 for you (maybe someone would like to confirm my understanding?). I had just recently asked these specific questions of Yann and that was the impression I got. I believe this is all because of the use of sysroot (is that correct Yann?).

Specifically, if I compile a simple "hello.c" using my powerpc-405
compiler built with CT-NG and add the "-v" option on the command line,
GCC gets very verbose about exactly everything it is doing:

$ powerpc-405-linux-gnu-gcc -v -o hello hello.c
Using built-in specs.
Target: powerpc-405-linux-gnu
Configured with:
/home/trevor/devel/ct-ng/1.10.0/work-area/powerpc-405/targets/src/gcc-4.3.2/configure
--build=x86_64-build_unknown-linux-gnu
--host=x86_64-build_unknown-linux-gnu --target=powerpc-405-linux-gnu
--prefix=/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu
--with-sysroot=/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot
--enable-languages=c --disable-multilib --with-cpu=405 --with-tune=405
--with-float=soft --with-pkgversion=crosstool-NG-1.10.0
--enable-__cxa_atexit --disable-libmudflap --disable-libgomp
--disable-libssp
--with-gmp=/home/trevor/devel/ct-ng/1.10.0/work-area/powerpc-405/targets/powerpc-405-linux-gnu/build/static
--with-mpfr=/home/trevor/devel/ct-ng/1.10.0/work-area/powerpc-405/targets/powerpc-405-linux-gnu/build/static
--enable-threads=posix --enable-target-optspace
--with-local-prefix=/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot
--disable-nls --enable-symvers=gnu --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.3.2 (crosstool-NG-1.10.0)
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mcpu=405' '-mtune=405' '-msoft-float'
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/libexec/gcc/powerpc-405-linux-gnu/4.3.2/cc1
-quiet -v -D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix
-Dlinux -D__linux -Asystem=linux -Asystem=unix -Asystem=posix hello.c
-quiet -dumpbase hello.c -mcpu=405 -mtune=405 -msoft-float -auxbase
hello -version -o /tmp/ccXXIIu6.s
ignoring nonexistent directory
"/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot/include"
ignoring nonexistent directory
"/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2/../../../../powerpc-405-linux-gnu/include"
ignoring nonexistent directory "/home/trevor/local/include"
#include "..." search starts here:
#include <...> search starts here:
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2/include
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2/include-fixed
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot/usr/include
End of search list.
GNU C (crosstool-NG-1.10.0) version 4.3.2 (powerpc-405-linux-gnu)
compiled by GNU C version 4.5.1 20101208 [gcc-4_5-branch
revision 167585], GMP version 4.3.2, MPFR version 2.4.2-p2.
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=127680
Compiler executable checksum: b3ecde2a02c137bc92133d3e84fb9338
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mcpu=405' '-mtune=405' '-msoft-float'
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2/../../../../powerpc-405-linux-gnu/bin/as
-m405 -many -V -Qy -o /tmp/ccPKBolR.o /tmp/ccXXIIu6.s
GNU assembler version 2.19.1 (powerpc-405-linux-gnu) using BFD version
(GNU Binutils) 2.19.1
COMPILER_PATH=/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/libexec/gcc/powerpc-405-linux-gnu/4.3.2/:/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/libexec/gcc/powerpc-405-linux-gnu/4.3.2/:/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/libexec/gcc/powerpc-405-linux-gnu/:/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2/:/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/:/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2/../../../../powerpc-405-linux-gnu/bin/
LIBRARY_PATH=/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2/:/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot/lib/:/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mcpu=405' '-mtune=405' '-msoft-float'
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/libexec/gcc/powerpc-405-linux-gnu/4.3.2/collect2
--sysroot=/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot
--eh-frame-hdr -V -Qy -m elf32ppclinux -dynamic-linker /lib/ld.so.1 -o
hello /home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot/usr/lib/crt1.o
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot/usr/lib/crti.o
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2/crtbegin.o
-L/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2
-L/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot/lib
-L/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot/usr/lib
/tmp/ccPKBolR.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc
--as-needed -lgcc_s --no-as-needed
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2/crtsavres.o
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2/crtend.o
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot/usr/lib/crtn.o
GNU ld (GNU Binutils) 2.19.1
Supported emulations:
elf32ppclinux
elf32ppc
elf32ppcsim


If you look closely at the output you'll notice:

#include "..." search starts here:
#include <...> search starts here:
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2/include
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2/include-fixed
/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot/usr/include
End of search list.


Specifically, the #include "" and #include <> paths do not include the
system include locations, just the cross locations.

Then later the collect2 phase:

-L/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/lib/gcc/powerpc-405-linux-gnu/4.3.2
-L/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot/lib
-L/home/trevor/devel/ct-ng/1.10.0/x-tools/powerpc-405-linux-gnu/powerpc-405-linux-gnu/sysroot/usr/lib


so the final linking is taking place using the cross library locations.

So when using CT-NG you don't need to use fancy "-L" and "-I" logic to
get your Makefiles correct. Just using the steps I mentioned before
should suffice.

--
For unsubscribe information see http://sourceware.org/lists.html#faq




----- End message from twoerner@gmail.com -----



--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]