OpenSolaris

  subsites   code review   repo   packages   bugs   defect   polls   planet
You are not signed in. Sign in or register.

Solaris on PowerPC – GNU Toolchain and Host Environment

Status 11/02/07

We reconfigured gcc to handle the c++ language. This means an updated toolchain which calls g++. When building the shared libs we found out that libnsl needed c++ support. If you are building the source tree you will need to upgrade your build tools. Go to the Project Tools page and download version 3. Also grab the latest onbld tar file. They will just install over the ones you currently have.

Overview

The host system is Solaris x86, the development tool chain is GCC 3.4.3, the source is OpenSolaris on PowerPC and the initial contribution has been developed in Sun Labs.

Operations for Getting Started

The community first came up with the tools and this was the simple install list. How does one get the build environment setup going for Solaris on PPC? This didn't really explain how to get there even though most would know via experience. The GNU toolchain has changed since the 1st release and there is now updated binaries in a tar file that get extracted over a users original installation. There is also a patch to created to outline the changes to the source. You will need to upgrade to them to build the latest source release.

  1. Get the cross tool chain version 3.
  2. Get latest SUNWonbld package.
  3. Install SUNWonbld-ppc-extra.tar.bz2. This simply added the empty ctf scripts which allowed the build to commence.
  4. Get and install ppc-devppconbld.tar.bz2. This updates the above files.
  5. Get sources from the Subversion repository or extract the tarball
  6. Copy the environment file usr/src/tools/env/polaris.sh to the root of your workspace and edit GATE and CODEMGR to point to your actual path
  7. Make sure your path includes /opt/onbld/bin and /opt/polaris/bin
  8. execute > bldenv -d /polaris.sh
  9. execute > 'onbld/bin/setup-polaris'
  10. Now you are ready to run make in usr/src/uts/ or one of its subdirectories

We tyically run the following especially if this is your first build on a fresh workspace

cd usr/src/uts
usr/src/uts/make install_h
cd ../head
usr/src/head/make install_h
cd ../stand
usr/src/stand/make install
cd ../psm
usr/src/psm/make install
cd ../uts
usr/src/uts/make install

This will make your kernel and inetboot.

Notes on building GCC and recent changes to it

The revised gcc bins have been in use since we switched over to a solaris based ld. A number of the c runtime objects have also been created.

If you are not a gcc build expert but care to know the torrid details of creating your own gcc toolchain then read on.


All of this was done on our build machine vespa2

First we got sfw from OpenSolaris and installed it since it had the GCC source base that ON uses and builds it all for x86. It was also the source base that our PPC cross started from. The goal was to build GCC for x86, next build the specifc configuration for our needs, then finally reconfigure it to use the solaris cross linker.

Next follow the instructions at the OpenSolaris link below and in the README.sfw.

http://www.opensolaris.org/os/project/sfwnv/install_quickstart/

The source base we started from is essentially here

/export/sfwnv/usr/src/cmd/gcc/

In order to build gcc, you must have the following installed in your path:

      gcc (version 3)
      bison
      gmake
      flex
      gm4  (GNU m4)
      GNU binutils (version 2.15 minimum)

These components are available in the following packages: SUNWbinutils, SUNWbison, SUNWflex, SUNWflexruntime, SUNWgcc, SUNWgccruntime, SUNWgmake, SUNWgm4.

The package that was missing on vespa2 was SUNWflex. We couldn't find this package anywhere that would allow us to do a pkgadd. Well we went on with GCC anyway (however they don't lie and we will end up returning to this topic shortly)

Build GCC with make -f Makefile.sfw and you'll end up with a

/export/sfwnv/usr/src/cmd/gcc/gcc-3.4.3-i386-build/

which contains your native gcc and a ./gcc/gcc-3.4.3/ dir with the generic source. Hey we didn't see any flex complaints… ha who needs it anyway.

Next we applied the patch from the original community work to the ./gcc/gcc-3.4.3 dir. There wasn't a huge amount of changes in that patch once you dug into it.

patch -b -p 0 -i gcc-add-powerpc-unknown-solaris2.patch

Then we tried building GCC. Please RTFM as it will save you from all those silly questions and errors you will surely create. See the GNU Install Guide as it is the best reference to finally getting this going.

Well now it complains about something missing called flex. Oh well that's somewhat familiar.

In sfwnv/pkgdefs there is no SUNWflex, there is a SUNWflexlex and a SUNWflexruntime. In this case we went to our local sfw build and found vespa2:/export/sfwnv/usr/src/cmd/flex built and installed it instead of attempting to find and do a pkgadd of SUNWflex. This will end up with a /usr/local/bin/flex which was what GCC was looking for.

By the time we got to the point of a proper GCC build Bill K. had found a bug in the original patched config.gcc file.

*** config.gcc.orig   Wed Jan 10 21:25:20 2007
--- config.gcc   Wed Jan 10 21:25:40 2007
*********
** 1773,1779 ***
    tmakefile="${tmakefile} t-slibgcc-elf-ver"
    tmdefines="${tmdefines} TARGETGNULD=1"
 else
!       tmakefile="{tmakefile} t-slibgcc-sld"
 fi
 tmfile="${tmfile} tm-dwarf2.h"
#   extraparts="gmon.o crtbegin.o crtend.o"
--- 1773,1779 -—
    tmakefile="${tmakefile} t-slibgcc-elf-ver"
    tmdefines="${tmdefines} TARGETGNULD=1"
 else
!       tmakefile="${tmakefile} t-slibgcc-sld"
 fi
 tmfile="${tmfile} tm-dwarf2.h"
#   extraparts="gmon.o crtbegin.o crtend.o"

It wasn't too long after that we got something working.

Bill revised the configure script

for example we created an objdir named as the original config did

gcc-3.4.3-powerpc-solaris2-build/

$ mkdir objdir
$ cd objdir
$ /export/sfwnv/usr/src/cmd/gcc/gcc-3.4.3/configure 
   --prefix=/opt/polaris
   --target=powerpc-unknown-solaris2.11 
   --disable-nls 
   --disable-shared
   --enable-languages=c,c++ 
   --without-headers 
   --with-local-prefix=/opt/polaris/powerpc-solaris2 
   --with-ld=/opt/onbld/usr/ccs/bin/ld 
   --without-gnu-ld 
   --with-gnu-as 
   --with-build-time-tools=/opt/polaris/bin
$ PATH=/usr/sfw/bin:/opt/polaris/bin:/usr/perl5/bin:$PATH
$ gmake

Then you'd need to do a "gmake install" but not sure you want to do that without saving off the version we have been using first.

Moving Forward

Needless to say building GCC on a solaris box without an sfw base make approach is not advised. Quite a few GNU based utilities are required. The best case solution is to get the cross tools built under and sfw based makefile with a ppc option. The patch itself is fairly straightforward.