Repository: fplll/fpylll (language: python)

Issue:
Cygwin compilation error
Hi everyone,

I do have problems compiling with:

cygwin 3.4.3
Python 3.9.10
Found GNU Autoconf version 2.71
Found GNU Automake version 1.16.5
Found GNU Libtool version 2.4.7

Using following commands:
git clone https://github.com/fplll/fpylll
cd fpylll
./bootstrap.sh -j 8

This will lead to **fplll** compilation errors with  “File too big/too many sections” errors.
Also Definition of M_PI and M_LN2 will be missing. 
These can be corrected by changing the bootstrap.sh compiler options like so:

CXXFLAGS="\$CXXFLAGS -O3 -march=native -Wp,-U_FORTIFY_SOURCE **-std=gnu++0x -Wa,-mbig-obj**"

After these changes fplll will compile without errors.

Now comes the part with fpylll.

$PIP install -r requirements.txt

works just fine but after that:

$PYTHON setup.py build $jobs || $PYTHON setup.py build_ext

will give following errors:

Compiling src/fpylll/gmp/pylong.pyx because it changed.
Compiling src/fpylll/fplll/integer_matrix.pyx because it changed.
Compiling src/fpylll/fplll/gso.pyx because it changed.
Compiling src/fpylll/fplll/lll.pyx because it changed.
Compiling src/fpylll/fplll/wrapper.pyx because it changed.
Compiling src/fpylll/fplll/bkz_param.pyx because it changed.
Compiling src/fpylll/fplll/bkz.pyx because it changed.
Compiling src/fpylll/fplll/enumeration.pyx because it changed.
Compiling src/fpylll/fplll/svpcvp.pyx because it changed.
Compiling src/fpylll/fplll/pruner.pyx because it changed.
Compiling src/fpylll/util.pyx because it changed.
Compiling src/fpylll/io.pyx because it changed.
Compiling src/fpylll/config.pyx because it changed.
[ 1/13] Cythonizing src/fpylll/config.pyx
[ 2/13] Cythonizing src/fpylll/fplll/bkz.pyx
[ 3/13] Cythonizing src/fpylll/fplll/bkz_param.pyx
[ 4/13] Cythonizing src/fpylll/fplll/enumeration.pyx
[ 5/13] Cythonizing src/fpylll/fplll/gso.pyx

Error compiling Cython file:
------------------------------------------------------------
...
            sig_off()
            return vector_fp_nr_slurp(cv, FT_DOUBLE)
        elif self._type == mat_gso_mpz_ld:
            vector_fp_nr_barf(cw, w, FT_LONG_DOUBLE)
            sig_on()
            (<MatGSO_c[Z_NR[mpz_t],FP_NR[ld_t]]*>self._core.mpz_ld).from_canonical(cv.ld, cw.ld, start, dimension)
                                            ^
------------------------------------------------------------

src/fpylll/fplll/gso.pyx:2079:45: unknown type in template argument


There are much more errors like this.
I am attaching the log.

It seems that despite a good compile of fplll it is not installed correctly into the virtualenv.

Hope someone can help me with this.

-e





[fpylll_error.txt](https://github.com/fplll/fpylll/files/10449111/fpylll_error.txt)




Cygwin compilation error
Hi everyone,

I do have problems compiling with:

cygwin 3.4.3
Python 3.9.10
Found GNU Autoconf version 2.71
Found GNU Automake version 1.16.5
Found GNU Libtool version 2.4.7

Using following commands:
git clone https://github.com/fplll/fpylll
cd fpylll
./bootstrap.sh -j 8

This will lead to **fplll** compilation errors with  “File too big/too many sections” errors.
Also Definition of M_PI and M_LN2 will be missing. 
These can be corrected by changing the bootstrap.sh compiler options like so:

CXXFLAGS="\$CXXFLAGS -O3 -march=native -Wp,-U_FORTIFY_SOURCE **-std=gnu++0x -Wa,-mbig-obj**"

After these changes fplll will compile without errors.

Now comes the part with fpylll.

$PIP install -r requirements.txt

works just fine but after that:

$PYTHON setup.py build $jobs || $PYTHON setup.py build_ext

will give following errors:

Compiling src/fpylll/gmp/pylong.pyx because it changed.
Compiling src/fpylll/fplll/integer_matrix.pyx because it changed.
Compiling src/fpylll/fplll/gso.pyx because it changed.
Compiling src/fpylll/fplll/lll.pyx because it changed.
Compiling src/fpylll/fplll/wrapper.pyx because it changed.
Compiling src/fpylll/fplll/bkz_param.pyx because it changed.
Compiling src/fpylll/fplll/bkz.pyx because it changed.
Compiling src/fpylll/fplll/enumeration.pyx because it changed.
Compiling src/fpylll/fplll/svpcvp.pyx because it changed.
Compiling src/fpylll/fplll/pruner.pyx because it changed.
Compiling src/fpylll/util.pyx because it changed.
Compiling src/fpylll/io.pyx because it changed.
Compiling src/fpylll/config.pyx because it changed.
[ 1/13] Cythonizing src/fpylll/config.pyx
[ 2/13] Cythonizing src/fpylll/fplll/bkz.pyx
[ 3/13] Cythonizing src/fpylll/fplll/bkz_param.pyx
[ 4/13] Cythonizing src/fpylll/fplll/enumeration.pyx
[ 5/13] Cythonizing src/fpylll/fplll/gso.pyx

Error compiling Cython file:
------------------------------------------------------------
...
            sig_off()
            return vector_fp_nr_slurp(cv, FT_DOUBLE)
        elif self._type == mat_gso_mpz_ld:
            vector_fp_nr_barf(cw, w, FT_LONG_DOUBLE)
            sig_on()
            (<MatGSO_c[Z_NR[mpz_t],FP_NR[ld_t]]*>self._core.mpz_ld).from_canonical(cv.ld, cw.ld, start, dimension)
                                            ^
------------------------------------------------------------

src/fpylll/fplll/gso.pyx:2079:45: unknown type in template argument


There are much more errors like this.
I am attaching the log.

It seems that despite a good compile of fplll it is not installed correctly into the virtualenv.

Hope someone can help me with this.

-e





[fpylll_error.txt](https://github.com/fplll/fpylll/files/10449111/fpylll_error.txt)






Discussion / hints:

Fix patch:
diff --git a/src/fpylll/fplll/gso.pyx b/src/fpylll/fplll/gso.pyx
index ca606e55..3879f29b 100644
--- a/src/fpylll/fplll/gso.pyx
+++ b/src/fpylll/fplll/gso.pyx
@@ -2074,11 +2074,14 @@ cdef class MatGSO:
             sig_off()
             return vector_fp_nr_slurp(cv, FT_DOUBLE)
         elif self._type == mat_gso_mpz_ld:
-            vector_fp_nr_barf(cw, w, FT_LONG_DOUBLE)
-            sig_on()
-            (<MatGSO_c[Z_NR[mpz_t],FP_NR[ld_t]]*>self._core.mpz_ld).from_canonical(cv.ld, cw.ld, start, dimension)
-            sig_off()
-            return vector_fp_nr_slurp(cv, FT_LONG_DOUBLE)
+            IF HAVE_LONG_DOUBLE:
+                vector_fp_nr_barf(cw, w, FT_LONG_DOUBLE)
+                sig_on()
+                (<MatGSO_c[Z_NR[mpz_t],FP_NR[ld_t]]*>self._core.mpz_ld).from_canonical(cv.ld, cw.ld, start, dimension)
+                sig_off()
+                return vector_fp_nr_slurp(cv, FT_LONG_DOUBLE)
+            ELSE:
+                raise RuntimeError("Float type long double not supported.")
         # elif self._type == mat_gso_mpz_dpe:
         #     vector_fp_nr_barf(cw, w, FT_DPE)
         #     sig_on()
@@ -2098,11 +2101,14 @@ cdef class MatGSO:
             sig_off()
             return vector_fp_nr_slurp(cv, FT_DOUBLE)
         elif self._type == mat_gso_long_ld:
-            vector_fp_nr_barf(cw, w, FT_LONG_DOUBLE)
-            sig_on()
-            (<MatGSO_c[Z_NR[long],FP_NR[ld_t]]*>self._core.long_ld).from_canonical(cv.ld, cw.ld, start, dimension)
-            sig_off()
-            return vector_fp_nr_slurp(cv, FT_LONG_DOUBLE)
+            IF HAVE_LONG_DOUBLE:
+                vector_fp_nr_barf(cw, w, FT_LONG_DOUBLE)
+                sig_on()
+                (<MatGSO_c[Z_NR[long],FP_NR[ld_t]]*>self._core.long_ld).from_canonical(cv.ld, cw.ld, start, dimension)
+                sig_off()
+                return vector_fp_nr_slurp(cv, FT_LONG_DOUBLE)
+            ELSE:
+                raise RuntimeError("Float type long double not supported.")
         # elif self._type == mat_gso_long_dpe:
         #     vector_fp_nr_barf(cw, w, FT_DPE)
         #     sig_on()
@@ -2125,7 +2131,7 @@ cdef class MatGSO:
             elif self._type == mat_gso_mpz_qd:
                 vector_fp_nr_barf(cw, w, FT_QD)
                 sig_on()
-                (<MatGSO_c[Z_NR[mpz_t],FP_NR[qd_t]]*>self._core.mpz_ld).from_canonical(cv.qd, cw.qd, start, dimension)
+                (<MatGSO_c[Z_NR[mpz_t],FP_NR[qd_t]]*>self._core.mpz_qd).from_canonical(cv.qd, cw.qd, start, dimension)
                 sig_off()
                 return vector_fp_nr_slurp(cv, FT_QD)
             elif self._type == mat_gso_long_dd:
@@ -2192,11 +2198,14 @@ cdef class MatGSO:
             sig_off()
             return vector_fp_nr_slurp(cw, FT_DOUBLE)
         elif self._type == mat_gso_mpz_ld:
-            vector_fp_nr_barf(cv, v, FT_LONG_DOUBLE)
-            sig_on()
-            (<MatGSO_c[Z_NR[mpz_t],FP_NR[ld_t]]*>self._core.mpz_ld).to_canonical(cw.ld, cv.ld, start)
-            sig_off()
-            return vector_fp_nr_slurp(cw, FT_LONG_DOUBLE)
+            IF HAVE_LONG_DOUBLE:
+                vector_fp_nr_barf(cv, v, FT_LONG_DOUBLE)
+                sig_on()
+                (<MatGSO_c[Z_NR[mpz_t],FP_NR[ld_t]]*>self._core.mpz_ld).to_canonical(cw.ld, cv.ld, start)
+                sig_off()
+                return vector_fp_nr_slurp(cw, FT_LONG_DOUBLE)
+            ELSE:
+                raise RuntimeError("Float type long double not supported.")
         # # https://github.com/fplll/fplll/issues/493
         # elif self._type == mat_gso_mpz_dpe:
         #     vector_fp_nr_barf(cv, v, FT_DPE)
@@ -2217,11 +2226,14 @@ cdef class MatGSO:
             sig_off()
             return vector_fp_nr_slurp(cw, FT_DOUBLE)
         elif self._type == mat_gso_long_ld:
-            vector_fp_nr_barf(cv, v, FT_LONG_DOUBLE)
-            sig_on()
-            (<MatGSO_c[Z_NR[long],FP_NR[ld_t]]*>self._core.long_ld).to_canonical(cw.ld, cv.ld, start)
-            sig_off()
-            return vector_fp_nr_slurp(cw, FT_LONG_DOUBLE)
+            IF HAVE_LONG_DOUBLE:
+                vector_fp_nr_barf(cv, v, FT_LONG_DOUBLE)
+                sig_on()
+                (<MatGSO_c[Z_NR[long],FP_NR[ld_t]]*>self._core.long_ld).to_canonical(cw.ld, cv.ld, start)
+                sig_off()
+                return vector_fp_nr_slurp(cw, FT_LONG_DOUBLE)
+            ELSE:
+                raise RuntimeError("Float type long double not supported.")
         # # https://github.com/fplll/fplll/issues/493
         # elif self._type == mat_gso_long_dpe:
         #     vector_fp_nr_barf(cv, v, FT_DPE)
@@ -2368,11 +2380,14 @@ cdef class MatGSO:
                 sig_off()
                 return vector_z_nr_slurp(cw, ZT_MPZ)
             elif self._type == mat_gso_mpz_ld:
-                vector_fp_nr_barf(cv, v, FT_LONG_DOUBLE)
-                sig_on()
-                (<MatGSO_c[Z_NR[mpz_t],FP_NR[ld_t]]*>self._core.mpz_ld).babai(cw.mpz, cv.ld, start, dimension, gso)
-                sig_off()
-                return vector_z_nr_slurp(cw, ZT_MPZ)
+                IF HAVE_LONG_DOUBLE:
+                    vector_fp_nr_barf(cv, v, FT_LONG_DOUBLE)
+                    sig_on()
+                    (<MatGSO_c[Z_NR[mpz_t],FP_NR[ld_t]]*>self._core.mpz_ld).babai(cw.mpz, cv.ld, start, dimension, gso)
+                    sig_off()
+                    return vector_z_nr_slurp(cw, ZT_MPZ)
+                ELSE:
+                    raise RuntimeError("Float type long double not supported.")
             # # https://github.com/fplll/fplll/issues/493
             # elif self._type == mat_gso_mpz_dpe:
             #     vector_fp_nr_barf(cv, v, FT_DPE)
@@ -2393,11 +2408,14 @@ cdef class MatGSO:
                 sig_off()
                 return vector_z_nr_slurp(cw, ZT_LONG)
             elif self._type == mat_gso_long_ld:
-                vector_fp_nr_barf(cv, v, FT_LONG_DOUBLE)
-                sig_on()
-                (<MatGSO_c[Z_NR[long],FP_NR[ld_t]]*>self._core.long_ld).babai(cw.long, cv.ld, start, dimension, gso)
-                sig_off()
-                return vector_z_nr_slurp(cw, ZT_LONG)
+                IF HAVE_LONG_DOUBLE:
+                    vector_fp_nr_barf(cv, v, FT_LONG_DOUBLE)
+                    sig_on()
+                    (<MatGSO_c[Z_NR[long],FP_NR[ld_t]]*>self._core.long_ld).babai(cw.long, cv.ld, start, dimension, gso)
+                    sig_off()
+                    return vector_z_nr_slurp(cw, ZT_LONG)
+                ELSE:
+                    raise RuntimeError("Float type long double not supported.")
             # # https://github.com/fplll/fplll/issues/493
             # elif self._type == mat_gso_long_dpe:
             #     vector_fp_nr_barf(cv, v, FT_DPE)
@@ -2448,11 +2466,14 @@ cdef class MatGSO:
                 sig_off()
                 return vector_z_nr_slurp(cw, ZT_MPZ)
             elif self._type == mat_gso_mpz_ld:
-                vector_fp_nr_barf(cv, v, FT_LONG_DOUBLE)
-                sig_on()
-                self._core.mpz_ld.babai(cw.mpz, cv.ld, start, dimension)
-                sig_off()
-                return vector_z_nr_slurp(cw, ZT_MPZ)
+                IF HAVE_LONG_DOUBLE:
+                    vector_fp_nr_barf(cv, v, FT_LONG_DOUBLE)
+                    sig_on()
+                    self._core.mpz_ld.babai(cw.mpz, cv.ld, start, dimension)
+                    sig_off()
+                    return vector_z_nr_slurp(cw, ZT_MPZ)
+                ELSE:
+                    raise RuntimeError("Float type long double not supported.")
             elif self._type == mat_gso_mpz_dpe:
                 vector_fp_nr_barf(cv, v, FT_DPE)
                 sig_on()
@@ -2472,11 +2493,14 @@ cdef class MatGSO:
                 sig_off()
                 return vector_z_nr_slurp(cw, ZT_LONG)
             elif self._type == mat_gso_long_ld:
-                vector_fp_nr_barf(cv, v, FT_LONG_DOUBLE)
-                sig_on()
-                self._core.long_ld.babai(cw.long, cv.ld, start, dimension)
-                sig_off()
-                return vector_z_nr_slurp(cw, ZT_LONG)
+                IF HAVE_LONG_DOUBLE:
+                    vector_fp_nr_barf(cv, v, FT_LONG_DOUBLE)
+                    sig_on()
+                    self._core.long_ld.babai(cw.long, cv.ld, start, dimension)
+                    sig_off()
+                    return vector_z_nr_slurp(cw, ZT_LONG)
+                ELSE:
+                    raise RuntimeError("Float type long double not supported.")
             elif self._type == mat_gso_long_dpe:
                 vector_fp_nr_barf(cv, v, FT_DPE)
                 sig_on()
diff --git a/src/fpylll/io.pyx b/src/fpylll/io.pyx
index 746ce6e2..0d4f9d8c 100644
--- a/src/fpylll/io.pyx
+++ b/src/fpylll/io.pyx
@@ -68,10 +68,13 @@ cdef void vector_fp_nr_barf(vector_fp_nr_t &out, object inp, FloatType float_typ
             tmp.d = <char*>py_bytes
             out.d.push_back(tmp.d)
     elif float_type == FT_LONG_DOUBLE:
-        for entry in inp:
-            py_bytes = str(entry).encode()
-            tmp.ld = <char*>py_bytes
-            out.ld.push_back(tmp.ld)
+        IF HAVE_LONG_DOUBLE:
+            for entry in inp:
+                py_bytes = str(entry).encode()
+                tmp.ld = <char*>py_bytes
+                out.ld.push_back(tmp.ld)
+        ELSE:
+            raise ValueError("Float type '%s' not understood."%float_type)
     elif float_type == FT_DPE:
         for entry in inp:
             py_bytes = str(entry).encode()
@@ -105,8 +108,11 @@ cdef object vector_fp_nr_slurp(vector_fp_nr_t &inp, FloatType float_type):
         for i in range(inp.d.size()):
             out.append(inp.d[i].get_d())
     elif float_type == FT_LONG_DOUBLE:
-        for i in range(inp.ld.size()):
-            out.append(inp.ld[i].get_d())
+        IF HAVE_LONG_DOUBLE:
+            for i in range(inp.ld.size()):
+                out.append(inp.ld[i].get_d())
+        ELSE:
+            raise ValueError("Float type '%s' not understood."%float_type)
     elif float_type == FT_DPE:
         for i in range(inp.dpe.size()):
             out.append(inp.dpe[i].get_d())


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index cb676a6a..4124e51f 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -18,10 +18,12 @@ jobs:
       matrix:
         python-version: ["3.8", "3.9", "3.10"]
         have_qd: [yes, no]
+        have_ld: [yes, no]
         have_numpy: [yes, no]
 
     env:
         HAVE_QD: ${{ matrix.have_qd }}
+        HAVE_LONG_DOUBLE: ${{ matrix.have_ld }}
         HAVE_NUMPY: ${{ matrix.have_numpy }}
         
     steps: