PowerPC compilation flags

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

PowerPC compilation flags

Felipe GM
Hi there,

Currently I am developing for a MPC5777 board, with e200z7 cores. Most
of the things are going well, but I am stuck with a problem that is
really annoying me already. I am trying to use floating point operations
on portions of my code, using the embedded hardware support. My
toolchain is GCC 6.3 (powerpc-gcc, although I have tried with 7.3 and
8.2 too), for which I am using the following flags:

|ASFLAGS_BASE =-g -a32 -mbooke -me500 --fatal-warnings ARCH_FLAGS
=-mpowerpc-gpopt -mfprnd -misel -m32 -mhard-float-mabi=spe -mmfpgpr
-mfloat-gprs=single|

Please notice the|-mfloat-gprs=single|flag. That is the one that is
giving problems.

When I use|-mfloat-gprs=single|, I am not able to compile things
properly, as some functions are not implemented:

|undefined reference to `__extendsfdf2`,undefined reference to
`__adddf3`,undefined reference to `__divdf3`,|

- among others.

Now, if I compile using|-mfloat-gprs=double|, it goes till the end and
generate all my execution files. BUT, using this flag also generates
extra functions, not implemented by the e200z7. I can't tell for sure
all of them, as the code is getting bigger and it is mostly impossible
to track all generated assembly. For instance, at the moment my
execution gets stuck when it reaches the|efscfd|instruction, which is
implemented by the e500 core, that has double precision floating point
support, but not for the e200, that has single precision support only.

So, any piece of advice here would be amazingly welcome!

Thanks in advance,

PS: regarding the documentation saying the floag-gprs flag being valid
only for 8540, I have two "architectures": the board I am working on and
qemu. QeMU emulates an e500 core and the board has two e200z7 cores. I
have to set the flags individually for each one of them, and the
-mfloat-gprs affects directly the outcome for both. In my opinion, the
comments regarding this flag are legacy, and do not reflect newer GCC
versions.

--
Reply | Threaded
Open this post in threaded view
|

Re: PowerPC compilation flags

Segher Boessenkool
Hello Felipe,

On Sun, Nov 25, 2018 at 02:42:10PM -0500, Felipe GM wrote:
> Currently I am developing for a MPC5777 board, with e200z7 cores. Most
> of the things are going well, but I am stuck with a problem that is
> really annoying me already. I am trying to use floating point operations
> on portions of my code, using the embedded hardware support. My
> toolchain is GCC 6.3 (powerpc-gcc, although I have tried with 7.3 and
> 8.2 too), for which I am using the following flags:

GCC 6 is no longer maintained.  GCC 8 powerpc*-* does not support SPE
anymore (you need to configure for powerpc*-*spe* instead; you probably
want that for GCC 6 and GCC 7 as well).

> |ASFLAGS_BASE =-g -a32 -mbooke -me500 --fatal-warnings ARCH_FLAGS
> =-mpowerpc-gpopt -mfprnd -misel -m32 -mhard-float-mabi=spe -mmfpgpr
> -mfloat-gprs=single|

-mpowerpc-gpopt, -mfprnd, -mmfpgpr, and -mhard-float do not make sense
for your target.

> Please notice the|-mfloat-gprs=single|flag. That is the one that is
> giving problems.
>
> When I use|-mfloat-gprs=single|, I am not able to compile things
> properly, as some functions are not implemented:
>
> |undefined reference to `__extendsfdf2`,undefined reference to
> `__adddf3`,undefined reference to `__divdf3`,|
>
> - among others.

That works fine for me (those functions are in libgcc.a).

Please open a PR for GCC 7 (and GCC 8).


Segher
Reply | Threaded
Open this post in threaded view
|

Re: PowerPC compilation flags

Felipe GM
Hi Segher,

thank you very much for your reply.

> Hello Felipe,
>
> On Sun, Nov 25, 2018 at 02:42:10PM -0500, Felipe GM wrote:
>> Currently I am developing for a MPC5777 board, with e200z7 cores. Most
>> of the things are going well, but I am stuck with a problem that is
>> really annoying me already. I am trying to use floating point operations
>> on portions of my code, using the embedded hardware support. My
>> toolchain is GCC 6.3 (powerpc-gcc, although I have tried with 7.3 and
>> 8.2 too), for which I am using the following flags:
> *GCC 6 is no longer maintained. GCC 8 powerpc*-* does not support SPE
> anymore (you need to configure for powerpc*-*spe* instead; you
> probably want that for GCC 6 and GCC 7 as well).*
That is why I tried 7.3 and 8.2! Regarding powerpc-*-spe, do you mean to
use a different cross gcc? Or just different compilation flags?
>> |ASFLAGS_BASE =-g -a32 -mbooke -me500 --fatal-warnings ARCH_FLAGS
>> =-mpowerpc-gpopt -mfprnd -misel -m32 -mhard-float-mabi=spe -mmfpgpr
>> -mfloat-gprs=single|
> *-mpowerpc-gpopt, -mfprnd, -mmfpgpr, and -mhard-float do not make
> sense for your target.*
I have used most of them in order to try to solve the issue. One
question here though. When I use -mspe (or something similar, depending
on the gcc version) flag, not always the floating point support is
provided. More than once the linker asked for the unimplemented
functions, similar to what I said before (__divdf3, etc).

