hercules-390 / hyperion

Hercules 390
Other
246 stars 69 forks source link

Hyperion fails to compile using VS2008 due to absence of stdbool.h #250

Closed srorso closed 6 years ago

srorso commented 6 years ago

Issue affects both the current NMake build and the forthcoming CMake build.

Additional symptom: Incorrect binary floating point (BFP) results for selected instructions when compiled on Windows using the NMake build.

The version of SoftFloat-3a headers included with Hyperion unconditionally includes stdbool.h. These headers are one commit back from the headers included in SoftFloat-3a, which make the #include conditional on HAVE_STDBOOL.H. The CMake build for SoftFloat-3a tests for stdbool.h and sets HAVE_STDBOOL.H accordingly. Neither the CMake build for Hercules, the GNU Autotools build, nor the NMake Windows build test for stdbool.h.

The incorrect BFP results occur because the NMake build does not report the presence of stdbool.h on VS2015+ systems, and Hyperion is compiled with a different definition for the type bool (int, defined in softfloat_stdTypes.h or worse, not at all) than SoftFloat (_bool, a char-sized type defined in stdbool.h).

There is no requirement that a c compiler map the type bool to a char.

The types and macros defined in stdbool.h or substituted in softfloat_stdTypes.h are used only within ieee.c or in the interface between ieee.c and Softfloat-3a. Other Hercules headers define TRUE and FALSE as 1 and 0 respectively.

This issue could occur on an older (non-C99) UNIX-like system, although it has not been reported.

Corrective actions:

  1. Update CMake/herc22_Userland.cmake to test for stdbool.h
  2. Update CMake/cmakeconfig.h.in to report the result of the above test.
  3. Update msvc.makefiles.includes\HERC_FLAGS.msvrc to report the presence of stdbool.h when the build tool is VS2015 or better. A compile test is not required.
  4. Update the SoftFloat-3a headers in Hyperion to match those in SoftFloat-3a.
  5. Update configure.ac to test for stdbool.h (Ugh!)
  6. Optional, but desirable: change the definition of bool in softfloat_stdTypes.h from int to char.

The above enable build from source. It "kicks the can down the road" a bit, though, when considering a stand-alone binary package for SoftFloat-3a; would would have to build one for C99 systems and one for pre-C99 systems.

srorso commented 6 years ago

Commits verified.