Skip to main content

Porting IA32 applications to Linux PowerPC

Matt Davis (matdavis@us.ibm.com ), Technical Consultant, IBM 
Matt Davis is a Linux technical consultant in the IBM eServer Solutions Enablement team. As a member of the pSeries Linux project since its inception, he explored and tested emerging technology for pSeries Linux and wrote several reports summarizing his findings. These include Journaling File Systems for Linux for POWER, Parallel Grid Computing with Linux for POWER, Open Source Alternatives to Commercial Software for Linux for POWER, and the Linux Solutions Catalog, to name a few. He came to IBM as an intern during his tenure as a student at the University of Texas at Austin, from which he earned two degrees with academic honors. You can reach him at matdavis@us.ibm.com.

Summary:  The path to enablement of IA32 code on Linux PPC travels through one of two compiler sets, the GNU Compiler Collection (GCC) and the Visual Age Compilers. This article reviews some tips for porting 32-bit software from Linux IA32 to Linux PowerPC with both of these compiler sets.

Date:  06 Jun 2003
Level:  Intermediate
Activity:  274 views

Introduction

The path to enablement of IA32 code on Linux PPC travels through one of two compiler sets. The GNU Compiler Collection (GCC) is the Free Software Foundation’s open source compiler set; this is the de facto standard for software compilation on Linux. GCC’s strength rests in its standardization across several types of hardware, and therefore the robust portability of code written to be compiled with GCC compilers. However, the nature of the GNU license and the standardization of GCC prohibit the GCC compilers from taking full advantage of specialized architectures, e.g. IBM eServers that feature PowerPC hardware. In order to provide a high performance compiler set for these servers, IBM has migrated the Visual Age Compilers used traditionally on AIX to develop and deploy applications for Linux PowerPC. This article reviews some tips for porting 32-bit software from Linux IA32 to Linux PowerPC with both of these compiler sets.


About PowerPC Architecture

Performance Optimized with Enhanced RISC (POWER) architecture is the result of more than a decade of hardware engineering dating to the POWER1 chips released in 1990. The POWER1 was IBM’s first commercial RISC processor and debuted at 25 Mhz clock speed. POWER4, the current IBM RISC processor offering operates at speeds between 1.1 and 1.45 Ghz. With the extensive parallelism and optimization in the hardware of the current implementations, PowerPC can deliver more computation per cycle than other chip architectures. Announced in 2001, POWER4 chips feature two 64 bit microprocessors per CPU board and support SMP configurations up to 32 way. In addition to the POWER4 hardware, Linux PowerPC also runs on IBM eServer hardware featuring POWER3 and RS64IV hardware. These architectures both feature 64 bit SMP capability and copper fabrication technology, but whereas the RS64IV processors are still actively developed, POWER3 is considered the legacy predecessor to POWER4. Each of the PowerPC derived chips offers industry leading performance and provides a world class hardware platform for the deployment of Linux PowerPC.


About SLES 8

SuSE Linux, available for more than 10 years, offers two levels of Linux distribution. SuSE Linux 8.0 is intended for workstation environments, and SuSE Linux Enterprise Server version 8 for enterprise systems. SLES 8 for PowerPC is the product of more than three years of collaboration between SuSE, IBM, and the open source community. Though SLES 8 boasts a number of accomplishments regarding 64 bit enablement of the Linux operating system, the ability of Linux PowerPC to run both 32 and 64 bit applications simultaneously does not prohibit 32 bit applications from taking advantage of this mature Linux distribution. Combined with IBM’s VA Compilers for performance critical applications, Linux PowerPC environment offered by SLES 8 on IBM iSeries and pSeries hardware is an unparalleled platform for developing and deploying Linux solutions. For more information on SuSE Linux, see http://www.suse.com/us/company/index.html.


Compiler Sets and Architecture Awareness

Unlike other Linux platforms, Linux PowerPC offers not only GCC, but also the IBM VA Compiler set. GCC offers robust portability of code intended for compilation in Linux, while the VA Compilers offer a substantial performance increase over GCC.

Both AIX and Linux PowerPC on the PowerPC architecture are run as Big Endian (left to right assignment of addresses to bytes in a data word). As most developers familiar with cross-platform develop will attest, it is of utmost importance to consider endian friendly coding habits when deploying across Little Endian and Big Endian platforms. Much has been written on this topic, and for an excellent review of addressing endian concerns, please see Chapter 2 of the AIX 5L Porting Guide. Another practical and concise reference, is Migrating Tru64 Applications to AIX. These references may prove particularly useful when migrating code with the VA Compilers.


Porting with the GCC Compiler Set

In general, porting code with GCC compilers should be straightforward. Architecture may vary, and occasionally library version discrepancies may arise, but for the most part, GCC is GCC, no matter which architecture it runs on. Architecture specific flags are discouraged for compilation on Linux PPC (for example, –m486, -powerpc), as GCC does not have extensive processor maps for optimization routines on these architectures. Also, without architecture specific flags, binary compatibility will be greater across different models of PPC hardware.

On all architectures, libraries must be compiled with –fPIC; IA32 has this flag applied by default with GCC. This flag creates position independent code, thereby dynamically linking to shared libraries.

