libyal / libpff

Library and tools to access the Personal Folder File (PFF) and the Offline Folder File (OFF) format
GNU Lesser General Public License v3.0
289 stars 74 forks source link

Failure to compile on Alpine linux due to undefined mempcpy #110

Closed brassy-endomorph closed 2 years ago

brassy-endomorph commented 2 years ago

Running pip install libpff-python-ratom (which I know isn't something you maintain, but you're upstream) results in this error:

    gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -DHAVE_CONFIG_H= -DLOCALEDIR="/usr/share/locale" -Iinclude -Icommon -Ilibcerror -Ilibcthreads -Ilibcdata -Ilibclocale -Ilibcnotify -Ilibcsplit -Ilibuna -Ilibcfile -Ilibcpath -Ilibbfio -Ilibfcache -Ilibfdata -Ilibfdatetime -Ilibfguid -Ilibfvalue -Ilibfwnt -Ilibfmapi -Ilibpff -I/usr/local/include/python3.10 -c pypff/pypff_attachment.c -o build/temp.linux-x86_64-3.10/pypff/pypff_attachment.o
    In file included from /usr/include/fortify/strings.h:22,
                     from /usr/include/string.h:57,
                     from /usr/include/fortify/wchar.h:30,
                     from include/libpff/types.h:193,
                     from common/types.h:34,
                     from pypff/pypff_attachment.c:23:
    /usr/include/fortify/string.h:144:1: error: 'mempcpy' undeclared here (not in a function); did you mean 'memccpy'?
      144 | _FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n)
          | ^~~~~~~~~~~
    In file included from /usr/local/include/python3.10/Python.h:30,
                     from pypff/pypff_python.h:46,
                     from pypff/pypff_item.h:29,
                     from pypff/pypff_attachment.h:28,
                     from pypff/pypff_attachment.c:30:
    /usr/include/fortify/string.h: In function 'mempcpy':
    /usr/include/fortify/string.h:151:9: error: called object '__orig_mempcpy' is not a function or function pointer
      151 |  return __orig_mempcpy(__d, __s, __n);
          |         ^~~~~~~~~~~~~~
    In file included from /usr/include/fortify/strings.h:22,
                     from /usr/include/string.h:57,
                     from /usr/include/fortify/wchar.h:30,
                     from include/libpff/types.h:193,
                     from common/types.h:34,
                     from pypff/pypff_attachment.c:23:
    /usr/include/fortify/string.h:144:1: note: declared here
      144 | _FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n)
          | ^~~~~~~~~~~
    error: command '/usr/bin/gcc' failed with exit code 1
    ----------------------------------------

This appears to be related to this: https://github.com/python-pillow/Pillow/issues/1850

Env:

joachimmetz commented 2 years ago
  1. Python bindings are not officially completed https://github.com/libyal/libpff/issues/2
  2. libpff/pypff codebase doesn't use mempcpy

So this is not a libpff/pypff issue

joachimmetz commented 2 years ago

Based on the links you refer to this seems to be a missing define of GNU_SOURCE in the Alpine Python build configuration/environment.

brassy-endomorph commented 2 years ago

It may not, but the order of includes within the codebase may be causing that in a similar manner to this comment here. https://github.com/python-pillow/Pillow/issues/1850#issuecomment-218428866

joachimmetz commented 2 years ago

https://github.com/libyal/libpff/blob/main/include/libpff/types.h.in#L193 just imports wchar.h of libc stdlib

Alpine Linux seems to ship a "fortify" version of this header, this is where the error happens

setup.py uses python-config --cflags to determine the compile flags, check if that sets GNU_SOURCE on Alpine Linux