{"id":637,"date":"2013-08-07T23:36:29","date_gmt":"2013-08-07T23:36:29","guid":{"rendered":"http:\/\/retroramblings.net\/?page_id=637"},"modified":"2015-04-23T22:58:33","modified_gmt":"2015-04-23T22:58:33","slug":"setting-up-the-toolchain","status":"publish","type":"page","link":"https:\/\/retroramblings.net\/?page_id=637","title":{"rendered":"Setting up the toolchain"},"content":{"rendered":"<p>Before you can compile software for the ZPU you will need the GCC toolchain.\u00a0 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 &#8220;-mno-neg&#8221; compiler switch, so it&#8217;s best to build from source if you can.<\/p>\n<p><del>The current toolchain source can be found at <a href=\"http:\/\/repo.or.cz\/w\/zpugcc.git\">http:\/\/repo.or.cz\/w\/zpugcc.git<\/a><\/del><\/p>\n<p>Edit: the repo now has a new home: <a href=\"https:\/\/github.com\/zylin\/zpugcc.git\">https:\/\/github.com\/zylin\/zpugcc.git\u00a0 <\/a>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.<\/p>\n<p>I&#8217;m going to assume you&#8217;re running Linux here.\u00a0\u00a0 To build the cross-compiler you will need gcc installed on the host system.\u00a0 You will also need bison installed.\u00a0 There may be other dependencies too, but hopefully the configure scripts will tell you what they are if any are missing!<\/p>\n<p>The steps required to check out and build the toolchain are as follows:<\/p>\n<pre>git clone http:\/\/repo.or.cz\/r\/zpugcc.git\r\ncd zpugcc\/toolchain<\/pre>\n<p>Now it *should* just be a case of running the build.sh script.<\/p>\n<pre>bash build.sh<\/pre>\n<p><del> &#8211; 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&#8217;t yet contain the fixes, <a href=\"http:\/\/retroramblings.net\/downloads\/zpugcc_buildfix_20150403.patch\">just apply this patch.<\/a> like so:\u00a0 [<strong>PATCH UPDATED 2015-04-03<\/strong> 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.]<\/del><\/p>\n<p><del>patch -p2 -i \/path\/to\/zpugcc_buildfix_20150403.patch<\/del><\/p>\n<p><del>Now build the toolchain with:<\/del><\/p>\n<pre><del>bash build.sh<\/del><\/pre>\n<p>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 &#8220;install&#8221; directory inside the &#8220;toolchain&#8221; directory.<\/p>\n<p>Now add that directory to your path, like so:<br \/>\nexport PATH=\/path\/to\/zpugcc\/toolchain\/install\/bin:$PATH<br \/>\nand you&#8217;re ready to compile a ZPU program.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Before you can compile software for the ZPU you will need the GCC toolchain.\u00a0 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 &#8220;-mno-neg&#8221; &hellip; <a href=\"https:\/\/retroramblings.net\/?page_id=637\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":627,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-637","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/pages\/637","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=637"}],"version-history":[{"count":8,"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/pages\/637\/revisions"}],"predecessor-version":[{"id":1080,"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/pages\/637\/revisions\/1080"}],"up":[{"embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/pages\/627"}],"wp:attachment":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}