mpir
mpir copied to clipboard
Building without one of the HAVE_DOUBLE constants fails
I'm building in MSYS2 on WIN64, actually testing my compiler (orange C) on the mpir sources... one of the problems I'm having seems to be on your end. That is that none of the HAVE_DOUBLE_* constants are getting defined. I think because the object file format of orange C is ASCII rather than BINARY. From what I can tell the floating point detection in the autoconfig files needs a binary object file format.
Which itself isn't the real issue. Unfortunately a side effect of not having one of the HAVE_DOUBLE_* constants defined is that the definition of 'union ieee_double_extract' is never made, but it is referenced anyway by at least one of the files in the mpn directory. The compiles fail at that point.
Rechecked: the things in error are
- mpn\generic\get_d.c: mpn_get_d
- tests\misc.c: tests_infinity_d, tests_isinf
Those use the union ieee_double_extract
without it being defined and they should either check for _GMP_IEEE_FLOATS
(which is defined along the structure definition) or gmp-impl.h should define "something" (maybe fallback to little-indian?)
Until this is solved I suggest to adjust gmp-impl.h (patch for 3.0.0 version but current version in master has no change in that area):
@@ -3404,9 +3404,8 @@
} s;
double d;
};
-#endif
-#if HAVE_DOUBLE_IEEE_LITTLE_ENDIAN
+#elif HAVE_DOUBLE_IEEE_LITTLE_ENDIAN
#define _GMP_IEEE_FLOATS 1
union ieee_double_extract
{
@@ -3419,9 +3418,8 @@
} s;
double d;
};
-#endif
-#if HAVE_DOUBLE_IEEE_BIG_ENDIAN
+#elif HAVE_DOUBLE_IEEE_BIG_ENDIAN
#define _GMP_IEEE_FLOATS 1
union ieee_double_extract
{
@@ -3434,6 +3432,10 @@
} s;
double d;
};
+
+#else
+#error currently unsupported environment, see #278
+
#endif
Rechecked with GMP 6.1.2 - those check the define before using the structure. I'll create a PR to do the same.
I eventually just defined it... but in the meantime I did a successful compile without. The tests fail though, I think mpr_set_d can get into a loop dividing infinity by a rational number and the exit condition never gets met (because infinity/x = infinity).
I'm posting the direct error I faced as it took a while to find the related issue:
get_d.c: In function '__gmpn_get_d':
get_d.c:125:34: error: storage size of 'u' isn't known
125 | union ieee_double_extract u;
| ^
make[2]: *** [Makefile:465: get_d.lo] Error 1
Hopefully this comes up better in searches for lost people like me.
@GitMensch I tried your patch, but I still ended up with errors. I created my own (incorrect, but building) patch #296 for anyone that comes across this issue.
Rechecked with GMP 6.1.2 - those check the define before using the structure. I'll create a PR to do the same.
Would really appreciate such a PR, if you get around to it would love a cc.