Building GCC & Binutils for the Nintendo 64
I had a request to help get a GCC+Binutils running as native win32 exe’s something comperable to the ancient ‘ultra’ N64 toolchain done by Kyoto Microcomputer (resume pdf). Â One interesting thing about their toolchain is that they used a common object format for MS-DOS, DOS/V and MS-DOS on the PC-98 format, along with Win32. Â However the Win32 runtime doesn’t like Win64 environments. Â On Win64 the exew32 driver just complains:
Can’t allocate memory (Error Code=487)
However the stubs in all the exe’s reference exegcc98 exegccv DOS extender’s along with a exegcc. Â However googling around yields nothing.
Running on a x86 version of Windows, however the tools run and report gcc 2.7.2 release 1.2 and the binutils version is simply 2.6 with BFD version 2.6. Â So going with this, and the request to keep it 1997 vintage I went ahead with Gcc 2.7.2.3 and Binutils 2.8.1 as they are the end of the line in both trains of code.
To configure is really a snap, as both support the Windows NT platform directly
sh configure --host=i386-winnt3.5 --target=mips-elf
Binutils 2.8.1 notes:
include/fopen-same.h
make sure this uses MS-DOS rb wb type constraints!
libiberty/xmalloc.c
There is no sbrk on my MinGW32 … so comment out all the sbrk stuff.
bfd/targmatch.sed
My sed LOVES UNIX style text files, so this one shouldn’t be in MS-DOS CRLF format.
binutils/objcopy.c
mkdir only accepts the path on Win32. Â Also there is now chown.
Gcc 2.7.2.3 notes:
c-gperf.h
‘__inline’ for is_reserved_word needs to be commented out.
config/mips/mips.h
Set like the following for both ASM_FINAL_SPEC to prevent the t-mips from trying to be run.
#define ASM_FINAL_SPEC “\
+%{pipe:-}”
config/winnt/xm-winnt.h
OBJECT_SUFFIX “.o”
Just because we are on Windows NT, doesn’t mean we want an .obj object suffix.
gcc.c
__spawnv : __spawnvp work better as _spawnv : _spawnvp
obstack.h
*((void **)__o->next_free)++ = ((void *)datum);
confuses newer compilers, with this error message:
obstack.h:341:32: error: lvalue required as increment operand
replace it with with:
*(__o->next_free)++ = ((void *)datum);
So at the end I have a cross compiler, and I can generate object files, and link files that the final tool MILD can then use and produce N64 ROM images. Â It’s not a 100% solution, as I don’t see any mention of MILD being GNU, however the compiler and binutils is running on Windows 10 x64!
I built a few demos and tested with the 1964 emulator.
And there you have it. Â For anyone who cares, you can download the toolchain + source here:Â winnt3.5_i386-mips_elf-gcc-2.7.2.3_binutils-2.8.1.7z