cflags

lkraav edited this page Mar 8, 2011 · 3 revisions

Choosing CFLAGS

First of all, I strongly recommend reading ARM architecture Wikipedia entry.

Both N810 and N800 tablets have ARM1136JF-S CPU, which supports:

From info above we can easily set -mtune=arm1136jf-s (make binaries tweaked to run as fast as possible on ARM1136JF-S) and -mfpu=vfp (use VFP for floating point operations).

march can be either set to armv6j or armv6l. The difference is that armv6j specifies arch with Jazelle support and N8x0 CPUs have it. But no known opensource software can use it because its specs are closed and only given to JVM vendors. So choosing between these two values is just a matter of taste.

And the last (and the most confusing one) -Os vs -O2. -Os promises to produce as small binaries as possible (which reduces required disk space, RAM usage for code and makes programs start faster because less code needs to be read from disk). However, there are rumours that some programs break with -Os (this is the reason why glibc and gcc are always built with -O2 in Gentoo). On the other hand, -O2 makes a little bigger binaries (5-10%) but with additional optimizations that (theoretically) allows faster execution. The choice is up to you.

After all that said, current recommended CFLAGS are:

CFLAGS="-Os -pipe -march=armv6j -mtune=arm1136jf-s -mfpu=vfp -fomit-frame-pointer"

crossdev sets some stuff up automatically for you, so using that structure is also OK:

MARCH_TUNE="-march=armv6j -mtune=arm1136jf-s -mfpu=vfp"
CFLAGS="-Os -pipe ${MARCH_TUNE} -fomit-frame-pointer -I${ROOT}usr/include/ -I${ROOT}include/"