Setting up the toolchain

Before you can compile software for the ZPU you will need the GCC toolchain.  While you could download a binary toolchain from the Zylin home page, the version there has a bug which causes problems if you use the “-mno-neg” compiler switch, so it’s best to build from source if you can.

The current toolchain source can be found at http://repo.or.cz/w/zpugcc.git

Edit: the repo now has a new home: https://github.com/zylin/zpugcc.git  Better yet, the new repo is up to date with build-fix patches, so much of the rest of this post is no longer relevant.

I’m going to assume you’re running Linux here.   To build the cross-compiler you will need gcc installed on the host system.  You will also need bison installed.  There may be other dependencies too, but hopefully the configure scripts will tell you what they are if any are missing!

The steps required to check out and build the toolchain are as follows:

git clone http://repo.or.cz/r/zpugcc.git
cd zpugcc/toolchain

Now it *should* just be a case of running the build.sh script.

bash build.sh

– however at the time of writing there are a couple of bugs in the repo which prevent it cleanly building, at least on my Mint 13 system. If the repo doesn’t yet contain the fixes, just apply this patch. like so:  [PATCH UPDATED 2015-04-03 to disable the building of docs, to fix an issue with bison 3.0 and to fix a rare internal compiler error that shows up with varargs and debugging information.]

patch -p2 -i /path/to/zpugcc_buildfix_20150403.patch

Now build the toolchain with:

bash build.sh

It will take a while (especially since C++ compiler is now enabled), but the toolchain should now build, and if all goes to plan, install itself in an “install” directory inside the “toolchain” directory.

Now add that directory to your path, like so:
export PATH=/path/to/zpugcc/toolchain/install/bin:$PATH
and you’re ready to compile a ZPU program.

4 thoughts on “Setting up the toolchain

  1. On “newer” environments, the zpu gcc doesn’t compile anymore so easily.
    I get (on cygwin and fedora 19):
    makeinfo –split-size=5000000 -I ../../../binutils/bfd/doc ../../../binutils/bfd/doc/bfd.texinfo
    ./elf.texi:1: warning: @section missing argument
    ../../../binutils/bfd/doc/bfd.texinfo:334: unknown command `colophon’
    ../../../binutils/bfd/doc/bfd.texinfo:345: unknown command `cygnus’
    ./bfdt.texi:325: raising the section level of @subsubsection which is too low
    ./init.texi:5: raising the section level of @subsubsection which is too low
    ./archive.texi:54: raising the section level of @subsubsection which is too low
    ./format.texi:27: raising the section level of @subsubsection which is too low
    ./reloc.texi:495: raising the section level of @subsubsection which is too low
    ./core.texi:8: raising the section level of @subsubsection which is too low
    ./opncls.texi:5: raising the section level of @subsubsection which is too low
    ./libbfd.texi:10: raising the section level of @subsubsection which is too low
    ./cache.texi:14: raising the section level of @subsubsection which is too low
    ./elf.texi:13: raising the section level of @subsubsection which is too low
    make[2]: *** [bfd.info] Error 1

    The first two can be fixed with:

    sed -i -e ‘s/@colophon/@@colophon/’ \
    -e ‘s/doc@cygnus.com/doc@@cygnus.com/’ bfd/doc/bfd.texinfo

    But still, the texinfo documents don’t work anymore 🙁

Leave a Reply to ex68k Cancel reply

Your email address will not be published.