<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>      I pulled the nestedvm head from <a href="http://git.megacz.com/">http://git.megacz.com/</a> and found it didn&#39;t build.  I decided to try two different techniques for this:<br></div>    1) Patch gcc, binutils, newlib as needed.<br></div>    2) Update gcc, binutils, newlib to newer versions (that build cleanly under gcc-4.8)<br></div>     Good news!  I got *BOTH* to work!<br>==============================<br></div>     First, building nestedvm &quot;as-is&quot;.    There are  several points in the crosscompiler build where gcc-4.8 stops due to finicky little complaints needing one-line patches; after those are patched, MIPS binutils have a buffer overflow, which presumably happens either way but gcc &gt;=4.4 or so detects the overflow and aborts binutils, while older GCC doesn&#39;t detect it.  <br><br>     &#39;CFLAGS=&quot;-D_FORTIFY_SOURCE=0&quot; make&#39;    avoids both issues -- it skips whatever sanity check gcc-4.8 does that makes gcc stop at these points, no patch required; and binutils completes successfully. It looks like John Stroy&#39;s patch of August 24, 2013 disables FORTIFY so his repo at <a href="https://github.com/jdstroy/nestedvm/">https://github.com/jdstroy/nestedvm/</a> should also build AFAIK.<br>================================<br></div>      Second:   I patched up nestedvm to use gcc-4.8.2 and binutils-2.24.  (I didn&#39;t update newlib, I wasn&#39;t sure how far nestedvm&#39;s patches were customizing it...)<br></div>      Please find attached a few patches and a readme.  In the readme, ignore the later steps if you don&#39;t have .tar.gz and classgen.zip pre-downloaded.  I was wiping the nestedvm directory enough to want to pre-load it with these files.<br><br></div>      To summarize the readme, you apply nestedvm.patch, and copy the remaining patches into upstream/patches.  You also copy crt0-override.spec into upstream/misc .   Then &quot;make&quot; to build the stuff, &quot;make nestedvm.jar&quot; if you need a package, etc. just like before.<br>================================<br></div>    Summary of the patches:<br></div>     binutils.patch is EXACTLY the same as the existing nestedvm binutils patches but with updated line numbers, it just adds the mips*-unknown-elf* target.  The original nestedvm binutils patches are not used.<br></div>     gcc.patch also just adds the mips*-unknown-elf* target.  The original nestedvm gcc patches are not used.<br></div><div>     newlib.patch adds a few patches to fix build errors with gcc-4.8. It&#39;s patched in in addition to nestedvm&#39;s patches, since stock newlib is used.<br></div>     nestedvm.patch makes a few patches; it patches the main Makefile and upstream/Makefile, and nestedvm&#39;s Compiler.java and Interpreter.java.   <br></div><div>     crt0-override.spec -- newer gcc no longer uses crt0.o, this has it use it since nestedvm supplies a custom crt0.o and expects the compiler to use it.<br></div><div><br>     In upstream Makefile, I updated the gcc and binutils version numbers that it grabs; changed the gcc download stuff slightly since gcc is no longer seperated into multiple tar.gz files. I added &quot;--disable-libssp&quot; to crosscompiler configure, SSP was causing build problems if I recall correctly.  Oh, yeah!  GCC &gt;=4.6 quit using crt0.o by default!!  So the faff about &quot;crt0-override.spec&quot; is to make crt0.o be included in your static libs and binaries, otherwise you have binaries without a proper start point and nothing runs in nestedvm.  <br>      In main Makefile, -freduce-all-givs is not legal in gcc-4, so I removed that from the default CFLAGs, and I took &quot;-Werror&quot; of the build flags since the examples that were I&#39;m sure warning-free in gcc-3.3.6 now build but shoot out loads of warnings with gcc-4.8.2.  <br></div>    In Compiler.java and Interpreter.java, they used symtab.getGlobalSymbol (for instance to look up the symbol _gp) but objdump tells me _gp is now a *local* symbol; so I replaced uses of &quot;getGlobalSymbol&quot; with &quot;GetSymbol&quot;, which works fine.<br>==========================<br></div>      Testing:<br></div>      I built the jpeg test, and some font test.  The results came out the same, in terms of correct execution.  gcc-4.8.2 results came out 11% *SLOWER* than gcc-3.3.6.  D&#39;oh!  However, I haven&#39;t messed around with LTO, or messing with the CFLAGS (other than removing the one invalid flag in my patch).  I figure at least this&#39;ll allow software that doesn&#39;t build under gcc-3 to be crosscompiled if one wants to.<br><br></div>     Again, do read at least the top of the the readme.txt -- the patches aren&#39;t just all applied to nestedvm, several are copied into the nestedvm upstream/patches directory instead.<br>     Enjoy!<br><br></div>