Opened 2 months ago

Closed 6 weeks ago

#11156 closed defect (fixed)

libavdevice fails to compile on Linux (musl libc)

Reported by: 2246c68 Owned by:
Priority: normal Component: avdevice
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

libavdevice fails to build on Linux (musl libc).

How to reproduce:

% ../configure \
    --cross-prefix="aarch64-unknown-linux-musl-" \
    --target-os="linux" \
    --arch="aarch64" \
    --disable-alsa \
    --disable-appkit \
    --disable-asm \
    --disable-audiotoolbox \
    --disable-avfoundation \
    --disable-bzlib \
    --disable-coreimage \
    --disable-debug \
    --disable-doc \
    --disable-iconv \
    --disable-libxcb \
    --disable-lzma \
    --disable-neon \
    --disable-schannel \
    --disable-sdl2 \
    --disable-securetransport \
    --disable-static \
    --disable-symver \
    --disable-videotoolbox \
    --disable-vulkan \
    --disable-xlib \
    --disable-zlib \
    --disable-manpages \
    --disable-htmlpages \
    --disable-podpages \
    --disable-txtpages \
    --enable-pic \
    --enable-shared \
    --enable-small \
    --enable-version3
% make
src/libavdevice/v4l2.c: In function 'device_open':
src/libavdevice/v4l2.c:137:17: error: assignment to 'int (*)(int,  long unsigned int, ...)' from incompatible pointer type 'int (*)(int,  int, ...)' [-Wincompatible-pointer-types]
  137 |     s->ioctl_f  = prefix ## ioctl;      \
      |                 ^
src/libavdevice/v4l2.c:151:9: note: in expansion of macro 'SET_WRAPPERS'
  151 |         SET_WRAPPERS();
      |         ^~~~~~~~~~~~

git bisect points to 9e674b31606c805dd31b4bb754364a72a5877238 as the culprit.

There is one main issue with the changes implemented in that commit, specifically the use of the __musl__ macro to write musl-specific code:

...
#if defined(__sun) || defined(__BIONIC__) || defined(__musl__) /* POSIX-like */
...

It should be noted that musl does not currently provide any way to detect itself (see https://wiki.musl-libc.org/faq). That is, neither the __musl__ nor __MUSL__ macros exists. The #if defined(__musl__) condition will always evaluate to false, even on musl platforms, leading FFmpeg to use the wrong prototype.

Change History (1)

comment:1 by Marton Balint, 6 weeks ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.