Author Topic: Kernel build/CFLAGS  (Read 210 times)

Offline xr200

  • Full Member
  • ***
  • Posts: 96
Kernel build/CFLAGS
« on: October 16, 2012, 11:48:30 AM »
Is there a way to see what compiler optimization flags were used to compile a particular PCLOS kernel,
or more generally, what optimization flags were used to compile any particular PCLOS package?

xr200

Offline The Chief

  • Hero Member
  • *****
  • Posts: 2258
Re: Kernel build/CFLAGS
« Reply #1 on: October 16, 2012, 11:57:13 AM »
Grab the source and look at the make file.

Retired Senior Chief, Retired Software Engineer, Active GrandPa

Offline gseaman

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3801
Re: Kernel build/CFLAGS
« Reply #2 on: October 16, 2012, 07:32:54 PM »
Grab the source and look at the make file.

The default CFLAGS for rpmbuild is:
Code: [Select]
--O2  -pipe -Wformat -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fomit-frame-pointer -march=i586 -mtune=generic -fasynchronous-unwind-tables
If the kernel has different settings it would be in the spec file. I am not using my build machine at the moment so I can't look, but I will try later and post if there are any different settings. Is there a specific optimization that you are looking for?

Galen

Offline xr200

  • Full Member
  • ***
  • Posts: 96
Re: Kernel build/CFLAGS
« Reply #3 on: October 16, 2012, 09:12:13 PM »
I'm interested in learning how PCLOS is built, and to see if it is possibly worthwhile compiling
my own kernel tailored to my specific hardware.

Here's some specific questions after reading your reply:

1. What's a spec file?  How can I find one for any specific PCLOS package (not just a kernel)?
2. The gcc manual page says -fomit-frame-pointer is on automatically for -O, -O2, and -O3.  Isn't it
    redundant to specifically include it?
3. Since I have a i686, presumably I would get some gain by compiling my own kernel with -march=native.
4. Why isn't -O3 used instead of -O2?

Just wondering, I don't pretend to know what's right....

Offline gseaman

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3801
Re: Kernel build/CFLAGS
« Reply #4 on: October 16, 2012, 10:18:26 PM »
I'm interested in learning how PCLOS is built, and to see if it is possibly worthwhile compiling
my own kernel tailored to my specific hardware.

Here's some specific questions after reading your reply:

1. What's a spec file?  How can I find one for any specific PCLOS package (not just a kernel)?
A spec file is the build instructions that are used to build the rpm. It is in the src.rpm.

Quote
2. The gcc manual page says -fomit-frame-pointer is on automatically for -O, -O2, and -O3.  Isn't it redundant to specifically include it?
Probably, but sometimes things are listed explicitly so that whoever builds the packages remembers what is selected by default. (This is a just a guess on my part.)

Quote
3. Since I have a i686, presumably I would get some gain by compiling my own kernel with -march=native.
I believe Tex found that the difference between a kernel built with i586 and i686 was insignificant. You could certainly try for yourself, though.

Quote
4. Why isn't -O3 used instead of -O2?
Originally, -03 was risky, I think. I am not sure that is true now, if it ever was. Again, it may also be the difference in the kernels was not significant.

Quote
Just wondering, I don't pretend to know what's right....
Good questions. Although, I've built quite a few kernels, I've not played with these options before.

Galen