RE: [arm-gnu] Compile Android_Kernel with code sourcery
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [arm-gnu] Compile Android_Kernel with code sourcery



If you question concerns building the kernel, yes, that is already built with the codesourcery chain.

If you question is regarding compiling software for Android, here are some hints:

The bionic C library does not support a lot, e.g. no exceptions, no multiple threads, no std templates. Android also uses a different way of dynamic linking which needs a special linker script. Further, Android is missing a standard linux library for execv and it needs special crt objects. If your program is simple enough, you can make it use the dynamic bionic library, the crt objects and the executable will be very small and run fine.

For more complex things, you can build on the fact that the kernel is standard Linux, so if you bring your own stuff ("-static" linked) on top of it, anything will compile and run. E.g.

arm-none-linux-gnueabi-gcc -o myprog -g -static myprog.c -lm -lc

One issue though: If the program is multithreaded, you need to force in the whole pthread library and not rely on the linker picking up the right routines (this issus is not related to Android, but general knowledge):
arm-none-linux-gnueabi-gcc -o myprog -g -static myprog.c -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lm -lc

If the program uses C++, std templates etc, use arm-none-linux-gnueabi-g++ instead of gcc.

Also, use

arm-none-linux-gnueabi-strip myprog

to remove symbols after debugging is done which shrinks the executable a lot.

It is important to manipulate the config scripts so they use the cross compiler and add the pthread trick to the link command lines. Usually that is done by setting some CC and LD related environment variables accordingly.

br
/Martin

________________________________________
From: keshav yadav [keshav.yadav2005@xxxxxxxxx]
Sent: Tuesday, May 11, 2010 3:56 AM
To: arm-gnu@xxxxxxxxxxxxxxxx
Subject: [arm-gnu] Compile Android_Kernel with code sourcery

Hi all,

I need small clarification, is it possible to Build android kernel
with code EABI based ARM tool chain.

Also on net I found that android use bionic Glibc. Is it different. if
so, how we can add in codesourcery toolchain ?

Kind regards

Keshav