PowerPC64 Port

From Free Pascal wiki
Revision as of 17:53, 12 October 2005 by Tom at work (talk | contribs) (Fixed Building section, minor changes)
Jump to navigationJump to search

The PowerPC64 port is in some sort of early beta-stage. It started as entry for the Linux On Power contest.

This page contains only a rough outline of what is working and especially what not, some notes about the port and several other related information. More, detailed information (about calling conventions and so on) later.


Status

  • 2.1.x compiler support
  • Supports POWER4 and derivative (G5) for Linux at the moment.
  • Base RTL units and compiler cycle.

Building

Since it's beta, with some small bugs, only the knowledgeable and interested people should try it. As usual, if you do not have a G5, and attempt to crosscompile, you need crossbinutils for linux-powerpc64. The target name is powerpc64.

For G5-owners the process is easier: enter

  make cycle PPC_TARGET=powerpc64 PP=ppcppc

(if you already have the 32 bit PowerPC compiler installed) in the compiler directory of the sources should do the trick. After a while this leaves a ppcppc64 executable in your compiler directory, and the compiled RTL in ../rtl/units/powerpc64-linux.

Issues

This is some sort of work diary, showing the current problems under investigation (and the problems already solved) with the PowerPC64 compiler.

  • Stabs debug information is generated wrongly. Maybe related to stabs not working at all in 2.1.x at the moment.
  • OO Exceptions do not work, SIGSEGV'ing after several Push/PopExceptAddr invocations
  • object messages do not work. This is an alignment problem of generated internal structures.
  • there are some problems with packages/FCL due to missing workaround for non-aligned accesses in some records. A workaround for this (instruction) limitation is being worked on.
  • performance is really bad. Programs compiled with the ppc32 compiler are much faster, and the same program on a slower clocked x86_32 dances circles around both.
  • conditional jump offsets must by < 32k (same issue that has been fixed in rev. 1161 for PowerPC32)
  • -Or is currently broken
  • Exception handling does not seem to work, there is an issue with the sigaction() call (signal handlers fail to register).
  • Exception handler crashes at invoking HandleErrorAddrFrame(), possibly incorrect internal structures

Of course, in general, the compiler needs more testing. All of this (except maybe the performance part :-) will be fixed for an "official" release.

32 bit compatibility

During porting several compatibility problems of 32 bit PowerPC programs with the 32 bit emulation layer of Linux were found. They are:

  • the default cache line size is 128 byte instead of 32 byte. This affects some RTL routines which assume 32 byte cache line length, i.e. the assembly fillchar() and move() methods. For this reason, most (except very trivial) FPC compiled programs immediately segfault on PowerPC64. Fixing this involves selecting cache line aware fillchar() and move() methods at program startup.
  • Signal handlers for exceptions are not registered properly by the RTL at program startup. This is due to Linux/32 on powerpc64 using different syscall numbers than Linux/32 on PowerPC32. In particular it uses the rt_sig* constants, not the old ones. This also affects OO-exception handling, which does not work at all. (Note from oliebol: "Either ppc64 improving or fpc linux/x86 switching to rt_sig*").

There may (and I think there are) more issues. These are only those which I could reproducably pinpoint at this time.

More information

This section contains links and notes to further information about the PowerPC64 architecture. This includes links to the ABI specification, general processor descriptions, instruction set documentation and general compiler notes.

  • Ian Lance Taylor, 64-bit PowerPC ELF Application Binary Interface Supplement 1.7, Zenbu Labs IBM, 2004 (HTML) (PDF) - This was the original ABI specification the PowerPC64 compiler was developed with.
  • Ian Lance Taylor, 64-bit PowerPC ELF Application Binary Interface Supplement 1.9, Zenbu Labs IBM, 2004 (HTML) (No PDF) - An update to the previous ABI specification. However, it only seems to add some clarifications compared to 1.7.
  • PowerPC Architecture Book - This website contains links to the PowerPC architecture manuals, i.e. a complete description of the instruction sets, containing both privileged and unprivileged instructions. The next links are direct references to the three books: Book I (PDF), Book I I (PDF), Book III (PDF)
  • PowerPC Compiler Writer's Guide - This website contains useful information for writing compilers for the PowerPC architecture, i.e. optimized code examples for common patterns. This manual has been written for the PowerPC32 architecture, but the techniques presented there can be easily ported over to the PowerPC64 platform.

Contact

Message to the fpc-devel mailing list, or look for "tom_at_work" in the IRC channel (or of course discuss it here).