Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installing the freesasa python module with gcc 12 and gcc 13 #37

Closed
vcojocaru opened this issue Nov 15, 2023 · 10 comments
Closed

installing the freesasa python module with gcc 12 and gcc 13 #37

vcojocaru opened this issue Nov 15, 2023 · 10 comments

Comments

@vcojocaru
Copy link

Dear all,

I am trying to install the freesasa python module on an updated openSUSE Tumbleweed distribution (gcc 13 and gcc 12). I did the following steps: (i) created a virtual environment with virtualenv with either python 3.9, 3.10, and 3.11; (ii) use pip install freesasa whitin that environment. In all cases (both gcc versions, all 3 python versions) I get the error below when building.

I'd appreciate any insight on how to fix this.

Thanks
Vlad

---- error message ---

Collecting freesasa
Using cached freesasa-2.2.0.post3.tar.gz (223 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: freesasa
Building wheel for freesasa (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [72 lines of output]
Define environment variable USE_CYTHON to build from Cython source
/apps/haddock/3.0/2023-11-15/.venv-python3.9/lib/python3.9/site-packages/setuptools/init.py:80: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

          ********************************************************************************
          Requirements should be satisfied by a PEP 517 installer.
          If you are using pip, you can try `pip install --use-pep517`.
          ********************************************************************************
  
  !!
    dist.fetch_build_eggs(dist.setup_requires)
  running bdist_wheel
  running build
  running build_ext
  building 'freesasa' extension
  creating build
  creating build/temp.linux-x86_64-cpython-39
  creating build/temp.linux-x86_64-cpython-39/lib
  creating build/temp.linux-x86_64-cpython-39/lib/src
  creating build/temp.linux-x86_64-cpython-39/src
  gcc -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -fPIC -Ilib/src -I. -I/apps/haddock/3.0/2023-11-15/.venv-python3.9/include -I/usr/include/python3.9 -c lib/src/classifier.c -o build/temp.linux-x86_64-cpython-39/lib/src/classifier.o -DHAVE_CONFIG_H -std=gnu99
  lib/src/classifier.c: In function ‘freesasa_atom_is_backbone’:
  lib/src/classifier.c:990:19: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
    990 |     for (i = 0; i < sizeof(bb)/sizeof(const char*); ++i) {
        |                   ^
  lib/src/classifier.c: In function ‘freesasa_classifier_add_type’:
  lib/src/classifier.c:411:21: warning: pointer ‘tn’ may be used after ‘realloc’ [-Wuse-after-free]
    411 |         types->name = tn;
        |         ~~~~~~~~~~~~^~~~
  lib/src/classifier.c:410:24: note: call to ‘realloc’ here
    410 |     if ((types->name = realloc(tn, sizeof(char*)*n)) == NULL) {
        |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  lib/src/classifier.c:416:28: warning: pointer ‘tr’ may be used after ‘realloc’ [-Wuse-after-free]
    416 |         types->type_radius = tr;
        |         ~~~~~~~~~~~~~~~~~~~^~~~
  lib/src/classifier.c:415:31: note: call to ‘realloc’ here
    415 |     if ((types->type_radius = realloc(tr, sizeof(double)*n)) == NULL) {
        |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  lib/src/classifier.c:421:27: warning: pointer ‘tc’ may be used after ‘realloc’ [-Wuse-after-free]
    421 |         types->type_class = tc;
        |         ~~~~~~~~~~~~~~~~~~^~~~
  lib/src/classifier.c:420:30: note: call to ‘realloc’ here
    420 |     if ((types->type_class = realloc(tc, sizeof(int) * n)) == NULL) {
        |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  lib/src/classifier.c: In function ‘freesasa_classifier_add_residue’:
  lib/src/classifier.c:561:25: warning: pointer ‘rn’ may be used after ‘realloc’ [-Wuse-after-free]
    561 |         c->residue_name = rn;
        |         ~~~~~~~~~~~~~~~~^~~~
  lib/src/classifier.c:560:28: note: call to ‘realloc’ here
    560 |     if ((c->residue_name = realloc(rn, sizeof(char*) * res)) == NULL) {
        |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  lib/src/classifier.c:566:20: warning: pointer ‘cr’ may be used after ‘realloc’ [-Wuse-after-free]
    566 |         c->residue = cr;
        |         ~~~~~~~~~~~^~~~
  lib/src/classifier.c:565:23: note: call to ‘realloc’ here
    565 |     if ((c->residue = realloc(cr, sizeof(struct classifier_residue *) * res)) == NULL) {
        |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  lib/src/classifier.c: In function ‘next_line’:
  lib/src/classifier.c:187:5: warning: ‘__builtin_strncpy’ output may be truncated copying 256 bytes from a string of length 256 [-Wstringop-truncation]
    187 |     strncpy(line, first, MAX_LINE_LEN);
        |     ^
  gcc -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -fPIC -Ilib/src -I. -I/apps/haddock/3.0/2023-11-15/.venv-python3.9/include -I/usr/include/python3.9 -c lib/src/classifier_naccess.c -o build/temp.linux-x86_64-cpython-39/lib/src/classifier_naccess.o -DHAVE_CONFIG_H -std=gnu99
  gcc -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -fPIC -Ilib/src -I. -I/apps/haddock/3.0/2023-11-15/.venv-python3.9/include -I/usr/include/python3.9 -c lib/src/classifier_oons.c -o build/temp.linux-x86_64-cpython-39/lib/src/classifier_oons.o -DHAVE_CONFIG_H -std=gnu99
  gcc -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -fPIC -Ilib/src -I. -I/apps/haddock/3.0/2023-11-15/.venv-python3.9/include -I/usr/include/python3.9 -c lib/src/classifier_protor.c -o build/temp.linux-x86_64-cpython-39/lib/src/classifier_protor.o -DHAVE_CONFIG_H -std=gnu99
  gcc -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -fPIC -Ilib/src -I. -I/apps/haddock/3.0/2023-11-15/.venv-python3.9/include -I/usr/include/python3.9 -c lib/src/coord.c -o build/temp.linux-x86_64-cpython-39/lib/src/coord.o -DHAVE_CONFIG_H -std=gnu99
  gcc -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -fPIC -Ilib/src -I. -I/apps/haddock/3.0/2023-11-15/.venv-python3.9/include -I/usr/include/python3.9 -c lib/src/freesasa.c -o build/temp.linux-x86_64-cpython-39/lib/src/freesasa.o -DHAVE_CONFIG_H -std=gnu99
 lib/src/freesasa.c: In function ‘freesasa_alg_name’:
  lib/src/freesasa.c:266:1: error: control reaches end of non-void function [-Werror=return-type]
    266 | }
        | ^
  cc1: some warnings being treated as errors
  error: command '/usr/bin/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 freesasa
Running setup.py clean for freesasa
Failed to build freesasa
ERROR: Could not build wheels for freesasa, which is required to install pyproject.toml-based projects

@vcojocaru
Copy link
Author

vcojocaru commented Nov 15, 2023

I should add that the regular (non-python) freesasa (both 2.1.2 and freshly downloaded repo) can be built on the system without any error. The freesasa.c file shows some difference between the 2 cloned repositories (freesasa and freesasa-python). When playing a little more I noticed that adding a "return 0;" statement after the assert macro in the last function of freesasa.c (line 266) resolves the build. I am not sure though if this is acceptable for the code. It is still a mystery why this issues only comes with the python module of freesasa and not with the regular freesasa

@mittinatten
Copy link
Member

Hmm, thanks for pointing out. Seems compilers are getting stricter. I had a look at the code, and in this particular case it's not an actual error. But I think it's an easy fix to make the compiler happy, so I'll see if I can get un update published.

@vcojocaru
Copy link
Author

Great, thanks. If you can tell why the regular freesasa code builds without issues with the same compiler version and without this return statement, I'd be curious about it.

mittinatten added a commit that referenced this issue Nov 15, 2023
@mittinatten
Copy link
Member

I'm not sure, but I assume Cython sets -Werror=return-type and that's not a standard flag. I have pushed what I hope is a fix to the master branch here. Can you verify that it works for you from there, before I publish it as 2.2.1?

@vcojocaru
Copy link
Author

gcc -v on my system shows the -Werror=return-type flag but maybe its not actually used when building directly the C code.

Now the repo seems to build correctly (last lines of build below). I will have to test it in the context of Haddock3.

Thanks a lot.

--- last lines of build output ---

gcc -Wsign-compare -DNDEBUG -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -fPIC -Ilib/src -I. -I/usr/include/python3.11 -c lib/src/util.c -o build/temp.linux-x86_64-cpython-311/lib/src/util.o -DHAVE_CONFIG_H -std=gnu99
gcc -Wsign-compare -DNDEBUG -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -fPIC -Ilib/src -I. -I/usr/include/python3.11 -c src/freesasa.c -o build/temp.linux-x86_64-cpython-311/src/freesasa.o -DHAVE_CONFIG_H -std=gnu99
creating build/lib.linux-x86_64-cpython-311
gcc -shared build/temp.linux-x86_64-cpython-311/lib/src/classifier.o build/temp.linux-x86_64-cpython-311/lib/src/classifier_naccess.o build/temp.linux-x86_64-cpython-311/lib/src/classifier_oons.o build/temp.linux-x86_64-cpython-311/lib/src/classifier_protor.o build/temp.linux-x86_64-cpython-311/lib/src/coord.o build/temp.linux-x86_64-cpython-311/lib/src/freesasa.o build/temp.linux-x86_64-cpython-311/lib/src/lexer.o build/temp.linux-x86_64-cpython-311/lib/src/log.o build/temp.linux-x86_64-cpython-311/lib/src/nb.o build/temp.linux-x86_64-cpython-311/lib/src/node.o build/temp.linux-x86_64-cpython-311/lib/src/parser.o build/temp.linux-x86_64-cpython-311/lib/src/pdb.o build/temp.linux-x86_64-cpython-311/lib/src/rsa.o build/temp.linux-x86_64-cpython-311/lib/src/sasa_lr.o build/temp.linux-x86_64-cpython-311/lib/src/sasa_sr.o build/temp.linux-x86_64-cpython-311/lib/src/selection.o build/temp.linux-x86_64-cpython-311/lib/src/structure.o build/temp.linux-x86_64-cpython-311/lib/src/util.o build/temp.linux-x86_64-cpython-311/src/freesasa.o -L/usr/lib64 -o build/lib.linux-x86_64-cpython-311/freesasa.cpython-311-x86_64-linux-gnu.so

@mittinatten
Copy link
Member

mittinatten commented Nov 15, 2023

I experimented with compiler flags too, and couldn't trigger the error either. Strange 🤔

Anyway, great to hear that it works now, I will publish a patch later today.

@mittinatten
Copy link
Member

Ok, I published version 2.2.1 with this fix. If you can verify that that also works for you I think we can close the issue. Thanks again for reporting!

@vcojocaru
Copy link
Author

vcojocaru commented Nov 15, 2023

Great, thanks. Building the git repo works fine but if I download the archives (either .zip or .tar.gz the content of the lib directory is missing. On the other hand I managed to build another software (Haddock3) which requires freesasa using a requirements.txt file in which the freesasa version is set to 2.2.1 . This actually solved the problem I started with in the first place

@mittinatten
Copy link
Member

Hmm, it could be possible that Github has changed what it packages in the release archives, but you should be able to get the C library by pulling the git submodules. Anyway, I was thinking of the PyPi-package primarily (that's where I assume you got it originally, judging from the logs in the original post).

@vcojocaru
Copy link
Author

Yes, that works well. Thanks a lot for all the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants