This set of AltiVec enabled GNU tools includes binutils-2.9.5.0.12, gcc-2.95.2, gdb-4.17, and newlib-1.8.1. This is a complete set to create a powerpc-eabisim cross environment and a starting point for a G4 native set of tools implementing the AltiVec Programming Model. To complete the G4 native tools, the following are needed: * Use the gcc-2.95.2 as part of the gcc-2.95.2 RPM. The latter additionally includes libstdc++-compat.tar, libgcj-2.95.1, and gcc-2.95.2-warn.patch. * Implement the AltiVec extensions in gdb. This involves extending the linux kernel interface to support reading and writing the vector registers (with ptrace and /proc). The version of gdb used for linux is gdb-4.17.0.11. The gdb-4.17 patch is a starting point, but the files ppclnx-nat.c and ppclnx-tdep.c (new in gdb-4.17.0.11) need to be modified. * Implement the AltiVec extensions in libc. Implement the vector format strings in scanf and printf. Add vec_calloc, vec_free, vec_malloc, and vec_realloc. Extend setjmp/longjmp by adding __vec_setjmp, __vec_longjmp to save and restore the vector registers. The newlib-1.8.1 patch implements these. Here's the complete list of instructions on how to build, install, and use the GNU tools hosted on both Solaris and a PC under Cygwin32. You may also build binutils and gcc for native PPC Linux. There are 6 tar files associated with the GNU tools: 0.9 Mb AltiVec-patch.tar Patch files for each of the GNU packages. 131.5 Mb AltiVec-src.tar The GNU packages with the patches applied. 18.2 Mb AltiVec-common-bin.tar Headers, libraries, and other binary files for the powerpc-eabisim target common to both Solaris and Cygwin32. 19.8 Mb AltiVec-sun-bin.tar Executables for the powerpc-eabisim target hosted on Solaris. 14.6 Mb AltiVec-pc-bin.tar Executables for the powerpc-eabisim target hosted on a PC under Cygwin32. 32.7 Mb AltiVec-linux-bin.tar Executables for the powerpc-redhat-linux-gnu target hosted on powerpc-redhat-linux-gnu. If you just want to use the Solaris binaries, follow steps 3 and 14. If you just want to use the Cygwin32 binaries, follow steps 5, 6, and 14. If you just want to use the Linux binaries, follow steps 12 and 14 1. Establish your environment for Solaris and Linux. XGNU is needed to build and run the GNU tools on Solaris and Linux. GNU and PCGNU are needed to build the GNU tools on Solaris to be hosted on a PC under Cygwin32. setenv XGNU /usr/local/AltiVec setenv GNU /... # Fill this in. setenv PCGNU /AltiVec set path=($XGNU/bin $GNU/bin $path) 2. Install the sources in $XGNU/src with either step 2a or 2b. 2a. Use the AltiVec-src.tar file. cd /; tar xf .../AltiVec-src.tar 2b. Fetch, unpack, and patch the GNU packages. Fetch and untar binutils-2.9.5.0.12, gcc-2.95.2, gdb-4.17, and newlib-1.8.1. Only binutils and gcc are used on Linux. I used the following: ftp://ftp.varesearch.com/pub/support/hjl/binutils/binutils-2.9.5.0.12.tar.gz ftp://gatekeeper.dec.com/pub/GNU/gdb/gdb-4.17.tar.gz ftp://go.cygnus.com/pub/sourceware.cygnus.com/pub/egcs/releases/gcc-2.95.2/gcc-2.95.2.tar.gz ftp://ftp.cygnus.com/pub/newlib/newlib-1.8.1.tar.gz Apply the patches (found in Altivec-patch.tar) to each of these trees. 3. Install the Solaris binaries in $XGNU or build them with steps 4a through 4e. cd /usr/local; tar xf .../AltiVec-common-bin.tar cd /; tar xf .../AltiVec-sun-bin.tar 4a. In $XGNU/src/newlib-1.8.1/newlib/libc: cd $XGNU/src/newlib-1.8.1/newlib/libc mkdir -p $XGNU/powerpc-eabisim/include find include -print | cpio -pdu $XGNU/powerpc-eabisim 4b. In $XGNU/src/binutils-2.9.5.0.12: cd $XGNU/src/binutils-2.9.5.0.12 # To debug use: # env CFLAGS=-g configure --target=powerpc-eabisim --prefix=$XGNU > & ,config configure --target=powerpc-eabisim --prefix=$XGNU >& ,config make >& ,make make install >& ,install 4c. In $XNGU/src/gcc-2.95.2: cd $XGNU/src/gcc-2.95.2 configure --target=powerpc-eabisim --prefix=$XGNU >& ,config # Dummy out most of objc libs. cd $XGNU/src/gcc-2.95.2 env "LANGUAGES=c proto gcov c++" make -e all-gcc >& ,make env "LANGUAGES=c proto gcov c++" make -e install-gcc >& ,install 4d. In $XGNU/src/gdb-4.17: # This is configured to run fast. cd $XGNU/src/gdb-4.17 configure --enable-sim-powerpc --target=powerpc-eabisim \ --enable-sim-stdio \ --enable-sim-icache=insn,define,semantic \ --enable-sim-smp=no \ --enable-sim-decode=complex \ --enable-sim-reserved-bits=no \ --enable-sim-alignment=nonstrict \ --prefix=$XGNU >& ,config # This is configured to build fast. cd $XGNU/src/gdb-4.17 configure --enable-sim-powerpc --target=powerpc-eabisim \ --enable-sim-cflags="-g -O0" \ --enable-sim-smp=no \ --enable-sim-inline=no \ --enable-sim-reserved-bits=no \ --enable-sim-alignment=nonstrict \ --prefix=$XGNU >& ,config make >& ,make make install >& ,install 4e. In $XGNU/src/newlib-1.8.1: cd $XGNU/src/newlib-1.8.1 configure --target=powerpc-eabisim --prefix=$XGNU --enable-multilib=no >& ,config env CFLAGS="-g -O2 -fvec" make -e >& ,make make install >& ,install 5. To run the GNU tools hosted on a PC under Cygwin32, you need the cygwin user package. The full package will work also and is needed if you want to build the GNU tools hosted on a PC under Cygwin32. Fetch and install Cygwin on your PC. I used ftp://go.cygnus.com/pub/sourceware.cygnus.com/cygwin/cygwin-b20/full.exe 6. Install the PC binaries in C:/AltiVec or build them with steps 7 to 11. On the PC cd //c tar xf .../AltiVec-common-bin.tar tar xf .../AltiVec-pc-bin.tar 7. Create a set of "mimic" trees that point to the sources in $XGNU/src. These trees consist of directories containing symbolic links to the files in $XGNU/src. By convention, these are placed in ~/obj and have a name that indicates the package, target, and host. The command mimic is not included. You can use a copy of the sources if you like. mimic $XGNU/src/binutils-2.9.5.0.12 ~/obj/binutils-pc-sun mimic $XGNU/src/binutils-2.9.5.0.12 ~/obj/binutils-eabi-pc mimic $XGNU/src/gcc-2.95.2 ~/obj/gcc-pc-sun mimic $XGNU/src/gcc-2.95.2 ~/obj/gcc-eabi-pc mimic $XGNU/src/gdb-4.17 ~/obj/gdb-pc-sun 8. To build the GNU tools hosted on a PC under Cygwin32, you first build and install cross tools that run on Solaris and target a PC under Cygwin32. 8a. Copy the lib and include trees from Cygwin32 to your cross tool area on Solaris. On the PC cd //c/cygwin/cygwin-b20/H-i586-cygwin32/i586-cygwin32 tar cf .../cygwin.tar lib include Copy cygwin.tar to Solaris. Then, on Solaris mkdir -p $GNU/i586-cygwin32 cd $GNU/i586-cygwin32 tar xf .../cygwin.tar 8b. Patch include/sys/stat.h. Cygwin32 apparently doesn't use the stat-dj.h structure. It seems to use the newlib version. *** ./include/sys/stat.h.orig Mon Dec 21 07:34:55 1998 --- ./include/sys/stat.h Mon Dec 21 07:31:45 1998 *************** *** 10,16 **** --- 10,18 ---- #include + #ifndef __CYGWIN32__ #ifdef __i386__ #ifdef __MSDOS__ #include "stat-dj.h" + #endif #endif #endif 8c. In ~/obj/binutils-pc-sun: cd ~/obj/binutils-pc-sun configure --target=i586-cygwin32 --prefix=$GNU >& ,config make >& ,make make install >& ,install 8d. In ~/obj/gcc-pc-sun cd ~/obj/gcc-pc-sun configure --target=i586-cygwin32 --prefix=$GNU >& ,config # Dummy out most of objc libs. env "LANGUAGES=c c++" make -e all-gcc >& ,make env "LANGUAGES=c c++" make -e install-gcc >& ,install 9. Build and install the executables that run on a PC under Cygwin32 and target powerpc-eabisim. 9a. In ~/obj/binutils-eabi-pc cd ~/obj/binutils-eabi-pc configure --build=sparc-sun-solaris2.6 --host=i586-cygwin32 \ --target=powerpc-eabisim --prefix=$PCGNU >& ,config make >& ,make make install >& ,install # The install step is incomplete. ln $PCGNU/bin/powerpc-eabisim-ld.exe \ $PCGNU/lib/gcc-lib/powerpc-eabisim/gcc-2.95.2/ld.exe 9b. In ~/obj/gcc-eabi-pc cd ~/obj/gcc-eabi-pc configure --build=sparc-sun-solaris2.6 --host=i586-cygwin32 \ --target=powerpc-eabisim --prefix=$PCGNU >& ,config # Currently, this fails building libstdc++. I haven't found a # way to build the executables only, so just make sure the installs # below work. env "LANGUAGES=c proto c++" make -e all-gcc >& ,make # The install step doesn't work, so it must be done explicitly: /bin/sh ./install-sh -c gcc/g++.exe $PCGNU/bin/powerpc-eabisim-c++.exe ln $PCGNU/bin/powerpc-eabisim-c++.exe $PCGNU/bin/powerpc-eabisim-g++.exe /bin/sh ./install-sh -c gcc/xgcc.exe $PCGNU/bin/powerpc-eabisim-gcc.exe ln $PCGNU/bin/powerpc-eabisim-gcc.exe $PCGNU/powerpc-eabisim/bin/gcc.exe /bin/sh ./install-sh -c gcc/protoize.exe $PCGNU/bin/protoize.exe /bin/sh ./install-sh -c gcc/unprotoize.exe $PCGNU/bin/unprotoize.exe /bin/sh ./install-sh -c gcc/cc1.exe \ $PCGNU/lib/gcc-lib/powerpc-eabisim/gcc-2.95.2/cc1.exe /bin/sh ./install-sh -c gcc/cc1plus.exe \ $PCGNU/lib/gcc-lib/powerpc-eabisim/gcc-2.95.2/cc1plus.exe /bin/sh ./install-sh -c gcc/cpp.exe \ $PCGNU/lib/gcc-lib/powerpc-eabisim/gcc-2.95.2/cpp.exe 9c. In ~/obj/gdb-eabi-pc # This is configured to run fast. cd ~/obj/gdb-eabi-pc configure --build=sparc-sun-solaris2.6 --host=i586-cygwin32 \ --target=powerpc-eabisim --prefix=$PCGNU \ --enable-sim-stdio \ --enable-sim-icache=insn,define,semantic \ --enable-sim-smp=no \ --enable-sim-decode=complex \ --enable-sim-reserved-bits=no \ --enable-sim-alignment=nonstrict >& ,config # This is configured to build fast and is more eaisly debugged. cd ~/obj/gdb-eabi-pc configure --build=sparc-sun-solaris2.6 --host=i586-cygwin32 \ --target=powerpc-eabisim --prefix=$PCGNU \ --enable-sim-powerpc \ --enable-sim-cflags="-g -O0" \ --enable-sim-smp=no \ --enable-sim-inline=no \ --enable-sim-reserved-bits=no \ --enable-sim-alignment=nonstrict >& ,config make >& ,make # The install step doesn't work, so it must be done explicitly: /bin/sh ./install-sh -c gdb/gdb $PCGNU/bin/powerpc-eabisim-gdb.exe /bin/sh ./install-sh -c sim/ppc/run $PCGNU/bin/powerpc-eabisim-run.exe 10. Use the headers, libaries, and other binary files from the Solaris build in step 3 or 4. These files can be used without change and are difficult to make with the steps used above. cd $XGNU find bin/. include/. info/. lib/. man/. powerpc-eabisim/. -type f | \ cpio -pdu $PCGNU cd $PCGNU rm -f bin/cpp \ bin/gcov \ bin/powerpc-eabisim-addr2line \ bin/powerpc-eabisim-ar \ bin/powerpc-eabisim-as \ bin/powerpc-eabisim-c++ \ bin/powerpc-eabisim-c++filt \ bin/powerpc-eabisim-g++ \ bin/powerpc-eabisim-gasp \ bin/powerpc-eabisim-gcc \ bin/powerpc-eabisim-gdb \ bin/powerpc-eabisim-ld \ bin/powerpc-eabisim-nm \ bin/powerpc-eabisim-objcopy \ bin/powerpc-eabisim-objdump \ bin/powerpc-eabisim-protoize \ bin/powerpc-eabisim-ranlib \ bin/powerpc-eabisim-readelf \ bin/powerpc-eabisim-run \ bin/powerpc-eabisim-size \ bin/powerpc-eabisim-strings \ bin/powerpc-eabisim-strip \ bin/powerpc-eabisim-unprotoize \ lib/gcc-lib/powerpc-eabisim/2.95.2/cc1 \ lib/gcc-lib/powerpc-eabisim/2.95.2/cc1plus \ lib/gcc-lib/powerpc-eabisim/2.95.2/collect2 \ lib/gcc-lib/powerpc-eabisim/2.95.2/cpp \ powerpc-eabisim/bin/ar \ powerpc-eabisim/bin/as \ powerpc-eabisim/bin/gcc \ powerpc-eabisim/bin/ld \ powerpc-eabisim/bin/nm \ powerpc-eabisim/bin/ranlib \ powerpc-eabisim/bin/strip 11. Copy the $PCGNU tree onto the PC. On Solaris tar cf .../altivec.tar /AltiVec Copy altivec.tar to the PC. Then on the PC cd //c tar xf .../altivec.tar 12. Install the Linux binaries in $XGNU or build them with steps 13a through 13e. cd /; tar xf .../AltiVec-linux-bin.tar 13a. In $XGNU/src/binutils-2.9.5.0.12: cd $XGNU/src/binutils-2.9.5.0.12 # To debug use: # env CFLAGS=-g configure --prefix=$XGNU powerpc-redhat-linux-gnu > & ,config configure --prefix=$XGNU powerpc-redhat-linux-gnu > & ,config make >& ,make make install >& ,install 13b. In $XNGU/src/gcc-2.95.2: cd $XGNU/src/gcc-2.95.2 configure --prefix=$XGNU powerpc-redhat-linux-gnu > & ,config # Dummy out most of objc libs. cd $XGNU/src/gcc-2.95.2 env "LANGUAGES=c proto gcov c++" make -e all-gcc >& ,make env "LANGUAGES=c proto gcov c++" make -e install-gcc >& ,install 14. To build, run, and debug programs, On the PC export PATH=/Altivec/bin:$PATH On Solaris export PATH=/usr/local/AltiVec/bin:$PATH # If you forget -lc -lmvme you'll get emul_bug_api: unimplemented ... powerpc-eabisim-gcc -Wl,-Ttext,0x4000 ... -lc -lmvme -o yada.emb powerpc-eabisim-run yada.emb powerpc-eabisim-gdb yada.emb (gdb) target sim (gdb) load # To use more unix interfaces (fopen for example), you can build and # run for the sim environment. You'll need to drop the -Ttext 0x4000 # option that identifies the executable as using the bugapi. You must # add an explicit -e linux option to use the linux api: powerpc-eabisim-gcc ... -o yada.emb powerpc-eabisim-run -e linux yada.emb powerpc-eabisim-gdb yada.emb (gdb) ta si -e linux (gdb) lo On Linux export PATH=/usr/local/AltiVec/bin:$PATH gcc ... -o yada yada