Developers not familiar with the GPL should reference it carefully and make sure the terms and conditions of the license are understood.


Porting with the Visual Age Compiler Set

Compiling code with the VA compiler set has shown a significant performance increase on Linux for IBM eServers featuring PowerPC hardware. These compilers, migrated from the high performance compiler set used on AIX, have extensive optimization routines for PowerPC hardware, and therefore should be used for any application that wants to take full advantage of the PowerPC architecture’s potential. However, software originally intended to be compiled with GCC compilers may need more attention when recompiled with VA compilers. Makefiles need to be edited to reflect the correct path to the VA compilers, by default /opt/ibmcmp/. The correct optimization flags should also be set for the architecture (for example, -03–qarch=pwr4–qtune=pwr4 for IBM POWER4 hardware; a complete list of these flags can be found by executing the compiler binary with no arguments). In addition to optimization modes for various PowerPC architecture derivatives, the Visual Age compilers can be instructed to compile software in common mode. This guarantees compatibility across all types of PowerPC architecture at the expense of performance otherwise gained through architecture-specific optimization.

As opposed to GCC, the Visual Age Compilers do not create object code directly. First, .w code is generated, which is fed back to the compiler’s backend optimizer. Once the most efficient compilation method is determined, the compiler generates .o files, and then the final binaries are generated.

A few tips to compiling GCC oriented code with the VisualAge compiler set are listed below:

  • C++ comments: GCC allows C++ style commenting to be used in C files by default, but this is not the case with XLC, the VisualAge C compiler. Since it is not economical to change all the comments in a group of source files to comply with C style commenting, XLC provides a –q argument to allow these comments, -q cpluscmt. When C code is compiled with this flag, both C and C++ style commenting is interpreted.
  • Environment variables are often the easiest way to configure build scripts. As opposed to hand editing Configure scripts and Makefiles, it is recommend that relevant environment variables such as $CC and $CFLAGS be set and the Configure script be allowed to generate the Makefile without the need for hand editing.
  • Configure scripts also need to be aware of the proper platform type. This will be either linux-powerpc-unknown-gnu or linux-powerpc64-unknown-gnu. This should be set for compilation with either GCC or VA by appending the –target= flag to the Configure script.

Although extensive documentation for the VisualAge compilers exists, an argument list is provided at the console by running the compiler with no arguments,for example, $COMPILER_PATH/bin/cc.


Java

In previous distributions of Linux PowerPC, the Blackdown JDK was the only available development kit. Blackdown, while renowned for offering a highly compatible JDK, has not boasted the performance the IBM JDK has delivered to Java applications on Linux Intel and AIX platforms. Yet, thanks to the joint effort of IBM, SuSE, and the open source community, Java migration to Linux PowerPC is now powered by the IBM JDK version 1.3.1. The IBM JDK offers the formal compliance to Java Standards and enterprise class performance expected from IBM development kits. Addition performance gains may be found by recompiling requisite C libraries with the VA Compilers. For more information on the IBM JDK, see IBM Developer Kits for Linux.


Conclusion

Linux PowerPC offers an enterprise class Linux environment, complete with 64 bit kernel, application environment, and toolchains. Unlike other Linux environments, Linux PowerPC offers a twin compiler set representing the best of both worlds: ease of migration with open source code and high performance exploitation of the award winning high performance PowerPC architecture. As a result of more than three years of cooperation between IBM, SuSE, and the open source community, SLES 8 has emerged as a genuine enterprise class distribution and a leader in its field. Application performance available on the PowerPC architecture is now augmented by development tools never before offered on the Linux operating system. In summary, Linux PowerPC is the leading platform for the deployment of high performance Linux applications.


Resources

Learn

  • VisualAge compilers: The best source for GCC compilers for Linux PowerPC is from a certified IBM Linux vendor, such as SuSE Linux, as these vendors have taken efforts to build GCC and its libraries to minimize any version discrepancies.

  • GCC: GCC is the GNU Compiler Collection, which currently contains compilers for C, C++, Objective-C, Fortran, Java, and Ada, as well as libraries for these languages (libstdc++, libgcj,...).

  • penguinppc.org: The home of the linux/pcc port.

  • Stay current with developerWorks technical events and webcasts.

  • Want more? The developerWorks IBM Systems zone hosts hundreds of informative articles and introductory, intermediate, and advanced tutorials on IBM systems.

Discuss

About the author

Matt Davis is a Linux technical consultant in the IBM eServer Solutions Enablement team. As a member of the pSeries Linux project since its inception, he explored and tested emerging technology for pSeries Linux and wrote several reports summarizing his findings. These include Journaling File Systems for Linux for POWER, Parallel Grid Computing with Linux for POWER, Open Source Alternatives to Commercial Software for Linux for POWER, and the Linux Solutions Catalog, to name a few. He came to IBM as an intern during his tenure as a student at the University of Texas at Austin, from which he earned two degrees with academic honors. You can reach him at matdavis@us.ibm.com.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=129354
ArticleTitle=Porting IA32 applications to Linux PowerPC
publish-date=06062003
author1-email=matdavis@us.ibm.com
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers