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

Fixes needed in Termux #7

Open
Manamama opened this issue Feb 11, 2024 · 1 comment
Open

Fixes needed in Termux #7

Manamama opened this issue Feb 11, 2024 · 1 comment

Comments

@Manamama
Copy link

Manamama commented Feb 11, 2024

Quick FYI, that on Termux, Android this:

add_definitions(-D_GNU_SOURCE)
include(CheckIncludeFile)
check_include_file("limits.h" HAVE_LIMITS_H)
add_compile_definitions(-DSSIZE_MAX=9223372036854775807)

added to:

/data/data/com.termux/files/home/downloads/Levenshtein-0.24.0/src/Levenshtein

was needed to fix:

.0:23: error: 'SSIZE_MAX' was not declared in this scope; did you mean 'SIZE_MAX'?
 5750 |         if (unlikely((PY_SSIZE_T_MAX >> kind_shift) - ulength < char_pos))
      |                       ^~~~~~~~~~~~~~
/data/data/com.termux/files/home/downloads/Levenshtein-0.24.0/src/Levenshtein/levenshtein_cpp.cxx:1456:43: note: in definition of macro 'unlikely'
 1456 |   #define unlikely(x) __builtin_expect(!!(x), 0)
      |                                           ^
/data/data/com.termux/files/home/downloads/Levenshtein-0.24.0/src/Levenshtein/levenshtein_cpp.cxx: In function 'Py_ssize_t __Pyx_ssize_strlen(const char*)':
/data/data/com.termux/files/home/downloads/Levenshtein-0.24.0/src/Levenshtein/levenshtein_cpp.cxx:9131:33: error: 'SSIZE_MAX' was not declared in this scope; did you mean 'SIZE_MAX'?
 9131 |     if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) {
      |                                 ^~~~~~~~~~~~~~
/data/data/com.termux/files/home/downloads/Levenshtein-0.24.0/src/Levenshtein/levenshtein_cpp.cxx:1456:43: note: in definition of macro 'unlikely'
 1456 |   #define unlikely(x) __builtin_expect(!!(x), 0)
      |                                           ^
make[2]: *** [src/Levenshtein/CMakeFiles/levenshtein_cpp.dir/build.make:76: src/Levenshtein/CMakeFiles/levenshtein_cpp.dir/levenshtein_cpp.cxx.o] Error 1
@maxbachmann
Copy link
Member

I am honestly confused by this. This is something we pull in from CPython:

/* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) ==
 * sizeof(size_t).  C99 doesn't define such a thing directly (size_t is an
 * unsigned integral type).  See PEP 353 for details.
 * PY_SSIZE_T_MAX is the largest positive value of type Py_ssize_t.
 */
#ifdef HAVE_PY_SSIZE_T

#elif HAVE_SSIZE_T
typedef ssize_t         Py_ssize_t;
#   define PY_SSIZE_T_MAX SSIZE_MAX
#elif SIZEOF_VOID_P == SIZEOF_SIZE_T
typedef Py_intptr_t     Py_ssize_t;
#   define PY_SSIZE_T_MAX INTPTR_MAX
#else
#   error "Python needs a typedef for Py_ssize_t in pyport.h."
#endif

The error means that in you environment you have ssize_t but not SSIZE_MAX.
Wouldn't this cause problems with virtually any compiled C module? To me this sounds very much like an issue with your / the termux environment.

Edit: I just gave this a test on termux on my Android phone. For me it appears to build fine. It fails to import due to some missing symbol in Cpython though. Maybe linked to it absolutely wanting to use the gold linker for some reason. Idk how to get rid of this behavior.

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