1 |
On Wed, 29 Apr 2015 13:31:13 +0200 Ralf wrote: |
2 |
> Hi, |
3 |
> |
4 |
> just a short question: I don't like genkernel, I always compile my |
5 |
> kernel manually using menuconfig. |
6 |
> So the CFLAGs of my make.conf won't get applied. |
7 |
> |
8 |
> What is the best way to (persistently) set the CFLAGs for the kernel |
9 |
> compilation? |
10 |
> |
11 |
> - I don't like invoking 'CFLAGS="-O2 -march=foo"make' |
12 |
> - I don't want to set CFLAGS as a persistent environment variable. |
13 |
> - I don't want to modify the kernel Makefile |
14 |
> |
15 |
> Does it actually make sense to set an optimization level and -march? |
16 |
|
17 |
Short answer: don't even try to use general CFLAGS for a kernel, |
18 |
you'll badly damage its performance. |
19 |
|
20 |
Long answer: context switching between integer and floating point |
21 |
is very expensive, that's why kernel is integer only, any |
22 |
non-integer calculations are implemented using fixed point (integer |
23 |
numbers from CPU's POW). That's why kernel makes sure that no |
24 |
floating point instructions sneaks in using CFLAGS, you may see a |
25 |
lot of -mno-${intrucion_set} flags when running make -V. Futhermore |
26 |
kernel needs several memory alignment flags which should not be |
27 |
removed as well. |
28 |
|
29 |
The proper way to fine-tune CFLAGS for a local CPU support will be |
30 |
to use kernel-gcc-patches[1], as was pointed in other reply already. |
31 |
This code will ensure that proper CPU support is enabled while |
32 |
keeping all floating point instructions disabled. Just apply a |
33 |
patch and select native arch in CPU arch menu. |
34 |
|
35 |
[1] https://github.com/graysky2/kernel_gcc_patch |
36 |
|
37 |
Best regards, |
38 |
Andrew Savchenko |