algebraic-solving / msolve

Library for Polynomial System Solving through Algebraic Methods
https://msolve.lip6.fr
GNU General Public License v2.0
92 stars 22 forks source link

Fix 32-bit build #164

Closed d-torrance closed 3 months ago

d-torrance commented 3 months ago

This fixes a few compiler warnings and errors when building on 32-bit systems:

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../.. -Wdate-time -D_FORTIFY_SOURCE=2 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4a -msha -maes -mavx -mfma -mavx2 -mrdrnd -mbmi -mbmi2 -madx -mabm -fopenmp -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/builds/math-team/msolve/debian/output/source_dir=. -fstack-protector-strong -Wformat -Werror=format-security -c libmsolve.c  -fPIC -DPIC -o .libs/libmsolve_la-libmsolve.o
In file included from msolve.c:24,
                 from libmsolve.c:35:
lifting.c: In function 'copy_modular_matrix':
lifting.c:207:83: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
  207 |             fprintf(stderr, "Problem when allocating modular matrices (amount = %ld)\n", trace_det->mat_alloc * sz);
      |                                                                                 ~~^      ~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                                   |                           |
      |                                                                                   long int                    size_t {aka unsigned int}
      |                                                                                 %d
In file included from msolve.c:25:
lifting-gb.c: In function 'crt_lift_modgbs':
lifting-gb.c:861:30: error: passing argument 2 of 'fmpz_comb_init' from incompatible pointer type [-Wincompatible-pointer-types]
  861 |   fmpz_comb_init(comb, modgbs->primes, modgbs->nprimes);
      |                        ~~~~~~^~~~~~~~
      |                              |
      |                              uint64_t * {aka long long unsigned int *}
In file included from msolve-data.h:26,
                 from libmsolve.c:25:
/usr/include/flint/fmpz.h:720:46: note: expected 'mp_srcptr' {aka 'const long unsigned int *'} but argument is of type 'uint64_t *' {aka 'long long unsigned int *'}
  720 | void fmpz_comb_init(fmpz_comb_t C, mp_srcptr primes, slong num_primes);
      |                                    ~~~~~~~~~~^~~~~~
lifting-gb.c:874:36: error: passing argument 2 of 'fmpz_multi_CRT_ui' from incompatible pointer type [-Wincompatible-pointer-types]
  874 |         fmpz_multi_CRT_ui(y, modgbs->cf_64,
      |                              ~~~~~~^~~~~~~
      |                                    |
      |                                    uint64_t * {aka long long unsigned int *}
/usr/include/flint/fmpz.h:724:49: note: expected 'mp_srcptr' {aka 'const long unsigned int *'} but argument is of type 'uint64_t *' {aka 'long long unsigned int *'}
  724 | void fmpz_multi_CRT_ui(fmpz_t output, mp_srcptr residues, const fmpz_comb_t comb, fmpz_comb_temp_t temp, int sign);
      |                                       ~~~~~~~~~~^~~~~~~~
make[3]: *** [Makefile:488: libmsolve_la-libmsolve.lo] Error 1

Full log: https://salsa.debian.org/math-team/msolve/-/jobs/6021204/raw

The two main changes are using zu as the format in fprintf and switching to pointers to mp_limb_t (which will be 32 bits on 32-bit systems and 64 bits on 64-bit systems) for the arrays of primes used when calling the flint CRT functions.

ederc commented 3 months ago

Thanks!