Set cpu explicitly in kernel compiles
PATCH 1/1 Set cpu explicitly in kernel compiles
What do people think of this patch? The motivation for it is that a biarch gcc-4.0 will by default tune for POWER4, even for a 32-bit compile, meaning that we end up with a lot of nops we don't need. This also takes out -mstring.
With this, the text size reduces by about 120k for my normal config when compiling with a biarch gcc-4.0. The text size also reduces slightly when compiling with the Debian gcc-3.3.5 (32-bit only, not biarch).
If there are no objections I'll send this to Andrew and Linus.
Paul.
arch/ppc/Makefile +4 -5
@@ -23,15 +23,14 @@ LDFLAGS_vmlinux := -Ttext $(KERNELLOAD) -Bstatic CPPFLAGS += -Iarch/$(ARCH) AFLAGS += -Iarch/$(ARCH) -CFLAGS += -Iarch/$(ARCH) -msoft-float -pipe \ - -ffixed-r2 -mmultiple +CFLAGS += -Iarch/$(ARCH) -msoft-float -pipe -ffixed-r2 -mmultiple CPP = $(CC) -E $(CFLAGS) CHECKFLAGS += -D__powerpc__ -ifndef CONFIG_E500 -CFLAGS += -mstring -endif +cpu-opt-$(CONFIG_6xx) += -mcpu=750 -mtune=7450 + +CFLAGS += $(cpu-opt-y) cpu-as-$(CONFIG_PPC64BRIDGE) += -Wa,-mppc64bridge cpu-as-$(CONFIG_4xx) += -Wa,-m405
Quoted 1 line · Paul Mackerras
+cpu-opt-$(CONFIG_6xx) += -mcpu=750 -mtune=7450
What about cores that aren't CONFIG_6xx (8xx, 4xx, e500, etc.)?
How about we create a CONFIG_GCC_CPUOPT and CONFIG_AS_OPT, and just get these out of the configuration file?
-- Dan
Quoted 6 lines · Dan Malek
Quoted 1 line · Paul Mackerras
+cpu-opt-$(CONFIG_6xx) += -mcpu=750 -mtune=7450
What about cores that aren't
CONFIG_6xx(8xx, 4xx, e500, etc.)?
There's two choices. We can either go down the route x86 has of each CPU family choice defaulting to a cpu-opt-..., or we could do roughly what we do today and force the default cpu/tune to be whatever the default is on gcc-3.3.x (which I assume is really gcc-3.x.x, but..).
Since there are folks working on optimizing toolchains on at least some of the newer CPUs, I'd be inclined to say we should do something like cpu-opt-y := ... gcc-3.3.x defaults ... cpu-opt-$(CONFIG_6xx) := -mcpu=750 -mtune=7450 cpu-opt-$(CONFIG_8xx) := -mcpu=800 -mtune=800 # Or whatever it is..
CFLAGS += $(cpu-opt-y)
Quoted 2 lines
How about we create a
CONFIG_GCC_CPUOPTandCONFIG_AS_OPT, and just get these out of the configuration file?
Ick. It's possible, but unfun, to go from CONFIG_FOO="string" to cflags.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 5 lines · Tom Rini
Since there are folks working on optimizing toolchains on at least some of the newer CPUs, I'd be inclined to say we should do something like cpu-opt-y := ... gcc-3.3.x defaults ... cpu-opt-$(CONFIG_6xx) := -mcpu=750 -mtune=7450 cpu-opt-$(CONFIG_8xx) := -mcpu=800 -mtune=800 # Or whatever it is..
While you're at it, how about breaking out the 970 as separate from the POWER4?
Chris
Quoted 1 line · Dan Malek
What about cores that aren't
CONFIG_6xx(8xx, 4xx, e500, etc.)?
Well, what about them? I didn't change anything for them (except to remove the -mstring). What -mcpu or -mtune options do you want for them?
Quoted 2 lines
How about we create a
CONFIG_GCC_CPUOPTandCONFIG_AS_OPT, and just get these out of the configuration file?
No. We already have enough configuration questions that are unanswerable by ordinary mortals.
Paul.
Quoted 2 lines · Paul Mackerras
Well, what about them? I didn't change anything for them (except to remove the -mstring). What -mcpu or -mtune options do you want for them?
The only reason I mentioned it is the "new" default behavior of the compiler is appropriate for only a very small subset of the cores, and your solution only addresses some of the ones affected. In the past, the default behavior was fine for all but your special case :-)
My concern wasn't specifically for which options I wanted, but rather for the mechanism to set all of them now that it appears we need to do that.
Quoted 2 lines
No. We already have enough configuration questions that are unanswerable by ordinary mortals.
OK, but we still need some kind of indication from the configuration process. It seems to me it would be easier (and more logical) to have the default behavior work like it has in the past, and use the special options for the POWER4, which we already know in the configuration.
Thanks.
-- Dan
Quoted 2 lines · Dan Malek
The only reason I mentioned it is the "new" default behavior of the compiler is appropriate for only a very small subset of the cores,
Subset of which set of cores? Do you mean "small subset of 6xx cores" or "small subset of PPC cores"? I didn't change anything for non-6xx cores except to take out -mstring (if you really want that back, say so :). If you mean "small subset of 6xx cores" then are you objecting to the specific choice of "-mcpu=603 -mtune=7450", or what?
Quoted 3 lines
My concern wasn't specifically for which options I wanted, but rather for the mechanism to set all of them now that it appears we need to do that.
We don't *need* to do it any more than we did before. It's easy to set options for 4xx, 8xx, etc. - just say the word.
Quoted 5 lines
OK, but we still need some kind of indication from the configuration process. It seems to me it would be easier (and more logical) to have the default behavior work like it has in the past, and use the special options for the POWER4, which we already know in the configuration.
The problem isn't for POWER4, the problem is biarch gcc4 optimizing for POWER4 when we are compiling for 6xx.
Paul.
Quoted 18 lines · Paul Mackerras
Quoted 2 lines · Dan Malek
The only reason I mentioned it is the "new" default behavior of the compiler is appropriate for only a very small subset of the cores,
Subset of which set of cores? Do you mean "small subset of 6xx cores" or "small subset of PPC cores"? I didn't change anything for non-6xx cores except to take out -mstring (if you really want that back, say so :). If you mean "small subset of 6xx cores" then are you objecting to the specific choice of "-mcpu=603 -mtune=7450", or what?
Quoted 3 lines
My concern wasn't specifically for which options I wanted, but rather for the mechanism to set all of them now that it appears we need to do that.
We don't *need* to do it any more than we did before. It's easy to set options for 4xx, 8xx, etc. - just say the word.
Quoted 8 lines
Quoted 5 lines
OK, but we still need some kind of indication from the configuration process. It seems to me it would be easier (and more logical) to have the default behavior work like it has in the past, and use the special options for the POWER4, which we already know in the configuration.
The problem isn't for POWER4, the problem is biarch gcc4 optimizing for POWER4 when we are compiling for 6xx.
So here's where the confusion comes in. You're saying that even though (except .S files) no ppc32 kernel config was passing in explicit -mcpu=... or similar, only CONFIG_6xx is hurt by the gcc4 biarch thingy?
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 3 lines · Tom Rini
So here's where the confusion comes in. You're saying that even though (except .S files) no ppc32 kernel config was passing in explicit -mcpu=... or similar, only
CONFIG_6xxis hurt by the gcc4 biarch thingy?
Indeed, we were never using -mcpu, and maybe we should be.
The problem only comes up if you configure gcc4 as biarch. I can't imagine anyone building a biarch compiler for 4xx or 8xx. :)
Alan Modra tells me that gcc4 can support all the ppc families in the one binary, and that you can specify what cpu to use as the assumed default at configure time. If you specify --with-cpu=xxx at configure time you get scheduling for that particular cpu.
So yes, only CONFIG_6xx is affected by biarch gcc4 assuming POWER4. Other families would only be affected if you were using a generic gcc4, which won't work at present anyway, since we don't add -mcpu=xxx.
Paul.
Quoted 10 lines · Paul Mackerras
Quoted 3 lines · Tom Rini
So here's where the confusion comes in. You're saying that even though (except .S files) no ppc32 kernel config was passing in explicit -mcpu=... or similar, only
CONFIG_6xxis hurt by the gcc4 biarch thingy?Indeed, we were never using -mcpu, and maybe we should be.
The problem only comes up if you configure gcc4 as biarch. I can't imagine anyone building a biarch compiler for 4xx or 8xx. :)
I can, quite easily. Think someone like Dan doing dev from their nice shiney G5.
Quoted 9 lines
Alan Modra tells me that gcc4 can support all the ppc families in the one binary, and that you can specify what cpu to use as the assumed default at configure time. If you specify --with-cpu=xxx at configure time you get scheduling for that particular cpu.
So yes, only
CONFIG_6xxis affected by biarch gcc4 assuming POWER4. Other families would only be affected if you were using a generic gcc4, which won't work at present anyway, since we don't add -mcpu=xxx.
Why won't it work with generic gcc4 ? Will something more than a lot of extra nops be added?
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 2 lines · Tom Rini
Why won't it work with generic gcc4 ? Will something more than a lot of extra nops be added?
Well, say you are compiling for 405. You either need to have a gcc that was configured with --with-cpu=405, or you need to have hacked arch/ppc/Makefile to add -mcpu=405. In both cases the problem doesn't arise. It only arises if you have a biarch gcc4 that was configured without any --with-cpu=xxx option and is run without any -mcpu=xxx option.
If you think we should have -mcpu=xxx on the command line for 4xx, 44x, 8xx, etc., then that's fine, but that is a separate problem from what my patch was addressing (one which my patch might make it easier to fix, though).
Paul.
Quoted 4 lines · Paul Mackerras
If you think we should have -mcpu=xxx on the command line for 4xx, 44x, 8xx, etc., then that's fine, but that is a separate problem from what my patch was addressing (one which my patch might make it easier to fix, though).
I think that is exactly what we want, although I don't know how that is separate from the patch you sent. My original comment was the patch fixes the problem for only one of the cpu cores, not all of them. Which then led into the subsequent suggestion of making the biarch work like the past compilers, and we must specific the flags for POWER4 instead of the other way around. Without explicit -mcpu flags, the existing compiler behavior is just fine ..... but, I guess I'd be standing in the way of progress to want this :-)
Thanks.
-- Dan
Quoted 4 lines · Dan Malek
Quoted 1 line · Paul Mackerras
If you think we should have -mcpu=3Dxxx on the command line for =
4xx,
Quoted 7 lines
Quoted 1 line
44x, 8xx, etc., then that's fine, but that is a separate problem=20
from
Quoted 1 line
what my patch was addressing (one which my patch might make it=20
easier
Quoted 1 line
to fix, though).
I think that is exactly what we want, although I don't know how that =
is
Quoted 1 line
separate from the patch you sent.=A0 My original comment was the =
patch
Quoted 9 lines
fixes the problem for only one of the cpu cores, not all of them.=A0=20=
Which
then led into the subsequent suggestion of making the biarch work like the past compilers, and we must specific the flags for POWER4 instead of the other way around.=A0 Without explicit -mcpu flags, the existing compiler behavior is just fine .....=A0 but, I guess I'd be
standing
in the way of progress to want this :-)
I agree with Dan here. I think we should go ahead and extend the patch=20=
to set -mcpu and -mtune flags for the list of processors we have in=20 "Processor Type". If I'm building a kernel for e500 or 4xx I might as=20=
well get a kernel that is tuned a bit more for the subarch. =20 Additionally, there should be some expert override ability, so if I=20 really want to do -mcpu=3D7455 -mtune=3D7455 I can.
- kumar
Quoted 24 lines · Kumar Gala
Quoted 10 lines · Dan Malek
Quoted 2 lines · Paul Mackerras
If you think we should have -mcpu=xxx on the command line for 4xx, 44x, 8xx, etc., then that's fine, but that is a separate problem
from
Quoted 1 line
what my patch was addressing (one which my patch might make it
easier
Quoted 1 line
to fix, though).
Quoted 10 lines
I think that is exactly what we want, although I don't know how that is separate from the patch you sent.? My original comment was the patch fixes the problem for only one of the cpu cores, not all of them.? Which
then led into the subsequent suggestion of making the biarch work like the past compilers, and we must specific the flags for POWER4 instead of the other way around.? Without explicit -mcpu flags, the existing compiler behavior is just fine .....? but, I guess I'd be standing
in the way of progress to want this :-)
Quoted 4 lines
I agree with Dan here. I think we should go ahead and extend the patch to set -mcpu and -mtune flags for the list of processors we have in "Processor Type". If I'm building a kernel for e500 or 4xx I might as well get a kernel that is tuned a bit more for the subarch.
This is fine.
Quoted 2 lines
Additionally, there should be some expert override ability, so if I really want to do -mcpu=7455 -mtune=7455 I can.
Gack, no! It's quite a pain to go from CONFIG_FOO="string" into useable Makefile bits that the one we did have back in 2.4 is gone. That also implies gcc finally knows something about these cores that might be useful, which I don't think is the case, nor is it likely to be. But if we did want it, we'd probably go the route x86 has.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 11 lines · Tom Rini
Quoted 7 lines · Kumar Gala
Quoted 4 lines · Dan Malek
Quoted 1 line · Paul Mackerras
If you think we should have -mcpu=3Dxxx on the command line for=20=
4xx,
Quoted 1 line
Quoted 1 line
Quoted 1 line
44x, 8xx, etc., then that's fine, but that is a separate =
problem
Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
from
Quoted 1 line
what my patch was addressing (one which my patch might make it
easier
Quoted 1 line
to fix, though).
I think that is exactly what we want, although I don't know how=20
that is
Quoted 1 line
Quoted 1 line
separate from the patch you sent.? My original comment was the=20
patch
Quoted 1 line
Quoted 1 line
fixes the problem for only one of the cpu cores, not all of =
them.?
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Which
then led into the subsequent suggestion of making the biarch work like the past compilers, and we must specific the flags for =
POWER4
Quoted 4 lines
Quoted 1 line
Quoted 1 line
instead of the other way around.? Without explicit -mcpu flags,=20=
the
Quoted 1 line
Quoted 1 line
existing compiler behavior is just fine .....? but, I guess I'd =
be
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
standing
in the way of progress to want this :-)I agree with Dan here.=A0 I think we should go ahead and extend the=20=
patch
Quoted 2 lines
to set -mcpu and -mtune flags for the list of processors we have in "Processor Type".=A0 If I'm building a kernel for e500 or 4xx I =
might=20
Quoted 5 lines
as
Quoted 1 line
well get a kernel that is tuned a bit more for the subarch.=A0
This is fine.
Quoted 7 lines
Quoted 2 lines
Additionally, there should be some expert override ability, so if I really want to do -mcpu=3D7455 -mtune=3D7455 I can.
Gack, no!=A0 It's quite a pain to go from
CONFIG_FOO=3D"string" into=20=useable
Makefilebits that the one we did have back in 2.4 is gone.=A0 That =
also
Quoted 2 lines
implies gcc finally knows something about these cores that might be useful, which I don't think is the case, nor is it likely to be.=A0 =
But=20
Quoted 2 lines
if
we did want it, we'd probably go the route x86 has.
I'm not saying it has to be done via a CONFIG option, all I'm saying is=20=
if I want to explicitly use GCC then I would hope we could somehow=20 disable it being override.
- kumar=
Quoted 52 lines · Kumar Gala
Quoted 41 lines · Tom Rini
Quoted 7 lines · Kumar Gala
Quoted 4 lines · Dan Malek
Quoted 1 line · Paul Mackerras
If you think we should have -mcpu=xxx on the command line for
4xx,
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
44x, 8xx, etc., then that's fine, but that is a separate problem
from
Quoted 1 line
what my patch was addressing (one which my patch might make it
easier
Quoted 1 line
to fix, though).
I think that is exactly what we want, although I don't know how
that is
Quoted 1 line
Quoted 1 line
separate from the patch you sent.? My original comment was the
patch
Quoted 5 lines
Quoted 5 lines
fixes the problem for only one of the cpu cores, not all of them.? Which
then led into the subsequent suggestion of making the biarch work like the past compilers, and we must specific the flags for POWER4 instead of the other way around.? Without explicit -mcpu flags,the
Quoted 5 lines
Quoted 3 lines
existing compiler behavior is just fine .....? but, I guess I'd be standing
in the way of progress to want this :-)I agree with Dan here.? I think we should go ahead and extend the
patch
Quoted 2 lines
to set -mcpu and -mtune flags for the list of processors we have in "Processor Type".? If I'm building a kernel for e500 or 4xx I might
as
Quoted 1 line
well get a kernel that is tuned a bit more for the subarch.?
This is fine.
Quoted 2 lines
Additionally, there should be some expert override ability, so if I really want to do -mcpu=7455 -mtune=7455 I can.
Quoted 7 lines
Gack, no!? It's quite a pain to go from
CONFIG_FOO="string" into useableMakefilebits that the one we did have back in 2.4 is gone.? That also implies gcc finally knows something about these cores that might be useful, which I don't think is the case, nor is it likely to be.? But if
we did want it, we'd probably go the route x86 has.
Quoted 3 lines
I'm not saying it has to be done via a CONFIG option, all I'm saying is if I want to explicitly use GCC then I would hope we could somehow disable it being override.
If you're not doing it via CONFIG, that leaves manual (which is always an option) or seeing if passing CFLAGS on the cmdline overrides things, or adds to them.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 68 lines · Tom Rini
Quoted 11 lines · Kumar Gala
Quoted 8 lines · Tom Rini
Quoted 7 lines · Kumar Gala
Quoted 4 lines · Dan Malek
Quoted 1 line · Paul Mackerras
If you think we should have -mcpu=xxx on the command line
for
Quoted 2 lines
Quoted 2 lines
4xx,
Quoted 1 line
Quoted 1 line
Quoted 1 line
44x, 8xx, etc., then that's fine, but that is a separate
problem
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
from
Quoted 1 line
what my patch was addressing (one which my patch might make
it
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
easier
Quoted 1 line
to fix, though).
I think that is exactly what we want, although I don't know how
that is
Quoted 1 line
Quoted 1 line
separate from the patch you sent.? My original comment was the
patch
Quoted 1 line
Quoted 1 line
fixes the problem for only one of the cpu cores, not all of
them.?
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Which
then led into the subsequent suggestion of making the biarchwork
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
like the past compilers, and we must specific the flags for
POWER4
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
instead of the other way around.? Without explicit -mcpu
flags,
Quoted 2 lines
Quoted 2 lines
the
Quoted 1 line
Quoted 1 line
existing compiler behavior is just fine .....? but, I guess
I'd be
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
standing
in the way of progress to want this :-)I agree with Dan here.? I think we should go ahead and extend the
patch
Quoted 1 line
to set -mcpu and -mtune flags for the list of processors we have
in
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Processor Type".? If I'm building a kernel for e500 or 4xx I
might
Quoted 6 lines
Quoted 6 lines
as
Quoted 1 line
well get a kernel that is tuned a bit more for the subarch.?
This is fine.
Quoted 1 line
Additionally, there should be some expert override ability, so
if I
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
really want to do -mcpu=7455 -mtune=7455 I can.
Gack, no!? It's quite a pain to go from
CONFIG_FOO="string" into useableMakefilebits that the one we did have back in 2.4 is gone.? Thatalso
Quoted 1 line
Quoted 1 line
implies gcc finally knows something about these cores that might
be
Quoted 1 line
Quoted 1 line
useful, which I don't think is the case, nor is it likely to be.?
But
Quoted 4 lines
Quoted 2 lines
if
we did want it, we'd probably go the route x86 has.I'm not saying it has to be done via a CONFIG option, all I'm saying
Quoted 8 lines
is
Quoted 2 lines
if I want to explicitly use GCC then I would hope we could somehow disable it being override.
If you're not doing it via CONFIG, that leaves manual (which is always
an option) or seeing if passing CFLAGS on the cmdline overrides
things,
or adds to them.
Thats all I really want. Just for us to make sure if I want to do -mcpu=7455 -mtune=7455 I'm able to and it actually does what I told it to do. I'm not sure if GCC is consistent on how it handles args that are duplicated. For example what will happen with the following:
gcc -mcpu=750 -mtune=7450 -mcpu=603 -mtune=603
Is this -mcpu=750 -mtune=7450 or -mcpu=603 -mtune=603
- kumar
Quoted 80 lines · Kumar Gala
Quoted 68 lines · Tom Rini
Quoted 11 lines · Kumar Gala
Quoted 8 lines · Tom Rini
Quoted 7 lines · Kumar Gala
Quoted 4 lines · Dan Malek
Quoted 1 line · Paul Mackerras
If you think we should have -mcpu=xxx on the command line
for
Quoted 2 lines
Quoted 2 lines
4xx,
Quoted 1 line
Quoted 1 line
Quoted 1 line
44x, 8xx, etc., then that's fine, but that is a separate
problem
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
from
Quoted 1 line
what my patch was addressing (one which my patch might make
it
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
easier
Quoted 1 line
to fix, though).
I think that is exactly what we want, although I don't know how
that is
Quoted 1 line
Quoted 1 line
separate from the patch you sent.? My original comment was the
patch
Quoted 1 line
Quoted 1 line
fixes the problem for only one of the cpu cores, not all of
them.?
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Which
then led into the subsequent suggestion of making the biarchwork
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
like the past compilers, and we must specific the flags for
POWER4
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
instead of the other way around.? Without explicit -mcpu
flags,
Quoted 2 lines
Quoted 2 lines
the
Quoted 1 line
Quoted 1 line
existing compiler behavior is just fine .....? but, I guess
I'd be
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
standing
in the way of progress to want this :-)I agree with Dan here.? I think we should go ahead and extend the
patch
Quoted 1 line
to set -mcpu and -mtune flags for the list of processors we have
in
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Processor Type".? If I'm building a kernel for e500 or 4xx I
might
Quoted 6 lines
Quoted 6 lines
as
Quoted 1 line
well get a kernel that is tuned a bit more for the subarch.?
This is fine.
Quoted 1 line
Additionally, there should be some expert override ability, so
if I
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
really want to do -mcpu=7455 -mtune=7455 I can.
Gack, no!? It's quite a pain to go from
CONFIG_FOO="string" into useableMakefilebits that the one we did have back in 2.4 is gone.? Thatalso
Quoted 1 line
Quoted 1 line
implies gcc finally knows something about these cores that might
be
Quoted 1 line
Quoted 1 line
useful, which I don't think is the case, nor is it likely to be.?
But
Quoted 4 lines
Quoted 2 lines
if
we did want it, we'd probably go the route x86 has.I'm not saying it has to be done via a CONFIG option, all I'm saying
Quoted 8 lines
is
Quoted 2 lines
if I want to explicitly use GCC then I would hope we could somehow disable it being override.
If you're not doing it via CONFIG, that leaves manual (which is always an option) or seeing if passing CFLAGS on the cmdline overrides things,
or adds to them.
Quoted 8 lines
Thats all I really want. Just for us to make sure if I want to do -mcpu=7455 -mtune=7455 I'm able to and it actually does what I told it to do. I'm not sure if GCC is consistent on how it handles args that are duplicated. For example what will happen with the following:
gcc -mcpu=750 -mtune=7450 -mcpu=603 -mtune=603
Is this -mcpu=750 -mtune=7450 or -mcpu=603 -mtune=603
Last one wins, modulo gcc bugs, is the rule I believe.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 6 lines
Well, say you are compiling for 405. You either need to have a gcc that was configured with --with-cpu=405, or you need to have hacked
arch/ppc/Makefileto add -mcpu=405. In both cases the problem doesn't arise. It only arises if you have a biarch gcc4 that was configured without any --with-cpu=xxx option and is run without any -mcpu=xxx option.
It happens for any installation where the default chosen by the GCC used is not the -mcpu=XXX flag you need used for your kernel. Which is a much more general statement than the biarch one. Most people just get lucky, because they compile code with a compiler that is defaulted for their target, and userland and kernel use (about) the same options on most targets. Not so in biarch land (bleeech).
Quoted 4 lines
If you think we should have -mcpu=xxx on the command line for 4xx, 44x, 8xx, etc., then that's fine, but that is a separate problem from what my patch was addressing (one which my patch might make it easier to fix, though).
Please always use -mcpu=XXX (and perhaps -mtune=XXX), that's the only "correct" way to fix this. Or _never_ do any -mcpu=, and let users override it in the CC setting in the Makefile. But I like the first option better.
Segher
Quoted 7 lines · Segher Boessenkool
Quoted 6 lines
Well, say you are compiling for 405. You either need to have a gcc that was configured with --with-cpu=405, or you need to have hacked
arch/ppc/Makefileto add -mcpu=405. In both cases the problem doesn't arise. It only arises if you have a biarch gcc4 that was configured without any --with-cpu=xxx option and is run without any -mcpu=xxx option.
Quoted 6 lines
It happens for any installation where the default chosen by the GCC used is not the -mcpu=XXX flag you need used for your kernel. Which is a much more general statement than the biarch one. Most people just get lucky, because they compile code with a compiler that is defaulted for their target, and userland and kernel use (about) the same options on most targets. Not so in biarch land (bleeech).
Note that up until very recently (and just a bit before conflicting opcodes were added), no -mcpu=XXX was required. For example, I compiled a 44x kernel with a -mcpu=750 toolchain no problems shortly after Paul posted this. The only exception to this rule I can possibly think of is 85xx. But even that would be the "very recently" thing I mentioned as I know you can use an 82xx-set toolchain to build for 85xx.
Having said that..
Quoted 9 lines
Quoted 4 lines
If you think we should have -mcpu=xxx on the command line for 4xx, 44x, 8xx, etc., then that's fine, but that is a separate problem from what my patch was addressing (one which my patch might make it easier to fix, though).
Please always use -mcpu=XXX (and perhaps -mtune=XXX), that's the only "correct" way to fix this. Or _never_ do any -mcpu=, and let users override it in the CC setting in the
Makefile. But I like the first option better.
We should setup cpu-opt-$(CONFIG_every choice) to fix new gcc breakage (and I guess we shouldn't have removed the do-nothing ones we had a few years ago).
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 2 lines
Note that up until very recently (and just a bit before conflicting opcodes were added), no -mcpu=XXX was required.
True, but it's just lucky that it worked...
Segher
Quoted 4 lines · Segher Boessenkool
Quoted 2 lines
Note that up until very recently (and just a bit before conflicting opcodes were added), no -mcpu=XXX was required.
True, but it's just lucky that it worked...
It used to be design that it worked. But now I'm sounding like Dan, which I find only slightly disconcerting :)
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 2 lines · Tom Rini
Quoted 1 line · Segher Boessenkool
Quoted 1 line
Well, say you are compiling for 405.=A0 You either need to have a =
gcc
Quoted 1 line
Quoted 1 line
Quoted 1 line
that was configured with --with-cpu=3D405, or you need to have =
hacked
Quoted 6 lines
Quoted 1 line
Quoted 1 line
arch/ppc/Makefileto add -mcpu=3D405.=A0 In both cases the problem=20=doesn't
Quoted 1 line
Quoted 1 line
arise.=A0 It only arises if you have a biarch gcc4 that was=20
configured
Quoted 1 line
Quoted 1 line
without any --with-cpu=3Dxxx option and is run without any =
-mcpu=3Dxxx
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
option.
It happens for any installation where the default chosen by the GCC used is not the -mcpu=3DXXX flag you need used for your kernel.=A0 =
Which
Quoted 1 line
Quoted 1 line
is a much more general statement than the biarch one.=A0 Most =
people=20
Quoted 4 lines
just
Quoted 1 line
get lucky, because they compile code with a compiler that is=20
defaulted
Quoted 1 line
for their target, and userland and kernel use (about) the same=20
Quoted 8 lines
options
Quoted 1 line
on most targets.=A0 Not so in biarch land (bleeech).
Note that up until very recently (and just a bit before conflicting
opcodes were added), no -mcpu=3DXXX was required.=A0 For example, I=20=compiled
a 44x kernel with a -mcpu=3D750 toolchain no problems shortly after =
Paul
Quoted 1 line
posted this.=A0 The only exception to this rule I can possibly think =
of=20
Quoted 2 lines
is
85xx.=A0 But even that would be the "very recently" thing I mentioned =
as
Quoted 3 lines
I know you can use an 82xx-set toolchain to build for 85xx.
Having said that..
I do the same thing as well and the only issue I have is that 85xx=20 doesn't support strings thus the conditional we currently have for=20 -mstring.
- kumar=
Quoted 2 lines · Paul Mackerras
The problem only comes up if you configure gcc4 as biarch. I can't imagine anyone building a biarch compiler for 4xx or 8xx. :)
Why not? I've never built a "special" compiler for any development work, and am very likely to use the default compiler installed on my YDL system (which could likely be a G5) for building any embedded PowerPC software.
Quoted 4 lines
So yes, only
CONFIG_6xxis affected by biarch gcc4 assuming POWER4. Other families would only be affected if you were using a generic gcc4, which won't work at present anyway, since we don't add -mcpu=xxx.
What do you mean by "won't work"? The compiler simply refuses or builds for a POWER4 because we don't have the proper -mcpu flags?
Thanks.
-- Dan
Quoted 9 lines · Paul Mackerras
What do people think of this patch?=A0 The motivation for it is that a
biarch gcc-4.0 will by default tune for POWER4, even for a 32-bit compile, meaning that we end up with a lot of nops we don't need. This also takes out -mstring.With this, the text size reduces by about 120k for my normal config
when compiling with a biarch gcc-4.0.=A0 The text size also reduces slightly when compiling with the Debian gcc-3.3.5 (32-bit only, not biarch).
What is attributed to this large of a text size change. I've always=20 assumed the -mcpu and -mtune options really only effected code=20 scheduling. This seems really odd since there arent really that many=20 different instructions between the various PPC variants.
- kumar=
Quoted 8 lines · Kumar Gala
Quoted 5 lines · Paul Mackerras
What do people think of this patch?? The motivation for it is that a biarch gcc-4.0 will by default tune for POWER4, even for a 32-bit compile, meaning that we end up with a lot of nops we don't need. This also takes out -mstring.
Quoted 6 lines
Quoted 4 lines
With this, the text size reduces by about 120k for my normal config when compiling with a biarch gcc-4.0.? The text size also reduces slightly when compiling with the Debian gcc-3.3.5 (32-bit only, not biarch).
What is attributed to this large of a text size change. I've always
My guess is taking out the nops that we don't need on !POWER4.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 11 lines · Paul Mackeras
What do people think of this patch? The motivation for it is that a biarch gcc-4.0 will by default tune for POWER4, even for a 32-bit compile, meaning that we end up with a lot of nops we don't need. This also takes out -mstring.
With this, the text size reduces by about 120k for my normal config when compiling with a biarch gcc-4.0. The text size also reduces slightly when compiling with the Debian gcc-3.3.5 (32-bit only, not biarch).
If there are no objections I'll send this to Andrew and Linus.
What will be done about this patch? -mcpu=750 reduces .text by 70k.
text data bss dec hex filename
3397801 579544 519704 4497049 449e99 ../O-ppc-cpu601/vmlinux 3397502 579544 519704 4496750 449d6e ../O-ppc-cpu604/vmlinux 3397953 579544 519704 4497201 449f31 ../O-ppc-cpu750/vmlinux 3469857 579544 519704 4569105 45b811 ../O-ppc-default/vmlinux
Quoted 7 lines · Olaf Hering
Quoted 5 lines · Paul Mackeras
What do people think of this patch? The motivation for it is that a biarch gcc-4.0 will by default tune for POWER4, even for a 32-bit compile, meaning that we end up with a lot of nops we don't need. This also takes out -mstring.
Quoted 8 lines
Quoted 6 lines
With this, the text size reduces by about 120k for my normal config when compiling with a biarch gcc-4.0. The text size also reduces slightly when compiling with the Debian gcc-3.3.5 (32-bit only, not biarch).
If there are no objections I'll send this to Andrew and Linus.
What will be done about this patch? -mcpu=750 reduces .text by 70k.
The fix for the real problem is now in. Perhaps, based off gcc's info page, we should update (from what 2.6.12 looks like) to do:
cpu-as-y = -Wa,-mcpu=powerpc # Pure ppc32
cpu-as-$(CONFIG_6xx) += -Wa,-maltivec cpu-as-$(CONFIG_PPC_601) := -Wa,-mcpu=601 # Or whatever the 601 option is cpu-as-$(CONFIG_PPC64BRIDGE) := -Wa,mcpu=powerpc64
< add 4xx/BookE here >
And see what we get. I really don't think we should fall into the i386 ugly trap of i386/i486/i586/i586tsc/... 20 other options ..., esp since it looks like the main win is switching from 100% generic powerpc to something more specific. And going with the generic name means if gcc starts doing something different on 750 vs 7400 vs 604, we win.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 1 line · Tom Rini
cpu-as-y = -Wa,-mcpu=powerpc # Pure ppc32
That alone should fix it, adding -mcpu=$somecpu may generate bad code for other cpu types, according to alanm.
Quoted 2 lines
cpu-as-$(CONFIG_6xx) += -Wa,-maltivec cpu-as-$(CONFIG_PPC_601) := -Wa,-mcpu=601 # Or whatever the 601 option is
601 doesnt need special cflags handling.
cpu-as-$(CONFIG_6xx) += -Wa,-mcpu=powerpc
may be enough, no idea if -Wa is required.
Quoted 6 lines · Olaf Hering
Quoted 1 line · Tom Rini
cpu-as-y = -Wa,-mcpu=powerpc # Pure ppc32
That alone should fix it, adding -mcpu=$somecpu may generate bad code for other cpu types, according to alanm.
Exactly.
Quoted 4 lines
Quoted 2 lines
cpu-as-$(CONFIG_6xx) += -Wa,-maltivec cpu-as-$(CONFIG_PPC_601) := -Wa,-mcpu=601 # Or whatever the 601 option is
601 doesnt need special cflags handling.
gcc info page says that -mcpu=powerpc won't work for 601.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 1 line · Tom Rini
gcc info page says that -mcpu=powerpc won't work for 601.
-mcpu=common may work for everyone, after a quick grep in gcc/config/rs6000
Quoted 6 lines · Olaf Hering
Quoted 1 line · Tom Rini
gcc info page says that -mcpu=powerpc won't work for 601.
-mcpu=common may work for everyone, after a quick grep in gcc/config/rs6000
It does, and that's the code bloat you're trying to get rid of :)
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 9 lines · Tom Rini
Quoted 6 lines · Olaf Hering
Quoted 1 line · Tom Rini
gcc info page says that -mcpu=powerpc won't work for 601.
-mcpu=common may work for everyone, after a quick grep in gcc/config/rs6000
It does, and that's the code bloat you're trying to get rid of :)
Yeah, leads to fun like that:
init/built-in.o: In function `calibrate_delay':
: undefined reference to `__quous'
need to grep harder.
Quoted 9 lines · Tom Rini
Quoted 6 lines · Olaf Hering
Quoted 1 line · Tom Rini
gcc info page says that -mcpu=powerpc won't work for 601.
-mcpu=common may work for everyone, after a quick grep in gcc/config/rs6000
It does, and that's the code bloat you're trying to get rid of :)
3397494 579544 519704 4496742 449d66 ../O-ppc-cpucommon/vmlinux 3469857 579544 519704 4569105 45b811 ../O-ppc-default/vmlinux
-mcpu=powerpc reduces text size still more than -mcpu=750
Quoted 7 lines · Olaf Hering
Quoted 5 lines · Tom Rini
Quoted 4 lines · Olaf Hering
Quoted 1 line · Tom Rini
gcc info page says that -mcpu=powerpc won't work for 601.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
-mcpu=common may work for everyone, after a quick grep in gcc/config/rs6000
It does, and that's the code bloat you're trying to get rid of :)
3397494 579544 519704 4496742 449d66 ../O-ppc-cpucommon/vmlinux 3469857 579544 519704 4569105 45b811 ../O-ppc-default/vmlinux
That's very wierd. What is the default then? Thinking back to May, I thought it was 'common', and that was why Paul wanted to change things.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 2 lines · Tom Rini
That's very wierd. What is the default then? Thinking back to May, I thought it was 'common', and that was why Paul wanted to change things.
This is an odd biarch compiler, the one that Paul talked about:
Target: powerpc64-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,objc,f95,java,ada --enable-checking --with-gxx-include-dir=/usr/include/c++/4.0.1 --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --without-system-libunwind --with-cpu=default32 --host=powerpc64-suse-linux
Thread model: posix
gcc version 4.0.1 20050701 (prerelease) (SUSE Linux)
PATCH 1/1 Set cpu explicitly in kernel compiles
In reply to Paul MackerrasQuoted 9 lines · Paul Mackeras
What do people think of this patch? The motivation for it is that a biarch gcc-4.0 will by default tune for POWER4, even for a 32-bit compile, meaning that we end up with a lot of nops we don't need. This also takes out -mstring.
With this, the text size reduces by about 120k for my normal config when compiling with a biarch gcc-4.0. The text size also reduces slightly when compiling with the Debian gcc-3.3.5 (32-bit only, not biarch).
Compile the 32bit kernel with -mcpu=powerpc. This reduces the imagesize when a compiler is used that defaults to -mtune=power4. It inserts lots of nops to please the 64bit cpu instruction scheduling. But all these nops are not needed for 32bit kernels.
Example with SLES10 gcc 4.1.0 and arch/powerpc/configs/pmac32_defconfig:
vmlinux vmlinux.strip vmlinux.gz
-O2 4980515 4187528 1846829 -Os 4618801 3827084 1673333 -O2 -mcpu=powerpc 4738851 3945868 1816253 -Os -mcpu=powerpc 4532785 3741068 1664688
--- arch/powerpc/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/Makefile +1 -0
@@ -107,6 +107,7 @@ endif cpu-as-$(CONFIG_PPC64BRIDGE) += -Wa,-mppc64bridge cpu-as-$(CONFIG_4xx) += -Wa,-m405 cpu-as-$(CONFIG_6xx) += -Wa,-maltivec +cpu-as-$(CONFIG_6xx) += -mcpu=powerpc cpu-as-$(CONFIG_POWER4) += -Wa,-maltivec cpu-as-$(CONFIG_E500) += -Wa,-me500 cpu-as-$(CONFIG_E200) += -Wa,-me200
arch/powerpc/Makefile endif · line 110
Quoted 7 lines · Olaf Hering
arch/powerpc/Makefile +1
-0@@ -107,6 +107,7 @@ endif cpu-as-$(CONFIG_PPC64BRIDGE) += -Wa,-mppc64bridge cpu-as-$(CONFIG_4xx) += -Wa,-m405 cpu-as-$(CONFIG_6xx) += -Wa,-maltivec +cpu-as-$(CONFIG_6xx) += -mcpu=powerpc
Is this really the right place for this? The cpu-as- thing is really for assembler options.
Paul.
Quoted 12 lines · Paul Mackeras
arch/powerpc/Makefile endif · line 110
Quoted 7 lines · Olaf Hering
arch/powerpc/Makefile +1
-0@@ -107,6 +107,7 @@ endif cpu-as-$(CONFIG_PPC64BRIDGE) += -Wa,-mppc64bridge cpu-as-$(CONFIG_4xx) += -Wa,-m405 cpu-as-$(CONFIG_6xx) += -Wa,-maltivec +cpu-as-$(CONFIG_6xx) += -mcpu=powerpcIs this really the right place for this? The cpu-as- thing is really for assembler options.
Compile the 32bit kernel with -mcpu=powerpc. This reduces the imagesize when a compiler is used that defaults to -mtune=power4. It inserts lots of nops to please the 64bit cpu instruction scheduling. But all these nops are not needed for 32bit kernels.
Example with SLES10 gcc 4.1.0 and arch/powerpc/configs/pmac32_defconfig:
vmlinux vmlinux.strip vmlinux.gz
-O2 4980515 4187528 1846829 -Os 4618801 3827084 1673333 -O2 -mcpu=powerpc 4738851 3945868 1816253 -Os -mcpu=powerpc 4532785 3741068 1664688
--- arch/powerpc/Makefile | 4 ++++ 1 file changed, 4 insertions(+)
arch/powerpc/Makefile +4 -0
@@ -104,6 +104,10 @@ ifndef CONFIG_FSL_BOOKE CFLAGS += -mstring endif +ifeq ($(CONFIG_6xx),y) +CFLAGS += -mcpu=powerpc +endif + cpu-as-$(CONFIG_PPC64BRIDGE) += -Wa,-mppc64bridge cpu-as-$(CONFIG_4xx) += -Wa,-m405 cpu-as-$(CONFIG_6xx) += -Wa,-maltivec