View previous topic :: View next topic |
Author |
Message |
Marel n00b
Joined: 29 Apr 2006 Posts: 17 Location: Serbia
|
Posted: Sun May 07, 2006 6:03 pm Post subject: |
|
|
I tried
Code: | # export CFLAGS_KERNEL="athlon-xp"
# make V=1 |
but in output is still only athlon (without xp). Is there something else to do? |
|
Back to top |
|
|
Enlight Advocate
Joined: 28 Oct 2004 Posts: 3519 Location: Alsace (France)
|
|
Back to top |
|
|
charlie n00b
Joined: 21 Oct 2007 Posts: 36
|
Posted: Tue Jul 02, 2013 4:54 am Post subject: |
|
|
This function, that you can paste into your .bashrc file, uses the MAKEOPTS and CFLAGS variables from /etc/portage/make.conf to compile your kernel with.
Code: | cdku () {
JOBS=`cat /etc/portage/make.conf | grep ^MAKEOPTS | sed 's@MAKEOPTS="\(.*\)"$@\1@1'`
cd /usr/src/linux &&
mv -v Makefile{,.orig} &&
cat Makefile.orig | sed 's@CFLAGS_KERNEL =@CFLAGS_KERNEL +=@1' > Makefile &&
export CFLAGS_KERNEL=`cat /etc/portage/make.conf | grep ^CFLAGS | sed 's@CFLAGS="\(.*\)"$@\1@1'` &&
sed -i "s@\(export.*INSTALL_PATH\) ?= /boot@\1=/boot@g" Makefile ;
make all ${JOBS} && make modules_install && make firmware && make firmware_install && make install ;
sed -i "s@\(export.*INSTALL_PATH\)=/boot@\1 ?= /boot@g" Makefile
} |
If using lilo--the sed instruction changing the INSTALL_PATH line in "Makefile" is there just in case you are compiling the kernel from git and don't want to have a modified Makefile interfering with your "git pull". |
|
Back to top |
|
|
Massimo B. Veteran
Joined: 09 Feb 2005 Posts: 1810 Location: PB, Germany
|
Posted: Tue Apr 04, 2017 9:34 am Post subject: |
|
|
Is the guide about exporting CFLAGS_KERNEL still valid today?
I was warned to change anything on the kernel CFLAGS as the kernel is very restrictive about that and rarely uses floating point arithmetic at all, however there have been drivers reported to use that..
Anyway, usually I would prefer some -march=native, but as distcc isn't compatible with that I have set the explicit CFLAGS in make.conf, that would be applied by -march=native:
Code: | # gcc -march=native -v -E - < /dev/null 2>&1 | grep cc1 | perl -pe 's/ -mno-\S+//g; s/^.* - //g;'
-march=sandybridge -mmmx -msse -msse2 -msse3 -mssse3 -mcx16 -msahf -maes -mpclmul -mpopcnt -mavx -msse4.2 -msse4.1 -mfxsr -mxsave -mxsaveopt --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=4096 -mtune=sandybridge -fstack-protector-strong |
Using distcc for the kernel build as well, I guess the CONFIG_MNATIVE wouldn't work there either, so I plan to use some Code: | export CFLAGS_KERNEL="-march=sandybridge -mmmx -msse -msse2 -msse3 -mssse3 -mcx16 -msahf -maes -mpclmul -mpopcnt -mavx -msse4.2 -msse4.1 -mfxsr -mxsave -mxsaveopt --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=4096 -mtune=sandybridge -fstack-protector-strong | ..though discouraged on the ##kernel channel. Just trying, this is Gentoo.
Anyone with comments or experience about that?
How would I pass that to genkernel, could that work in a command like this or is there some better place to set the build environment?
Code: | CFLAGS_KERNEL="-march=sandybridge -mmmx -msse -msse2 -msse3 -mssse3 -mcx16 -msahf -maes -mpclmul -mpopcnt -mavx -msse4.2 -msse4.1 -mfxsr -mxsave -mxsaveopt --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=4096 -mtune=sandybridge -fstack-protector-strong" pump genkernel all --kernel-cc=distcc --makeopts="-j7 -l2" --loglevel=4 && grub-mkconfig -o /boot/grub/grub.cfg |
_________________ HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770 |
|
Back to top |
|
|
Sadako Advocate
Joined: 05 Aug 2004 Posts: 3792 Location: sleeping in the bathtub
|
Posted: Tue Apr 04, 2017 6:06 pm Post subject: |
|
|
There is a kernel patch to let you specify a more precise processor/family, and enable the relevant -march flag, might be worth trying;
https://github.com/graysky2/kernel_gcc_patch
Been meaning to try it myself, just haven't gotten around to it yet.
BTW, for most options the only thing missing from the proper -march setting that march=native adds is the param options for specifying cache sizes. _________________ "You have to invite me in" |
|
Back to top |
|
|
Massimo B. Veteran
Joined: 09 Feb 2005 Posts: 1810 Location: PB, Germany
|
Posted: Thu Apr 06, 2017 12:39 pm Post subject: |
|
|
I guess this is done by USE="experimental", but alas ck-sources don't have that. For comparison I emerged gentoo-sources with that experimental, but I can't see any more features in make menuconfig around CONFIG_MSANDYBRIDGE=y.
Anyway I just patched the Makefile for a try: Code: | # egrep "HOSTC.*?FLAGS.* = " /usr/src/linux-4.10.8-ck/Makefile
HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -std=gnu89 -O2 -pipe -fomit-frame-pointer -march=sandybridge -mmmx -msse -msse2 -msse3 -mssse3 -mcx16 -msahf -maes -mpclmul -mpopcnt -mavx -msse4.2 -msse4 -mfxsr -mxsave -mxsaveopt --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=4096 -mtune=sandybridge -fstack-protector-strong
HOSTCXXFLAGS = -O2 -pipe -fomit-frame-pointer -march=sandybridge -mmmx -msse -msse2 -msse3 -mssse3 -mcx16 -msahf -maes -mpclmul -mpopcnt -mavx -msse4.2 -msse4 -mfxsr -mxsave -mxsaveopt --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=4096 -mtune=sandybridge -fstack-protector-strong -fvisibility-inlines-hidden |
A kernel made like this runs fine currently, does my kernel have the CFLAGS applied now?
I wondered that -march=sandybridge sets a lot less than -march=native.
In the past there was also --help=target to make the settings visible, but due to a old bug 39851 --help=target is a liar: Code: | vimdiff <(gcc -march=native -Q --help=target) <(gcc -march=sandybridge -Q --help=target) |
_________________ HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770 |
|
Back to top |
|
|
|