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

Sagelib build error on Cygwin using system GMP #27714

Closed
embray opened this issue Apr 23, 2019 · 17 comments
Closed

Sagelib build error on Cygwin using system GMP #27714

embray opened this issue Apr 23, 2019 · 17 comments

Comments

@embray
Copy link
Contributor

embray commented Apr 23, 2019

Since #27212 I get an error building sagelib:

[sagelib-8.8.beta3] gcc -shared -Wl,--enable-auto-image-base -L/home/embray/src/sagemath/sage/local/lib -Wl,-rpath,/home/embray/src/sagemath/sage/local/lib -L/home/embray/src/sagemath/sage/local/lib -Wl,-rpath,/home/embray/src/sagemath/sage/local/lib build/temp.cygwin-2.9.0-x86_64-2.7/build/cythonized/sage/ext/fast_callable.o -L/home/embray/src/sagemath/sage/local/lib -L/home/embray/src/sagemath/sage/local/lib/python2.7/config -L/home/embray/src/sagemath/sage/local/lib -lpython2.7 -o build/lib.cygwin-2.9.0-x86_64-2.7/sage/ext/fast_callable.dll
[sagelib-8.8.beta3] build/cythonized/sage/data_structures/bounded_integer_sequences.c:3442:29: error: conflicting types for ‘__pyx_f_4sage_15data_structures_25bounded_integer_sequences_limb_one_set_bit’
[sagelib-8.8.beta3]  static CYTHON_INLINE mp_limb_t __pyx_f_4sage_15data_structures_25bounded_integer_sequences_limb_one_set_bit(mp_bitcnt_t __pyx_v_n) {
[sagelib-8.8.beta3]                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[sagelib-8.8.beta3] build/cythonized/sage/data_structures/bounded_integer_sequences.c:3170:29: note: previous declaration of ‘__pyx_f_4sage_15data_structures_25bounded_integer_sequences_limb_one_set_bit’ was here
[sagelib-8.8.beta3]  static CYTHON_INLINE mp_limb_t __pyx_f_4sage_15data_structures_25bounded_integer_sequences_limb_one_set_bit(mp_bitcnt_t); /*proto*/
[sagelib-8.8.beta3]                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

followed by a long string of similar errors in the same module.

This is probably similar to the error fixed in #27713 but a different manifestation thereof.

This is partially fixed by the PR linked below, but then another related error arises related to flint and/or zn_poly abusing GMP type definitions:

[sagelib-8.8.beta3] g++ -shared -Wl,--enable-auto-image-base -L/home/embray/src/sagemath/sage/local/lib -Wl,-rpath,/home/embray/src/sagemath/sage/local/lib -L/home/embray/src/sagemath/sage/local/lib -Wl,-rpath,/home/embray/src/sagemath/sage/local/lib build/temp.cygwin-2.9.0-x86_64-2.7/build/cythonized/sage/rings/polynomial/polynomial_zz_pex.o -L/home/embray/src/sagemath/sage/local/lib -L/home/embray/src/sagemath/sage/local/lib/python2.7/config -L/home/embray/src/sagemath/sage/local/lib -lntl -lgmp -lstdc++ -lpython2.7 -o build/lib.cygwin-2.9.0-x86_64-2.7/sage/rings/polynomial/polynomial_zz_pex.dll -lpari
[sagelib-8.8.beta3] [380/437] gcc -I/usr/include/ncurses -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wno-unused -I./sage/cpython -I./sage/libs/ntl -I/home/embray/src/sagemath/sage/local/lib/python2.7/site-packages/cysignals -I/home/embray/src/sagemath/sage/local/include -I/home/embray/src/sagemath/sage/src -I/home/embray/src/sagemath/sage/src/sage/ext -I/home/embray/src/sagemath/sage/local/include/python2.7 -I/home/embray/src/sagemath/sage/local/lib/python2.7/site-packages/numpy/core/include -Ibuild/cythonized -I/home/embray/src/sagemath/sage/local/include/python2.7 -c build/cythonized/sage/rings/polynomial/polynomial_zmod_flint.cpp -o build/temp.cygwin-2.9.0-x86_64-2.7/build/cythonized/sage/rings/polynomial/polynomial_zmod_flint.o -fno-strict-aliasing -DCYTHON_CLINE_IN_TRACEBACK=1 -std=gnu++11
[sagelib-8.8.beta3] In file included from build/cythonized/sage/rings/polynomial/polynomial_zmod_flint.cpp:697:0:
[sagelib-8.8.beta3] ../local/include/zn_poly/zn_poly.h:72:23: error: conflicting declaration ‘typedef long unsigned int mp_limb_t’
[sagelib-8.8.beta3]  typedef unsigned long  ulong;
[sagelib-8.8.beta3]                        ^~~~~~~
[sagelib-8.8.beta3] In file included from build/cythonized/sage/rings/polynomial/polynomial_zmod_flint.cpp:676:0:
[sagelib-8.8.beta3] /usr/include/gmp.h:138:32: note: previous declaration as ‘typedef long long unsigned int mp_limb_t’
[sagelib-8.8.beta3]  typedef unsigned long long int mp_limb_t;
...

and followed by some other errors that look related.

Upstream PR: flintlib/flint#557

Upstream: Fixed upstream, but not in a stable release.

CC: @jdemeyer

Component: porting: Cygwin

Keywords: cygwin sagelib gmp flint

Issue created by migration from https://trac.sagemath.org/ticket/27714

@embray embray added this to the sage-8.8 milestone Apr 23, 2019
@embray

This comment has been minimized.

@embray
Copy link
Contributor Author

embray commented Apr 23, 2019

comment:2

Hmm, changing these ctypedefs to what I actually have in my gmp.h does not seem to fix it. If my reading of the Cython docs is correct this actually should't matter anyways: It's still going to output literally mp_limb_t to the C code and does not redefine it in any way.

The "conflicting types" error first appears just after

/* Late includes */
#include "macros.h"
#include "string_impl.h"
#include "flint/flint.h"
#include "flint/fmpz.h"
#include "cython_metaclass.h"

so I wonder if one of these is somehow responsible.

@embray
Copy link
Contributor Author

embray commented Apr 23, 2019

Changed keywords from cygwin sagelib gmp to cygwin sagelib gmp flint

@embray
Copy link
Contributor Author

embray commented Apr 23, 2019

comment:3

I traced the problem to this line in flint.h:

#define mp_bitcnt_t ulong

I have no idea why it would do this, but it's almost certainly wrong.

@embray
Copy link
Contributor Author

embray commented Apr 23, 2019

comment:4

Added 10 years ago for no readily apparent reason in flintlib/flint@f988d3e

Later it was changed to #define mp_bitcnt_t ulong in a mass rename. But flint's ulong type is defined in terms of mp_limb_t hence the breakage.

@embray
Copy link
Contributor Author

embray commented Apr 23, 2019

Upstream: Reported upstream. No feedback yet.

@embray

This comment has been minimized.

@embray

This comment has been minimized.

@embray
Copy link
Contributor Author

embray commented Apr 23, 2019

Changed upstream from Reported upstream. No feedback yet. to Fixed upstream, but not in a stable release.

@embray
Copy link
Contributor Author

embray commented Apr 23, 2019

comment:8

The previous PR to flint partially fixed the problem, but not fully. See updated description.

@embray

This comment has been minimized.

@embray
Copy link
Contributor Author

embray commented Apr 23, 2019

comment:9

Yeah, zn_poly has its own typedef unsigned long ulong totally unrelated to flint, except when both headers get included in the same module it's a mess. I'll clean up the zn_poly ulong stuff... :(

@embray
Copy link
Contributor Author

embray commented Apr 24, 2019

comment:10

Wow. PARI has one of these too. In pari/parigen.h:

#ifdef _WIN64
typedef unsigned long long pari_ulong;
#define long long long
#define labs llabs
#else
typedef unsigned long pari_ulong;
#endif
#define ulong pari_ulong
typedef long *GEN;

I think I encountered a problem caused by this #define long long long before. I hate it.

@embray
Copy link
Contributor Author

embray commented Apr 24, 2019

comment:11

I think ultimately the worse perpetrator of this is flint. Its ulong and slong defines result in the worse compatibility issues.

@embray
Copy link
Contributor Author

embray commented Jun 7, 2019

comment:12

This will be fixed by #27721 if it's accepted.

@embray
Copy link
Contributor Author

embray commented Jul 3, 2019

comment:13

Moving open critical and blocker issues to the next release milestone (optimistically).

@embray embray modified the milestones: sage-8.8, sage-8.9 Jul 3, 2019
@embray
Copy link
Contributor Author

embray commented Aug 7, 2019

comment:14

Should be fixed by #27721.

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

No branches or pull requests

1 participant