welchbj / tt

a Pythonic toolkit for working with Boolean expressions
https://tt.brianwel.ch
MIT License
217 stars 11 forks source link

Compilation error gcc 14.2.0 #11

Open gibarrasch opened 1 week ago

gibarrasch commented 1 week ago

Hi guys, it seems that the installation of the ttable==0.6.4 pip package fails due to a compilation error when trying to build the picosatmodule.c.

The error message is realated to the -Wint-conversion check, where it detected a pointer trying to be stored in a char signed:

      building 'tt._clibs.picosat' extension
      creating build/temp.linux-x86_64-cpython-312
      creating build/temp.linux-x86_64-cpython-312/tmp
      creating build/temp.linux-x86_64-cpython-312/tmp/pip-install-hrud7wm5
      creating build/temp.linux-x86_64-cpython-312/tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907
      creating build/temp.linux-x86_64-cpython-312/tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt
      creating build/temp.linux-x86_64-cpython-312/tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs
      creating build/temp.linux-x86_64-cpython-312/tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosat
      x86_64-pc-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -O2 -Wall -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -march=x86-64-v2 -mtune=broadwell -O2 -Wall -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -march=x86-64-v2 -mtune=broadwell -fPIC -DNDEBUG -I/tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosat -I/usr/include/python3.12 -c /tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosat/picosat.c -o build/temp.linux-x86_64-cpython-312/tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosat/picosat.o
      x86_64-pc-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -O2 -Wall -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -march=x86-64-v2 -mtune=broadwell -O2 -Wall -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -march=x86-64-v2 -mtune=broadwell -fPIC -DNDEBUG -I/tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosat -I/usr/include/python3.12 -c /tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosatmodule.c -o build/temp.linux-x86_64-cpython-312/tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosatmodule.o
      /tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosatmodule.c: In function '_tt_soliter_next':
      /tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosatmodule.c:403:50: error: passing argument 2 of '_tt_block_sol' makes pointer from integer without a cast [-Wint-conversion]
        403 |             if (_tt_block_sol(iter->picosat, iter->_temp_mem) < 0)
            |                                              ~~~~^~~~~~~~~~~
            |                                                  |
            |                                                  signed char
      /tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosatmodule.c:356:48: note: expected 'signed char *' but argument is of type 'signed char'
        356 | _tt_block_sol(PicoSAT * picosat, signed char * mem)
            |                                  ~~~~~~~~~~~~~~^~~
      /tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosatmodule.c: In function '_tt_soliter_dealloc':
      /tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosatmodule.c:426:24: error: passing argument 1 of 'PyMem_Free' makes pointer from integer without a cast [-Wint-conversion]
        426 |         PyMem_Free(iter->_temp_mem);
            |                    ~~~~^~~~~~~~~~~
            |                        |
            |                        signed char
      In file included from /usr/include/python3.12/Python.h:41,
                       from /tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosatmodule.c:12:
      /usr/include/python3.12/pymem.h:55:35: note: expected 'void *' but argument is of type 'signed char'
         55 | PyAPI_FUNC(void) PyMem_Free(void *ptr);
            |                             ~~~~~~^~~
      /tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosatmodule.c: In function 'sat_all':
      /tmp/pip-install-hrud7wm5/ttable_b714877d13474619b5cf569f63972907/tt/_clibs/picosatmodule.c:548:21: error: assignment to 'signed char' from 'void *' makes integer from pointer without a cast [-Wint-conversion]
        548 |     iter->_temp_mem = NULL;
            |                     ^
      error: command '/usr/bin/x86_64-pc-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for ttable
Failed to build ttable
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (ttable)

It seems to be a legitim warning that could generate a bug, which currently might be mittigated thanks to the implicit padding added at the end of the structure. I think we just need to change the _temp_mem type to signed char*: https://github.com/welchbj/tt/blob/develop/tt/_clibs/picosatmodule.c#L25.

I can do the Pull Request myself if needed