Opened 2 years ago
Closed 2 years ago
#27714 closed defect (worksforme)
Sagelib build error on Cygwin using system GMP
Reported by: | embray | Owned by: | |
---|---|---|---|
Priority: | critical | Milestone: | sage-duplicate/invalid/wontfix |
Component: | porting: Cygwin | Keywords: | cygwin sagelib gmp flint |
Cc: | jdemeyer | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | Fixed upstream, but not in a stable release. | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
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: https://github.com/wbhart/flint2/pull/557
Change History (14)
comment:1 Changed 2 years ago by
- Cc jdemeyer added
- Description modified (diff)
comment:2 Changed 2 years ago by
comment:3 Changed 2 years ago by
- Keywords flint added
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.
comment:4 Changed 2 years ago by
Added 10 years ago for no readily apparent reason in https://github.com/wbhart/flint2/commit/f988d3eaab92ad477fe73cb346060fc0b700c566
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.
comment:5 Changed 2 years ago by
- Description modified (diff)
- Report Upstream changed from N/A to Reported upstream. No feedback yet.
comment:6 Changed 2 years ago by
- Description modified (diff)
comment:7 Changed 2 years ago by
- Report Upstream changed from Reported upstream. No feedback yet. to Fixed upstream, but not in a stable release.
comment:8 Changed 2 years ago by
- Description modified (diff)
The previous PR to flint partially fixed the problem, but not fully. See updated description.
comment:9 Changed 2 years ago by
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... :(
comment:10 Changed 2 years ago by
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.
comment:11 Changed 2 years ago by
I think ultimately the worse perpetrator of this is flint. Its ulong
and slong
defines result in the worse compatibility issues.
comment:12 Changed 2 years ago by
This will be fixed by #27721 if it's accepted.
comment:13 Changed 2 years ago by
- Milestone changed from sage-8.8 to sage-8.9
Moving open critical and blocker issues to the next release milestone (optimistically).
comment:14 Changed 2 years ago by
- Milestone changed from sage-8.9 to sage-duplicate/invalid/wontfix
- Resolution set to worksforme
- Status changed from new to closed
Should be fixed by #27721.
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 literallymp_limb_t
to the C code and does not redefine it in any way.The "conflicting types" error first appears just after
so I wonder if one of these is somehow responsible.