PowerPC64 Port

From Free Pascal wiki
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 is cycling fine.

Building

Since it's beta, with some slight bugs, only the knowledgeable and interested people should try it. As usual, if you do not have a G5, you need crossbinutils for linux-ppc64.

The target name is "powerpc64", so a "make PPC_TARGET=powerpc64-linux" (or "make PPC_TARGET=powerpc64" if you are already on Linux) should do the trick.

Issues

  • -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
  • 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)
  • in general, the compiler needs more testing.

Of course, 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.

Contacts

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