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

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

Closed
brassy-endomorph opened this issue Feb 26, 2022 · 4 comments
Closed
Assignees
Labels

Comments

@brassy-endomorph
Copy link

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: python-pillow/Pillow#1850

Env:

  • Alpine 3.15
  • Python 3.10.2
  • libpff-python-ratom 20200808
@joachimmetz
Copy link
Member

joachimmetz commented Feb 26, 2022

  1. Python bindings are not officially completed Add Python bindings #2
  2. libpff/pypff codebase doesn't use mempcpy

So this is not a libpff/pypff issue

@joachimmetz joachimmetz self-assigned this Feb 26, 2022
@joachimmetz
Copy link
Member

joachimmetz commented Feb 26, 2022

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
Copy link
Author

It may not, but the order of includes within the codebase may be causing that in a similar manner to this comment here. python-pillow/Pillow#1850 (comment)

@joachimmetz
Copy link
Member

joachimmetz commented Feb 26, 2022

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

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

No branches or pull requests

2 participants