On Wed, 29 Apr 2015 13:31:13 +0200 Ralf wrote:
> Hi,
> 
> just a short question: I don't like genkernel, I always compile my
> kernel manually using menuconfig.
> So the CFLAGs of my make.conf won't get applied.
> 
> What is the best way to (persistently) set the CFLAGs for the kernel
> compilation?
> 
> - I don't like invoking 'CFLAGS="-O2 -march=foo"make'
> - I don't want to set CFLAGS as a persistent environment variable.
> - I don't want to modify the kernel Makefile
> 
> Does it actually make sense to set an optimization level and -march?

Short answer: don't even try to use general CFLAGS for a kernel,
you'll badly damage its performance.

Long answer: context switching between integer and floating point
is very expensive, that's why kernel is integer only, any
non-integer calculations are implemented using fixed point (integer
numbers from CPU's POW). That's why kernel makes sure that no
floating point instructions sneaks in using CFLAGS, you may see a
lot of -mno-${intrucion_set} flags when running make -V. Futhermore
kernel needs several memory alignment flags which should not be
removed as well.

The proper way to fine-tune CFLAGS for a local CPU support will be
to use kernel-gcc-patches[1], as was pointed in other reply already.
This code will ensure that proper CPU support is enabled while
keeping all floating point instructions disabled. Just apply a
patch and select native arch in CPU arch menu.

[1] https://github.com/graysky2/kernel_gcc_patch

Best regards,
Andrew Savchenko

Attachment: pgpuqTvm6pXaj.pgp
Description: PGP signature

Reply via email to