2003-07-24 07:01:15

by CIJOML

[permalink] [raw]
Subject: passing my own compiler options into linux kernel compiling

Hello,

I use gcc-3.3 and I would like compile my kernel with flags:

-O4 -march=pentium3 -mcpu=pentium3

Is there any way to do this?
Maybe there should be a possibility in menuconfig and xconfig for users
specify their own compiler options.

What do you think about this people?

Michal


2003-07-24 07:43:59

by Hacksaw

[permalink] [raw]
Subject: Re: passing my own compiler options into linux kernel compiling

>Maybe there should be a possibility in menuconfig and xconfig for users
>specify their own compiler options.

The system does take the chip into account, as far as I remember. It's one of
the first few options of the config system.

As to the -O4 option, it's important to think about what optimizations it's
doing. Many of the critical functions in the kernel are hand coded assembler,
no small amount of work. The other functions might gain from this, but I bet
they don't. They might even lose from it.

In any case it appears that if you modify the HOSTCFLAGS in the top level
Makefile, you can add these options. Do be careful. The data you save may be
your own.
--
A principle is universal.
A rule is specific.
A law is invariable.
http://www.hacksaw.org -- http://www.privatecircus.com -- KB1FVD


2003-07-24 07:46:10

by Martin Zwickel

[permalink] [raw]
Subject: Re: passing my own compiler options into linux kernel compiling

On Thu, 24 Jul 2003 09:16:17 +0200
Michal Semler <[email protected]> bubbled:

> Hello,
>
> I use gcc-3.3 and I would like compile my kernel with flags:
>
> -O4 -march=pentium3 -mcpu=pentium3
-O4 is useless. max is -O3

try this file: arch/i386/Makefile
there is something like:

ifdef CONFIG_MPENTIUMIII
CFLAGS += -march=i686
endif

maybe this helps...

Regards,
Martin

--
MyExcuse:
Arcserve crashed the server again.

Martin Zwickel <[email protected]>
Research & Development

TechnoTrend AG <http://www.technotrend.de>

2003-07-24 08:35:24

by CIJOML

[permalink] [raw]
Subject: Re: passing my own compiler options into linux kernel compiling

Hi,

