You are not logged in.

#1 2013-03-03 19:52:26

Kalrish
Member
Registered: 2013-02-27
Posts: 62

[SOLVED]Is it possible to compile the Linux kernel with -march=native?

I'm sorry for posting this, because I bet it's very, very common, but have had no luck searching for it.

Now that Linux 3.8.1 is coming to the AUR (well... I guess...) I'd like to compile it by myself, disabling lots of things that I don't need, and of course optimizing it!
-march=native seems to be the best optimisation option, but I'm wondering if it's possible to use it to compile the Linux kernel.

Thank you all, best regards

P.S.: I have -O2 in my /etc/makepkg.conf. Is there any reason to not put -O3 instead? Does anybody know of any other optimisation options?

Last edited by Kalrish (2013-03-06 17:19:17)

Offline

#2 2013-03-03 20:25:09

brebs
Member
Registered: 2007-04-03
Posts: 3,413

Re: [SOLVED]Is it possible to compile the Linux kernel with -march=native?

Previous threads:

https://bbs.archlinux.org/viewtopic.php?id=97999
http://forums.gentoo.org/viewtopic-t-944782.html

There's some info in the files under gcc_patch.

So, it looks like you might get a *tiny* improvement.

-O3 does not make apps magically faster, sadly wink It can introduce compiler bugs, and make apps slower/buggy.

Offline

#3 2013-03-06 11:42:32

straykat
Member
From: Queensland, Australia
Registered: 2009-12-06
Posts: 60

Re: [SOLVED]Is it possible to compile the Linux kernel with -march=native?

The Linux Kernel uses it's own HOSTCFLAGS & HOSTCXXFLAGS in the Makefile. Any changers will need to be done here. The stock optimisation is O2.

There is no "march=" as you you select your arch. from make menuconfig ---> Processor type and features  ---> Processor family (Generic-x86-64)  --->.

Suggested reading: http://forums.gentoo.org/viewtopic-t-24849-start-0.html

Offline

#4 2013-03-06 11:53:30

graysky
Member
From: /run/user/1000
Registered: 2008-12-01
Posts: 8,444
Website

Re: [SOLVED]Is it possible to compile the Linux kernel with -march=native?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Online

#5 2013-03-06 17:18:59

Kalrish
Member
Registered: 2013-02-27
Posts: 62

Re: [SOLVED]Is it possible to compile the Linux kernel with -march=native?

Ok, thank you all! Very useful info.

Maybe I'm a bit 'aggressive', but I think it's right to try to get the best performance - and also to choose what to use! Marking as "[SOLVED]", thank you.

Offline

#6 2013-04-06 13:48:04

graysky
Member
From: /run/user/1000
Registered: 2008-12-01
Posts: 8,444
Website

Re: [SOLVED]Is it possible to compile the Linux kernel with -march=native?

In this commit of the patch, I added an option that will pass a literal `-march=native` to the compiler while making a kernel.  Apply the patch yourself or try it out in v3.8.6-1 of linux-ck.  Seems to be working fine on my box.

Last edited by graysky (2013-04-06 13:49:38)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Online

#7 2013-04-06 18:11:57

Thaodan
Member
From: Dortmund, Nordrein-Westfalen
Registered: 2012-04-28
Posts: 433

Re: [SOLVED]Is it possible to compile the Linux kernel with -march=native?

Linux-pf has this patch applied too (currently a older version but in next release I'll use grayskys patch).


Linux odin 3.13.1-pf #1 SMP PREEMPT Wed Mar 5 21:47:28 CET 2014 x86_64 GNU/Linux

Offline

#8 2013-04-07 10:37:49

jim1960
Member
Registered: 2011-08-19
Posts: 24

Re: [SOLVED]Is it possible to compile the Linux kernel with -march=native?

graysky wrote:

In this commit of the patch, I added an option that will pass a literal `-march=native` to the compiler while making a kernel.  Apply the patch yourself or try it out in v3.8.6-1 of linux-ck.  Seems to be working fine on my box.

Does the patch of kernel-38-gcc47-2.patch.gz also applied for gcc v4.8?

PS:
Many packages used patch of gcc v4.7,  whether these packages have no ploblem if i upgrade to gcc v4.8?


Sorry for my poor english.

Offline

#9 2013-04-07 11:24:39

graysky
Member
From: /run/user/1000
Registered: 2008-12-01
Posts: 8,444
Website

Re: [SOLVED]Is it possible to compile the Linux kernel with -march=native?

@jim - Yes.  Bad naming on my part which has now been corrected:
https://github.com/graysky2/kernel_gcc_ … d46e8707ea

Thanks for the report.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Online

Board footer

Powered by FluxBB