>
>> Please notice the|-mfloat-gprs=single|flag. That is the one that is
>> giving problems.
>>
>> When I use|-mfloat-gprs=single|, I am not able to compile things
>> properly, as some functions are not implemented:
>>
>> |undefined reference to `__extendsfdf2`,undefined reference to
>> `__adddf3`,undefined reference to `__divdf3`,|
>>
>> - among others.
> *That works fine for me (those functions are in libgcc.a). Please open
> a PR for GCC 7 (and GCC 8).*
>
> Segher
--
Ph.D. Felipe Gohring de Magalhães
Curriculum Lattes <http://lattes.cnpq.br/4701534141479314>
Reply | Threaded
Open this post in threaded view
|

Re: PowerPC compilation flags

Segher Boessenkool
Hi!

On Sun, Nov 25, 2018 at 05:36:38PM -0500, Felipe GM wrote:

> >On Sun, Nov 25, 2018 at 02:42:10PM -0500, Felipe GM wrote:
> >>Currently I am developing for a MPC5777 board, with e200z7 cores. Most
> >>of the things are going well, but I am stuck with a problem that is
> >>really annoying me already. I am trying to use floating point operations
> >>on portions of my code, using the embedded hardware support. My
> >>toolchain is GCC 6.3 (powerpc-gcc, although I have tried with 7.3 and
> >>8.2 too), for which I am using the following flags:
> >*GCC 6 is no longer maintained. GCC 8 powerpc*-* does not support SPE
> >anymore (you need to configure for powerpc*-*spe* instead; you
> >probably want that for GCC 6 and GCC 7 as well).*
> That is why I tried 7.3 and 8.2! Regarding powerpc-*-spe, do you mean to
> use a different cross gcc? Or just different compilation flags?

It's easiest if you build for target powerpc-eabispe or whatever you have.
That will default -mspe etc.; and you may not even be able to switch it
on other configurations, at all.

> >>|ASFLAGS_BASE =-g -a32 -mbooke -me500 --fatal-warnings ARCH_FLAGS
> >>=-mpowerpc-gpopt -mfprnd -misel -m32 -mhard-float-mabi=spe -mmfpgpr
> >>-mfloat-gprs=single|
> >*-mpowerpc-gpopt, -mfprnd, -mmfpgpr, and -mhard-float do not make
> >sense for your target.*
> I have used most of them in order to try to solve the issue. One
> question here though. When I use -mspe (or something similar, depending
> on the gcc version) flag, not always the floating point support is
> provided. More than once the linker asked for the unimplemented
> functions, similar to what I said before (__divdf3, etc).

Your CPU has hardware support for single precision only.  You get the
soft float support for double precision (like that __divdf3, yes --
anything "df").  This is what -mfloat-gprs=single does :-)

You always should link libgcc.  This is the default if you link using
gcc, but your custom linker scripts may have other plans ;-)


Segher
Reply | Threaded
Open this post in threaded view
|

Re: PowerPC compilation flags

Felipe GM

Em 2018-11-25 6:23 p.m., Segher Boessenkool escreveu:

> Hi!
>
> On Sun, Nov 25, 2018 at 05:36:38PM -0500, Felipe GM wrote:
>>> On Sun, Nov 25, 2018 at 02:42:10PM -0500, Felipe GM wrote:
>>>> Currently I am developing for a MPC5777 board, with e200z7 cores. Most
>>>> of the things are going well, but I am stuck with a problem that is
>>>> really annoying me already. I am trying to use floating point operations
>>>> on portions of my code, using the embedded hardware support. My
>>>> toolchain is GCC 6.3 (powerpc-gcc, although I have tried with 7.3 and
>>>> 8.2 too), for which I am using the following flags:
>>> *GCC 6 is no longer maintained. GCC 8 powerpc*-* does not support SPE
>>> anymore (you need to configure for powerpc*-*spe* instead; you
>>> probably want that for GCC 6 and GCC 7 as well).*
>> That is why I tried 7.3 and 8.2! Regarding powerpc-*-spe, do you mean to
>> use a different cross gcc? Or just different compilation flags?
> *It's easiest if you build for target powerpc-eabispe or whatever you
> have. That will default -mspe etc.; and you may not even be able to
> switch it on other configurations, at all.*
Ok, will do.