-O4 is a feature - for example MPlayer (http://www.mplayerhq.hu) using it.

Is easyer way of passing these args planned? Editing source every time I
change kernel is not goood way. make oldconfig adding these args is better
way.

Michal

Dne ?t 24. ?ervence 2003 10:01 jste napsal(a):
> On Thu, 24 Jul 2003 09:16:17 +0200
>
> Michal Semler <[email protected]> bubbled:
> > Hello,
> >
> > I use gcc-3.3 and I would like compile my kernel with flags:
> >
> > -O4 -march=pentium3 -mcpu=pentium3
>
> -O4 is useless. max is -O3
>
> try this file: arch/i386/Makefile
> there is something like:
>
> ifdef CONFIG_MPENTIUMIII
> CFLAGS += -march=i686
> endif
>
> maybe this helps...
>
> Regards,
> Martin

2003-07-24 08:40:01

by Christoph Hellwig

[permalink] [raw]
Subject: Re: passing my own compiler options into linux kernel compiling

On Thu, Jul 24, 2003 at 10:50:25AM +0200, Michal Semler wrote:
> Hi,
>
> -O4 is a feature - for example MPlayer (http://www.mplayerhq.hu) using it.

Maybe you and the mplayer folks want to take a look at gcc's "handling"
of -O4..

2003-07-24 09:16:55

by J.A. Magallon

[permalink] [raw]
Subject: Re: passing my own compiler options into linux kernel compiling


On 07.24, Christoph Hellwig wrote:
> On Thu, Jul 24, 2003 at 10:50:25AM +0200, Michal Semler wrote:
> > Hi,
> >
> > -O4 is a feature - for example MPlayer (http://www.mplayerhq.hu) using it.
>
> Maybe you and the mplayer folks want to take a look at gcc's "handling"
> of -O4..
>

http://freshmeat.net/articles/view/730/

;)

--
J.A. Magallon <[email protected]> \ Software is like sex:
werewolf.able.es \ It's better when it's free
Mandrake Linux release 9.2 (Cooker) for i586
Linux 2.4.22-pre7-jam1m (gcc 3.3.1 (Mandrake Linux 9.2 3.3.1-0.6mdk))

2003-07-24 09:26:24

by J.A. Magallon

[permalink] [raw]
Subject: Re: passing my own compiler options into linux kernel compiling


On 07.24, Christoph Hellwig wrote:
> On Thu, Jul 24, 2003 at 10:50:25AM +0200, Michal Semler wrote:
> > Hi,
> >
> > -O4 is a feature - for example MPlayer (http://www.mplayerhq.hu) using it.
>
> Maybe you and the mplayer folks want to take a look at gcc's "handling"
> of -O4..
>

BTW, is there any way to get from gcc the options it uses when you
put -ON in the options ?
(It's not I don't trust documentation, just want to double check ;))

--
J.A. Magallon <[email protected]> \ Software is like sex:
werewolf.able.es \ It's better when it's free
Mandrake Linux release 9.2 (Cooker) for i586
Linux 2.4.22-pre7-jam1m (gcc 3.3.1 (Mandrake Linux 9.2 3.3.1-0.6mdk))

2003-07-24 12:22:31

by James Cloos

[permalink] [raw]
Subject: Re: passing my own compiler options into linux kernel compiling

>>>>> "Michal" == Michal Semler <[email protected]> writes:

Michal> Is easyer way of passing these args planned? Editing source
Michal> every time I change kernel is not goood way. make oldconfig
Michal> adding these args is better way.

In 2.6 arch/i386/Makefile looks like this;

cflags-$(CONFIG_M686) += -march=i686
cflags-$(CONFIG_MPENTIUMII) += $(call check_gcc,-march=pentium2,-march=i686)
cflags-$(CONFIG_MPENTIUMIII) += $(call check_gcc,-march=pentium3,-march=i686)
cflags-$(CONFIG_MPENTIUM4) += $(call check_gcc,-march=pentium4,-march=i686)

et al for the other cpu CONFIG options.

IOW it pretty much makes the right choices w/o editing.

-JimC

2003-07-24 20:43:33

by Sam Ravnborg

[permalink] [raw]
Subject: Re: passing my own compiler options into linux kernel compiling

On Thu, Jul 24, 2003 at 09:16:17AM +0200, Michal Semler wrote:
> Hello,
>
> I use gcc-3.3 and I would like compile my kernel with flags:
>
> -O4 -march=pentium3 -mcpu=pentium3
>
> Is there any way to do this?
Only way to specify -O4 is to manually edit top-level Makefile.
Change the assignment to CFLAGS (not hOSTCFLAGS as someone suggested).

The -m options are set in arch/i386/Makefile.
The best way to set them is to select the correct processor type.

Sam

2003-07-24 21:26:04

by Ed Sweetman

[permalink] [raw]
Subject: Re: passing my own compiler options into linux kernel compiling

Sam Ravnborg wrote:
> On Thu, Jul 24, 2003 at 09:16:17AM +0200, Michal Semler wrote:
>
>>Hello,
>>
>>I use gcc-3.3 and I would like compile my kernel with flags:
>>
>>-O4 -march=pentium3 -mcpu=pentium3

-mcpu is taken care of by -march in gcc3
-O4 does nothing, -O3 is the highest gcc3 goes, and -O3 does cause
problems with certain code.

I'd suggest also -ftracer as it is supposed to help your standard -O2
level optimizations do their jobs. How well, probably not very noticable
in real life, but then neither is -march=pentium3 over i686.


>>Is there any way to do this?
>
> Only way to specify -O4 is to manually edit top-level Makefile.
> Change the assignment to CFLAGS (not hOSTCFLAGS as someone suggested).
>
> The -m options are set in arch/i386/Makefile.
> The best way to set them is to select the correct processor type.
>
> Sam
>
basically, makefiles are supposed to add the value of CFLAGS to their
flag variable. CXXFLAGS for c++ arguments. But i understand why the
kernel doesn't do this since it needs strict management over the build.

2003-07-24 23:13:17

by Kurt Wall

[permalink] [raw]
Subject: Re: passing my own compiler options into linux kernel compiling

Quoth Michal Semler:
> Hello,
>
> I use gcc-3.3 and I would like compile my kernel with flags:
>
> -O4 -march=pentium3 -mcpu=pentium3

Although it might be handled differently elsewhere, this snippet
from gcc/toplev.c suggests -O4 buys you nothing you don't get from
-O3:

if (optimize >= 3)
{
flag_inline_functions = 1;
flag_rename_registers = 1;
}

Kurt
--
Substitute "damn" every time you're inclined to write "very"; your
editor will delete it and the writing will be just as it should be.
-- Mark Twain