Best compiler/flags combination

4 messages, 3 authors, 2000-01-31 · open the first message on its own page

Best compiler/flags combination

From: Pavel Roskin <hidden>
Date: 2000-01-28 20:06:45

Hello!

I'm compiling stuff for RPX/Lite on a PowerMac running LinuxPPC. It turns
out that programs compiled with -O2 work correctly on PowerMac but not on
RPX. For example, libcrypt.a compiled with -O2 and linked with tinylogin
crashes when it's run on RPX.

However, if I use -Os, all programs work correctly. The only exception was
ld.so that I had to recompile without optimization.

I'm using egcs-1.1.2 and glibc-2.1.1 with patches from LinuxPPC (i.e. I
use their source RPM's).

The question is, what compiler is known to produce good code for embedded
PPC boards and what flags should be used? It is desireable that the
binaries still run on PowerPC.

Pavel Roskin


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

Re: Best compiler/flags combination

From: Graham Stoney <hidden>
Date: 2000-01-30 23:21:30

Pavel Roskin writes:
I'm using egcs-1.1.2 and glibc-2.1.1 with patches from LinuxPPC (i.e. I
use their source RPM's).

The question is, what compiler is known to produce good code for embedded
PPC boards and what flags should be used? It is desireable that the
binaries still run on PowerPC.
My general approach when starting out is to always use the latest official
released versions, and move to a newer snapshot if you encounter problems.
In particular, the latest official gcc release (gcc-2.95.2) is a better
starting point than the old egcs releases.

Regards,
Graham

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

Re: Best compiler/flags combination

From: Pavel Roskin <hidden>
Date: 2000-01-31 04:55:50

Hello, Graham!
quoted
The question is, what compiler is known to produce good code for embedded
PPC boards and what flags should be used? It is desireable that the
binaries still run on PowerPC.
My general approach when starting out is to always use the latest official
released versions, and move to a newer snapshot if you encounter problems.
In particular, the latest official gcc release (gcc-2.95.2) is a better
starting point than the old egcs releases.
Thank you. I'll try it.

This approach works particularily well when you are using the same OS as
the developers (which is probably {i386,alpha}-linux) or when you (or
other people) have time to keep support for your configuration is a good
shape.

You did not mention flags. Maybe my results will be of some interest. I'm
using egcs-1.1.2 native for PowerMAC

-O2                bad code almost everywhere (libcrypt, depmod, bash)
-Os                bad code in tinylogin
-Os -fno-inline    good code (not extensively tested),
                   but it doesn't look like a clean solution
-O2 -mcpu=860 -mmultiple -mstrings -mhard-float
                   good code so far, but libm cannot be compiled
                   (internal error in the compiler)

Probably I'll still have to use
-O2 -mcpu=860 -mmultiple -mstrings -mhard-float

Or should I understand your recommendation so that you don't specify -mcpu
and gcc still produces code running on embedded systems?

Pavel Roskin


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

Re: Best compiler/flags combination

From: Peter Allworth <hidden>
Date: 2000-01-31 23:10:02

Pavel Roskin wrote:
<snip>
You did not mention flags. Maybe my results will be of some interest. I'm
using egcs-1.1.2 native for PowerMAC

-O2                bad code almost everywhere (libcrypt, depmod, bash)
-Os                bad code in tinylogin
-Os -fno-inline    good code (not extensively tested),
                   but it doesn't look like a clean solution
-O2 -mcpu=860 -mmultiple -mstrings -mhard-float
                   good code so far, but libm cannot be compiled
                   (internal error in the compiler)
Pavel,

I believe I have found the cause of the "internal error" in the compiler.
The source code of the compiler includes a file:

egcs-1.1.2/gcc/config/rs6000/rs6000.c

that defines a routine called "rs6000_override_options" which for -mcpu=860
will FORCE soft-float, irrespective of your command line flags.
(I think it's particularly thoughtful the way it doesn't tell you it's
doing this. ;)

By looking through the available list of cpu types, I've found an old
one that results in the compiler using the correct set of internal flags
to generate code for an MPC core with hardware (or emulated) floating point.

It's: -mcpu=505

With this flag I've been able to successfully compile and use glibc-2.1.1
on my Rev C iMac. I think the same code should run native on the iMac but
I haven't tried it.
Probably I'll still have to use
-O2 -mcpu=860 -mmultiple -mstrings -mhard-float

Or should I understand your recommendation so that you don't specify -mcpu
and gcc still produces code running on embedded systems?
As far as I can tell, the only problem with using the compiler "as-is"
would be that the compiler's idea of how long each instruction takes
would be wrong in some cases and so the resulting code would be suboptimal.

'Hope that all helps,

PeterA.

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help