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

Fix AlphaMap definition in cdatrie.pxd #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

musicinmybrain
Copy link

Fixes failure to compile on GCC with -Werror=incompatible-pointer-types.

Fixes failure to compile on GCC with `-Werror=incompatible-pointer-types`.
@glaubitz
Copy link

This fixes the build with GCC 14 for me.

@johanneskoester
Copy link

johanneskoester commented Aug 8, 2024

Maintainers, could you please review and merge? Or let us know how to proceed? Do you want to transfer the ownership of datrie?

@Stack7
Copy link

Stack7 commented Sep 18, 2024

Good evening!
This fix is very helpful, thanks a lot! However I still have a issue.
I have already patched the file as it has shown above and then, I tried to compile with -Werror incompatible-pointer-types .I guessed I need to edit the file update_c.sh and add that flag in the cython line. I tried so, but the compiler gave me back this:
cython: error: argument -Werror/--warning-errors: ignored explicit argument 'incompatible-pointer-types'
Can you help me to find out what is wrong?
Thank you very much!

@musicinmybrain
Copy link
Author

[…] Can you help me to find out what is wrong? Thank you very much!

It looks like you are passing -Werror incompatible-pointer-types to cython, not to your C++ compiler. (Also, I’m not sure if -Werror incompatible-pointer-types would be parsed as equivalent to -Werror=incompatible-pointer-types in this case or not.) But why do you need to pass that option, anyway? This patch is intended primarily to deal with GCC versions or distribution environments where incompatible pointer types are errors by default.

@Stack7
Copy link

Stack7 commented Sep 19, 2024

ok thanks! I followed your advice and I compiled
gcc ./src/datrie.c -W -O3 -Werror=incompatible-pointer-types -I $HOME/miniconda3/envs/scenicplus/include/python3.11/
however, I have got this error, which is attached.
The -I flag helps me to find the Python.h
error.txt

@musicinmybrain
Copy link
Author

./src/datrie.c: In function ‘__pyx_pf_6datrie_8BaseTrie___init__’:
./src/datrie.c:5669:53: error: passing argument 1 of ‘trie_new’ from incompatible pointer type [-Wincompatible-pointer-types]
 5669 |   __pyx_v_self->_c_trie = trie_new(__pyx_v_alpha_map->_c_alpha_map);
      |                                    ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
      |                                                     |
      |                                                     struct AlphaMap *

It looks like you are probably compiling a copy of datrie.c that was generated (with update_c.sh) before patching datrie.pyx.

@Stack7
Copy link

Stack7 commented Sep 19, 2024

Thanks! You were right! then, I updated and compiled it! That error has disappeared! However I have got a lot of undefined reference; the error file is attached. Many thanks for helping me.
error_compiling.txt

@musicinmybrain
Copy link
Author

Most of those errors indicate you’re not linking the CPython libraries. The first error that’s trying to find a main routine suggests you may be just blindly running something like gcc -I/usr/include/python3.12 datrie.c and expecting to get a Python extension module.

All of the following work fine for me in a git checkout of this branch:

$ python3 -m build
$ python3 setup.py build
$ python3 -m venv _e
$ . _e/bin/activate
(_e) $ pip install .

@Stack7
Copy link

Stack7 commented Sep 20, 2024

Thnk you very much for the help! In the end, I tried a workaround from here : #101:

export CFLAGS="-Wno-error=incompatible-pointer-types" ; export CXXFLAGS="-Wno-error=incompatible-pointer-types" ; pip install datrie and I succeded! Anyway, very very thanks

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

Successfully merging this pull request may close these issues.

4 participants