Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building without one of the HAVE_DOUBLE constants fails #278

Open
LADSoft opened this issue Oct 1, 2019 · 5 comments
Open

Building without one of the HAVE_DOUBLE constants fails #278

LADSoft opened this issue Oct 1, 2019 · 5 comments

Comments

@LADSoft
Copy link

LADSoft commented Oct 1, 2019

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.

@GitMensch
Copy link
Contributor

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

@GitMensch
Copy link
Contributor

Rechecked with GMP 6.1.2 - those check the define before using the structure. I'll create a PR to do the same.

@LADSoft
Copy link
Author

LADSoft commented Feb 5, 2020

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).

@acxz
Copy link

acxz commented Aug 1, 2022

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.

@acxz
Copy link

acxz commented Aug 1, 2022

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants