fplll / fpylll

A Python interface for https://github.com/fplll/fplll
GNU General Public License v2.0
118 stars 60 forks source link

Cygwin compilation error #240

Closed eychei closed 1 year ago

eychei commented 1 year ago

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

malb commented 1 year ago

Could you test the PR to see if that fixes your issue?

eychei commented 1 year ago

Wow that response was fast.

Tried but still not working.

FPLLL is build and installed correctly. Also tried without virtualenv.

I get these errors now:

$ python setup.py build_ext running build_ext 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/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. [1/9] Cythonizing src/fpylll/fplll/gso.pyx

Error compiling Cython file:

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

src/fpylll/fplll/gso.pyx:2471:26: Object of type 'mat_gso_core_t' has no attribute 'mpz_ld'

Error compiling Cython file:

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

src/fpylll/fplll/gso.pyx:2471:50: Object of type 'vector_fp_nr_t' has no attribute 'ld'

Error compiling Cython file:

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

src/fpylll/fplll/gso.pyx:2471:42: Cannot convert 'vector[Z_NR[mpz_t]]' to Python object

Error compiling Cython file:

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

src/fpylll/fplll/gso.pyx:2495:26: Object of type 'mat_gso_core_t' has no attribute 'long_ld'

Error compiling Cython file:

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

src/fpylll/fplll/gso.pyx:2495:52: Object of type 'vector_fp_nr_t' has no attribute 'ld'

Error compiling Cython file:

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

src/fpylll/fplll/gso.pyx:2495:43: Cannot convert 'vector[Z_NR[long]]' to Python object Traceback (most recent call last): File "/home/Think/Downloads/fpylll/setup.py", line 239, in setup( File "/usr/lib/python3.9/distutils/core.py", line 148, in setup dist.run_commands() File "/usr/lib/python3.9/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/usr/lib/python3.9/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/home/Think/Downloads/fpylll/setup.py", line 122, in run self.extensions = Cython.Build.cythonize( File "/usr/local/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1112, in cythonize cythonize_one(*args) File "/usr/local/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1235, in cythonize_one raise CompileError(None, pyx_file) Cython.Compiler.Errors.CompileError: src/fpylll/fplll/gso.pyx

malb commented 1 year ago

I had missed some guards, can you pull and try again?

eychei commented 1 year ago

I think you are close to solving this:)

I have the following errors now:

$ python setup.py build_ext running build_ext 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 [ 6/13] Cythonizing src/fpylll/fplll/integer_matrix.pyx [ 7/13] Cythonizing src/fpylll/fplll/lll.pyx [ 8/13] Cythonizing src/fpylll/fplll/pruner.pyx [ 9/13] Cythonizing src/fpylll/fplll/svpcvp.pyx [10/13] Cythonizing src/fpylll/fplll/wrapper.pyx [11/13] Cythonizing src/fpylll/gmp/pylong.pyx [12/13] Cythonizing src/fpylll/io.pyx

Error compiling Cython file:

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

src/fpylll/io.pyx:73:15: Object of type 'fp_nr_t' has no attribute 'ld'

Error compiling Cython file:

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

src/fpylll/io.pyx:74:15: Object of type 'vector_fp_nr_t &' has no attribute 'ld'

Error compiling Cython file:

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

src/fpylll/io.pyx:74:32: Object of type 'fp_nr_t' has no attribute 'ld'

Error compiling Cython file:

... out = [] if float_type == FT_DOUBLE: 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()): ^

src/fpylll/io.pyx:108:26: Object of type 'vector_fp_nr_t &' has no attribute 'ld'

Error compiling Cython file:

... out = [] if float_type == FT_DOUBLE: 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()): ^

src/fpylll/io.pyx:108:26: Object of type 'vector_fp_nr_t &' has no attribute 'ld'

Error compiling Cython file:

... out = [] if float_type == FT_DOUBLE: 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()): ^

src/fpylll/io.pyx:108:26: Object of type 'vector_fp_nr_t &' has no attribute 'ld'

Error compiling Cython file:

... if float_type == FT_DOUBLE: 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()) ^

src/fpylll/io.pyx:109:26: Object of type 'vector_fp_nr_t &' has no attribute 'ld' Traceback (most recent call last): File "/home/Think/Downloads/fpylll/setup.py", line 239, in setup( File "/usr/lib/python3.9/distutils/core.py", line 148, in setup dist.run_commands() File "/usr/lib/python3.9/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/usr/lib/python3.9/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/home/Think/Downloads/fpylll/setup.py", line 122, in run self.extensions = Cython.Build.cythonize( File "/usr/local/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1112, in cythonize cythonize_one(*args) File "/usr/local/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1235, in cythonize_one raise CompileError(None, pyx_file) Cython.Compiler.Errors.CompileError: src/fpylll/io.pyx

malb commented 1 year ago

Can you try again, it should work now

eychei commented 1 year ago

Hi,

thank you! It is working now. I still have to change the bootstrap.sh and edit the CXXFLAGS as follows:

CXXFLAGS="\$CXXFLAGS -O3 -march=native -Wp,-U_FORTIFY_SOURCE -std=gnu++0x -Wa,-mbig-obj"

Else it will complain as described in my first post. Is there a solution for this?

-e

malb commented 1 year ago

Sorry, out of my depth on that one!

eychei commented 1 year ago

Thank you so much for the help!

Wish you the best.

-e

joerowell commented 1 year ago

CXXFLAGS="$CXXFLAGS -O3 -march=native -Wp,-U_FORTIFY_SOURCE -std=gnu++0x -Wa,-mbig-obj" Sorry, out of my depth on that one!

I don't have the time to fix this bug right now, but for posterity the reason for this is (AFAIK) two-fold:

  1. fplll probably uses some GCC specific extension internally somewhere, and so we need to specify compatibility with gcc. Off the top of my head I'm not sure where that extension is: we can probably find it by compiling with -pedantic during build time.
  2. -Wa, -mbig-obj is probably needed because of the number of template instantiations fplll does. AFAIK, Windows assembly listings are limited to $\~2^{16}$ sections, and one needs to coerce Cygwin into producing more sections. This is what "-Wa,-mbig-obj" does. I'd guess this is probably due to do the parallel enumeration templates, but it could also be down to the sheer number of templated functions in fplll. I found this useful for understanding this problem in a past life. This can probably be fixed with autotools trickery: alternatively, we could force -Wa, -mbig-obj on everyone, but I'm not sure what impact that might have.