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.
– 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:
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:
and you’re ready to compile a ZPU program.