KMC: Difference between revisions

From Decompedia
Jump to navigation Jump to search
(Added details about the toolchain and the KMC wrapper)
 
Line 18: Line 18:


* [[Dr. Mario 64]]
* [[Dr. Mario 64]]
* [[Duke Nukem Zero Hour]]
* [[Duke Nukem: Zero Hour]]
* [[libultra]] ([[ultralib]])
* [[libultra]] ([[ultralib]])
* [[Mario Party]]
* [[Mario Party]]

Latest revision as of 19:38, 23 September 2023

On the N64 decompilation world we refer to "KMC" as an specific compiler distributed by the Japanese company Kyoto Microcomputer, Co. Ltd. (hence the name). This toolchain is a mostly unchanged fork of GNU GCC 2.7.2 paired with a fork of GNU Binutils 2.6. The Binutils fork has some patches to work around hardware issues with the CPU used in the Nintendo 64 console as well as a patch to automatically align variables above a specific size to meet DMA alignment requirements for the N64's Reality Coprocessor. There are a few releases of the KMC toolchain, but they all seem to generate identical code.

Running the KMC Toolchain

The original KMC toolchain binaries are available, but were built as programs that were run with a DOS Extender under Windows XP. This meant they were compiled as 32-bit applications but used the DOS system calls to interface with the operating system. Trying to run them under more Windows versions either not work or lead to issues such as restricted maximum path lengths or memory allocation problems.

KMC Wrapper

The first mechanism to allow the KMC toolchain to run without issues was the KMC GCC wrapper made by community member Wiseguy. It loaded the original binaries into memory and patched them to replace DOS system calls with reimplementations using the C standard library. After patching, it would run them natively as 32-bit code. It also patched or replaced various functions to work around issues such as short maximum path lengths.

KMC Native Build

While the KMC wrapper allowed running the toolchain, it had issues with portability. As a replacement, Wiseguy reverse engineered the changes made to GCC and Binutils made by the original Kyoto Microcomputer team and replicated them in the source code of GCC 2.7.2/Binutils 2.6. This meant the KMC toolchain could now be built as a native executable for modern systems from source code, allowing it to run as a 64-bit executable and on other platforms such as Mac OS. Since then, several quality of life changes have been added to the toolchain. The two components of the toolchain are hosted in the decompals Github organization:

Projects using this compiler

The following is the list of known projects that use this compiler: