autc04 / Retro68

a gcc-based cross-compiler for classic 68K and PPC Macintoshes
GNU General Public License v3.0
537 stars 51 forks source link

68k Seems to lack any FPU support. #252

Open EGAMatsu opened 1 month ago

EGAMatsu commented 1 month ago

In the ClassiCube Project, we seemed to notice that there is NO FPU SUPPORT, so out 68k builds are beyond sluggish.

autc04 commented 1 month ago

Well, the 68000 had no FPU. Starting with the 68020, the FPU was available as an optional coprocessor called the 68881. Therefore, the GCC compiler does not use the FPU by default, instead you have to enable it using a compiler option.

https://gcc.gnu.org/onlinedocs/gcc/M680x0-Options.html

-mhard-float for using the hardware FPU. -msoft-float for turning it off.

-m68020 and higher imply -mhard-float, even though the coprocessor was optional and there were many old macs without it (so compiling for -m68020 -msoft-float also makes sense).

superdave commented 1 month ago

Indeed. 68020 and 68030 did not have built-in FPUs, and there were many macs which did not ship with them (all of which, AFAICR, could be later upgraded to have them, and also AFAICR the 68881 and 68882 were pin and mostly software compatible).

The 68040 was FPU-optional (the 68LC040 had either no or a disabled FPU), but one could not be installed externally; however, all 68040 Macs except for the PowerBooks used socketed CPUs and could upgrade that way (and even the PowerBooks could, if you knew a good technician; we had a full ‘040 PowerBook 540c back in the day).

All of that is to say that FPU support was fairly sparse on 68k machines in the real world, and compiling without float support is the default for a reason. You’ll find the same true for 32-bit ARM, which didn’t even have a single floating-point instruction set but several mutually incompatible ones.