>
>>>> |ASFLAGS_BASE =-g -a32 -mbooke -me500 --fatal-warnings ARCH_FLAGS
>>>> =-mpowerpc-gpopt -mfprnd -misel -m32 -mhard-float-mabi=spe -mmfpgpr
>>>> -mfloat-gprs=single|
>>> *-mpowerpc-gpopt, -mfprnd, -mmfpgpr, and -mhard-float do not make
>>> sense for your target.*
>> I have used most of them in order to try to solve the issue. One
>> question here though. When I use -mspe (or something similar, depending
>> on the gcc version) flag, not always the floating point support is
>> provided. More than once the linker asked for the unimplemented
>> functions, similar to what I said before (__divdf3, etc).
> *Your CPU has hardware support for single precision only. You get the
> soft float support for double precision (like that __divdf3, yes --
> anything "df"). This is what -mfloat-gprs=single does :-)*
That is bugging me badly. I am not trying to use double float at any
point. Still, I am getting complaints about the linker trying to use
them. Any clue why? That is the reason I was (am) trying to use
-mfloat-gprs=double.
>
> *You always should link libgcc. This is the default if you link using
> gcc, but your custom linker scripts may have other plans ;-)*
libcc is not an option, sadly. I have a very restrict (and in need of
certification for compliance) application, so extra resources
(libraries) are not possible.
>
>
> Segher
--
Ph.D. Felipe Gohring de Magalhães
Curriculum Lattes <http://lattes.cnpq.br/4701534141479314>
Reply | Threaded
Open this post in threaded view
|

Re: PowerPC compilation flags

Segher Boessenkool
On Sun, Nov 25, 2018 at 06:41:23PM -0500, Felipe GM wrote:
> Em 2018-11-25 6:23 p.m., Segher Boessenkool escreveu:
> >*Your CPU has hardware support for single precision only. You get the
> >soft float support for double precision (like that __divdf3, yes --
> >anything "df"). This is what -mfloat-gprs=single does :-)*
> That is bugging me badly. I am not trying to use double float at any
> point. Still, I am getting complaints about the linker trying to use
> them. Any clue why? That is the reason I was (am) trying to use
> -mfloat-gprs=double.

You may have written something like

  float x = ...;
  x /= 10.0;

which does the calculation as *double*.  You need to write

  x /= 10.0f;

if you want a single-precision division.

Similar for the other unexpected functions.

There is a warning to help you find these: -Wdouble-promotion .

> >*You always should link libgcc. This is the default if you link using
> >gcc, but your custom linker scripts may have other plans ;-)*
> libcc is not an option, sadly. I have a very restrict (and in need of
> certification for compliance) application, so extra resources
> (libraries) are not possible.

All code compiled with GCC always has to be linked with libgcc.  This
library is required.  GCC can (and will, as you saw) generate calls to it
for various constructs that the target port did not implement directly, or
that are best implemented as a function (__divdf3 is more than 1800 bytes
for example, you do not want to inline that everywhere).


Segher
Reply | Threaded
Open this post in threaded view
|

Re: PowerPC compilation flags

Felipe GM
Hi Segher,
just to let you know that your help did the trick. Thank you very much. I
am using
*-mfloat-gprs=single -Wdouble-promotion -fsingle-precision-constant *in
order to prevent any double precision and so far it looks good!

On Sun, Nov 25, 2018 at 7:35 PM Segher Boessenkool <
[hidden email]> wrote:

> On Sun, Nov 25, 2018 at 06:41:23PM -0500, Felipe GM wrote:
> > Em 2018-11-25 6:23 p.m., Segher Boessenkool escreveu:
> > >*Your CPU has hardware support for single precision only. You get the
> > >soft float support for double precision (like that __divdf3, yes --
> > >anything "df"). This is what -mfloat-gprs=single does :-)*
> > That is bugging me badly. I am not trying to use double float at any
> > point. Still, I am getting complaints about the linker trying to use
> > them. Any clue why? That is the reason I was (am) trying to use
> > -mfloat-gprs=double.
>
> You may have written something like
>
>   float x = ...;
>   x /= 10.0;
>
> which does the calculation as *double*.  You need to write
>
>   x /= 10.0f;
>
> if you want a single-precision division.
>
> Similar for the other unexpected functions.
>
> There is a warning to help you find these: -Wdouble-promotion .
>
> > >*You always should link libgcc. This is the default if you link using
> > >gcc, but your custom linker scripts may have other plans ;-)*
> > libcc is not an option, sadly. I have a very restrict (and in need of
> > certification for compliance) application, so extra resources
> > (libraries) are not possible.
>
> All code compiled with GCC always has to be linked with libgcc.  This
> library is required.  GCC can (and will, as you saw) generate calls to it
> for various constructs that the target port did not implement directly, or
> that are best implemented as a function (__divdf3 is more than 1800 bytes
> for example, you do not want to inline that everywhere).
>
>
> Segher
>


--
Felipe GM