Hello,
How can I set gcc compiler flags for optimizations when I compile a kernel ?
I followed succesfully the instructions on https://docs.01.org/clearlinux/latest/guides/kernel/kernel-development.html but I cannot seem to figure out how to set the flags.
I have a i9 9900kf cpu which means skylake
for -mtune=
(as coffee lake does not exist separately). My env
and /usr/share/defaults/etc/profile
both show the same situation for CFLAGS
and CXXFLAGS
, in which there is -mtune=skylake
, but when I compile the kernel it always shows -march=westmere
and -mtune=haswell
in both CFLAGS
and CXXFLAGS
.
In the kernel Makefile there is a:
# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments KBUILD_CPPFLAGS += $(KCPPFLAGS) KBUILD_AFLAGS += $(KAFLAGS) KBUILD_CFLAGS += $(KCFLAGS)
section, but settings KCFLAGS
and KCPPFLAGS
changes nothing.
grep
-ing for westmere
or haswell
gives no result in the clearlinux/packages/linux
directory, so these are not written anywhere. How does the kernel make process even decide what flags to use ?
Also, -march
used to include -mtune
but by other people’s testing this is no longer the case. So, should I use both, should I use only one. Is it better to use -march=native
and/or -mtune=native
(I gues it would choose skylake
) … I have heard that that can give a different final binary, as well even if the correct -mtune
and -march
are chosen right.
So, which ones are important among: CFLAGS
, CXXFLAGS
, CPPFLAGS
, AFLAGS
and LDFLAGS
?
And how can I set them ?
And how about -mtune
and/or -march
+ skylake
or native
?
Also, if this is the wrong section of the forum to post this in - please move it to another … I couldn’t choose between general discussion and dev, and since I am not a dev … I figured it should be here.
I am going to be running something heavy on my cpu, so I want to sqweeze it to the limit (plus I have overclocked it pretty decent) and I am also simply always interested in optimization.