BeBits Information Developer Central Submit Application Your Account Web Links Contact Us
BeBits
TipsOnPortingIntelAppsToPPC
This is a tricky subject. Below is a list of all the pitfalls I've encountered:

PPC has no assembler and no port of GCC. We rely entirely on the magic and mystery of the Metrowerks compiler (here after mwcc), linker (mwld) and assorted support tools.

Q: Why should this matter?
A: The simple answer is that it shouldn't. However it does bigtime. The mwcc generates a custom object format (fully documented, but still a bit of a mystery) and this is the *only* format that the R5.0 PPC mwld will accept. (A port of GCC would need to generate this format to be compatible, sigh!) Without an assembler and with only a single object file format available to us, we have fairly narrow choices to be made with regards to our alternatives.


(As a sidebar : XCOFF was initially supported too by mwld, but when Be took over the development of the compiler suite, this support seems to have been lost some how.)

Q: How about replacing mwld?
This too is troublesome. The PPC platform uses the PEF executable format, which is patented by Apple. The replacement linker would need to produce executables in this format. This is not an easy thing to do; it would certainly be easier to develop an assembler that could sit between an alternative compiler and output object files that mwld could use.

The next big issue to be dealt with is that mwcc is not a complete drop in clone/replacement for GCC. In fact, it is a very capable compiler, with features over GCC, but also lacks some features that GCC has and people often use. Some would argue that some of these faetures are actually an abuse... this is down to personal taste. Compiling good C and C++ written to be targeted by GCC often just involves a bit of fiddling on the part of the PPC user. Endianness is our only large problem, bar the indepth issues we will discuss below with some of the GCC syntax and mwcc's lack of support/differing interpretation of for it.

The most common issues:

  • Default parameters - mwcc does not allow function bodies in C++ classes to contain default params. You can have default params in the class declaration, just not in the method implementation/body
     
    e.g.
    

    class X { ... void doSomething(int a, bool b = false); //this is fine ... };

    void doSomething(int a, bool b = false) { //this is illegal, you must just declare '(int a, bool b)' ... }

  • signed and unsigned conversions - gcc cheats. It silently typecasts unsigned and signed values to the correct signing. Mwcc does not do this by default (if at all.) You will often need to add a "(xxxx*)" or "(unsigned xxxx*)" typecast (where 'xxxx' is the type in question) to get by this error.
    e.g.
    

    void f(unsigned int* a) { int* b;

    b = a; //error!!! b = (int*)a; //this is okay }


PAGE VISITS
1,750

LINKS HERE
BeOSplatformsPPC

NEW PAGES
CrosscompilingFirefox
BuildingCairo
StoringDataInBetweenOSes
ScriptingBeosRuby
ScriptingBeosPython
HaikuOS
QemUwinbe
MinimalBeos
XpMBRoverwrite
SteveSakoman

RECENT CHANGES
BeUserProfiles
PhilipDybowski
CorumIII
BuildingFirebird
FrontPage
BeAcademic
CrosscompilingFirefox
HowTo
BuildingCairo
BeCommunity
Edit Page | Front Page | BeBits
Site content is in the public domain. Unless otherwise noted, everything else is copyright © 1999-2010 Haikuware. All Rights Reserved.
For more legal trivia, take a gander at our
Legal Stuff page and our Privacy Statement.