[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pilot-Unix] gcc patches patched for egcs-1.0.3 (long)
Hello all.
I've updated gcc-2.7.2.2.palmos.diff so that it can be applied cleanly
to egcs-2.90.29 980515 (egcs-1.0.3 release). I am now running something
I've called egcs-2.90.29-kgpd-980515 and so far it seems to be working.
(I've seen a little bit of discussion here about doing this, but not found
anything conclusive. I hope I haven't duplicated someone else's effort,
but I've had fun doing it anyway.)
I'm using bintools-2.9.1.0.6 which patched happily out of the box with
binutils-2.7.palmos.diff, and my patchfile for the gcc-2.7.2.2.palmos.diff
patchfile is about 500 lines, if you see what I mean. Here's the major
changes from gcc-2.7.2.2.palmos.diff:
* config/m68k/m68k.c & config/m68k/m68k.md: Some patches have
moved from .md to .c with the creation of output_move_simode().
* config/m68k/m68k.md (beq0_di, bne0_di, bge0_di, blt0_di): These
patches have been removed since egcs has what appears to be a better
version of the same modification. (See +/m68k.md..beq ChangeLog.11)
* config/m68k/m68kpalmos.h (CC1_SPEC): Added -mpcrel. It seems
that the winner of a battle between TARGET_DEFAULT and CC1_SPEC
has changed.
(CC1PLUS_SPEC): Added -fno-exceptions and -fno-rtti. (Note that
C++ gets -mpcrel etc from CC1_SPEC too.)
Hmmmm... it doesn't look like much now, but each of those involved some
pretty major detective work.
(1) TESTING
I haven't done an awful lot of testing yet, and maybe I am missing
something major. (Any suggestions?) Here's what testing I have done:
1. Compiled and run some small programs (Andrew Howlett's table howto,
Laurence Bang's cities distance, a couple of my own works-in-progress).
All compile cleanly and work on xcopilot just fine.
2. Compiled the v3 Address Book. This required the v3 system headers,
which worked as downloaded from devsupp after four changes:
mv UI/Event.H UI/Event.h
ln System/ImcUtils.h System/IMCUtils.h
vi +188 Hardware/Hardware.h, s/UChar data[];/UChar data[0];/
change CRLF to LF everywhere (grrrrr)
This compiled without errors (modulo zillions of "passing arg from
incompatible pointer type" warnings) but failed to link ("region
coderes is full"). I'm not too concerned because I suspect that
Address really is > 64K. (Am I right not to be concerned?)
3. Tried out Ian Goldberg's clobbering bug from this mailing list
last December ("BUG in gcc for Pilot (detailed, long)", heaps of
scary DES #define code). It looks to me that it's been fixed:
move.l %d4,-8(%a6)
move.l %d3,-4(%a6)
move.l 28(%a6),-(%sp)
move.l 24(%a6),-(%sp)
move.l 20(%a6),-(%sp)
pea -8(%a6)
move.l %a0,-12(%a6)
move.l %a1,-16(%a6)
bsr.w des_decrypt3
move.l -8(%a6),%d1
eor.l %d6,%d1
move.l -4(%a6),%d2
eor.l %d5,%d2
Note that %d1 is now properly dead over the bsr, and it appears to be
using %d6 where it was using %d1 incorrectly before. In fact, I think
maybe I noticed where in m68k.md this got fixed: there used to be this
insn with very complicated if/then/else^4 stuff in the output template,
and on one of the paths through it it forgot to emit anything. So I
suspect it knew it had to save %d1, but Ian managed to trigger that path.
(2) CALLBACK WORKAROUNDS
We're all pretty used to Ian's %a4 callback workaround by now. Does it
really need to be fixed? I for one think so. Here's my voluminous
example. (Yes, there are workarounds, but it's getting pretty ugly.)
int global;
int example() {
int local = global;
CALLBACK_PROLOGUE /* can't put this first in C */
if (local == 37) {
CALLBACK_EPILOGUE
return 3;
}
CALLBACK_EPILOGUE
return global;
}
example:
link.w %a6,#-8
lea global(%a4),%a1 /* crash: %a4 not set up yet */
move.l %a1,%d0
move.l %d0,%a0
move.w (%a0),-2(%a6)
move.l %a4,-6(%a6)
move.l %a5,%a4; sub.l #edata,%a4
cmp.w #37,-2(%a6)
jbne .L2
move.l -6(%a6),%a4 /* duplicated even though there's
moveq.l #3,%d0 only one rts */
bra .L1
.even
.L2:
move.l -6(%a6),%a4
lea global(%a4),%a1 /* crash: %a4 no longer correct */
move.l %a1,%d0
move.l %d0,%a0
move.w (%a0),%d1
move.w %d1,%d0
bra .L1
.even
.L1:
unlk %a6
rts
.comm global,2
We could just build the exact same workaround into the compiler. I can
see what a function attribute "callback" would need to do, and I think I
can see where it would need to do it. On the other hand:
Why actually does gcc use %a4? (I suspect this is a dumb question, and
I've got a lot of reading of very old pilot-unix to do.) It appears
to be at a constant difference from %a5, so why do we need %a4 instead
of using %a5 with a pre-offsetted offset? (Ah.. edata may be constant,
but it's not known early enough, maybe that's it? Not until after link
time, maybe, that sounds promising. What is edata anyway?)
(3) WHAT'S NEXT
We need some more people to test it on more non-trivial programs! If
you want to download 10 megs of egcs source, compile it (configure & make
really do work!), and try some of your programs, I will be happy to send
you my 500 lines of patchfile.
I need to get in touch with the prc-tools maintainers and find out about
incorporating this into the current distributions. Heck, maybe a new
distribution to fix those naysayers who say PalmOS gcc is getting too
long in the tooth!
I also have some other ideas of things that could be updated, but this
message is quite long enough, and I'm going to go get some sleep now.
John
--
John Marshall <jmarshall@acm.org>
Edinburgh, Scotland.