[OE-core] [PATCH 24/53] directfb: Fix build with musl

Andre McCurdy armccurdy at gmail.com
Sat Jan 9 03:27:41 UTC 2016


On Fri, Jan 8, 2016 at 2:18 AM, Khem Raj <raj.khem at gmail.com> wrote:
> compar_fn_t, sigval_t and non-posix recursive mutexes
> are not available in musl
>
> Signed-off-by: Khem Raj <raj.khem at gmail.com>
> ---
>  meta/recipes-graphics/directfb/directfb.inc        |  5 ++
>  .../directfb/directfb/compar_fn_t.patch            | 62 ++++++++++++++++++++++
>  .../directfb/directfb/union-sigval.patch           | 19 +++++++
>  .../directfb/use-PTHREAD_MUTEX_RECURSIVE.patch     | 19 +++++++
>  4 files changed, 105 insertions(+)
>  create mode 100644 meta/recipes-graphics/directfb/directfb/compar_fn_t.patch
>  create mode 100644 meta/recipes-graphics/directfb/directfb/union-sigval.patch
>  create mode 100644 meta/recipes-graphics/directfb/directfb/use-PTHREAD_MUTEX_RECURSIVE.patch
>
> diff --git a/meta/recipes-graphics/directfb/directfb.inc b/meta/recipes-graphics/directfb/directfb.inc
> index 603aba3..3a79a8f 100644
> --- a/meta/recipes-graphics/directfb/directfb.inc
> +++ b/meta/recipes-graphics/directfb/directfb.inc
> @@ -16,7 +16,12 @@ SRC_URI = "http://www.directfb.org/downloads/Core/DirectFB-1.7/DirectFB-${PV}.ta
>             file://fusion.patch \
>             file://bashism.patch \
>             file://0001-gfx-direct-Aboid-usng-VLAs-and-printf-formats.patch \
> +           file://compar_fn_t.patch \
>            "
> +SRC_URI_append_libc-musl = "\
> +                            file://union-sigval.patch \
> +                            file://use-PTHREAD_MUTEX_RECURSIVE.patch \
> +                           "

For patches which fix 'correctness' issues uncovered by musl maybe
it's better to apply the patches unconditionally, so they get some
test cover from non-musl builds?

Especially true in this case - see below.

>  S = "${WORKDIR}/DirectFB-${PV}"
>
> diff --git a/meta/recipes-graphics/directfb/directfb/compar_fn_t.patch b/meta/recipes-graphics/directfb/directfb/compar_fn_t.patch
> new file mode 100644
> index 0000000..ee4d900
> --- /dev/null
> +++ b/meta/recipes-graphics/directfb/directfb/compar_fn_t.patch
> @@ -0,0 +1,62 @@
> +test for __compar_fn_t and if not defined by libc then define it
> +help make directfb compile with musl
> +
> +Upstream-Status: Pending
> +Signed-off-by: Khem Raj <raj.khem at gmail.com>
> +
> +Index: DirectFB-1.7.7/configure.in
> +===================================================================
> +--- DirectFB-1.7.7.orig/configure.in
> ++++ DirectFB-1.7.7/configure.in
> +@@ -112,6 +112,17 @@ AC_CHECK_SIZEOF(long)
> + AC_CHECK_SIZEOF(long long)
> + AC_CHECK_FUNCS(fork)
> +
> ++AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [
> ++    AC_TRY_COMPILE(
> ++        [#include <stdlib.h>],
> ++        [void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); }],
> ++        ccache_cv_COMPAR_FN_T=yes,
> ++        ccache_cv_COMPAR_FN_T=no)])
> ++if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then
> ++   AC_DEFINE(HAVE_COMPAR_FN_T, 1,
> ++             Define to 1 if you have the `__compar_fn_t' typedef.)
> ++fi
> ++
> + AC_PATH_PROGS(PERL, perl5 perl)
> +
> + AC_PATH_PROG(MAN2HTML, man2html, no)
> +Index: DirectFB-1.7.7/inputdrivers/lirc/lirc.c
> +===================================================================
> +--- DirectFB-1.7.7.orig/inputdrivers/lirc/lirc.c
> ++++ DirectFB-1.7.7/inputdrivers/lirc/lirc.c
> +@@ -59,6 +59,11 @@
> +
> + #include <core/input_driver.h>
> +
> ++#if HAVE_COMPAR_FN_T
> ++#define COMPAR_FN_T __compar_fn_t
> ++#else
> ++typedef int (*COMPAR_FN_T)(const void *, const void *);
> ++#endif
> +
> + DFB_INPUT_DRIVER( lirc )
> +
> +@@ -97,7 +102,7 @@ static DFBInputDeviceKeySymbol lirc_pars
> +           qsort ( keynames,
> +                   D_ARRAY_SIZE( keynames ),
> +                   sizeof(keynames[0]),
> +-                  (__compar_fn_t) keynames_sort_compare );
> ++                  (COMPAR_FN_T) keynames_sort_compare );
> +           keynames_sorted = true;
> +      }
> +
> +@@ -124,7 +129,7 @@ static DFBInputDeviceKeySymbol lirc_pars
> +                symbol_name = bsearch( name, keynames,
> +                                       D_ARRAY_SIZE( keynames ),
> +                                       sizeof(keynames[0]),
> +-                                      (__compar_fn_t) keynames_compare );
> ++                                      (COMPAR_FN_T) keynames_compare );
> +                if (symbol_name)
> +                     return symbol_name->symbol;
> +                break;
> diff --git a/meta/recipes-graphics/directfb/directfb/union-sigval.patch b/meta/recipes-graphics/directfb/directfb/union-sigval.patch
> new file mode 100644
> index 0000000..29f45c7
> --- /dev/null
> +++ b/meta/recipes-graphics/directfb/directfb/union-sigval.patch
> @@ -0,0 +1,19 @@
> +This patch is taken from gentoo musl overlay
> +sigval_t is glibc only construct, we use a union of sigval
> +which pretty much is same effect as sigval_t
> +
> +Upstream-Status: Pending
> +Signed-off-by: Khem Raj <raj.khem at gmail.com>
> +
> +diff -Naur DirectFB-1.7.6.orig/lib/direct/os/linux/glibc/system.c DirectFB-1.7.6/lib/direct/os/linux/glibc/system.c
> +--- DirectFB-1.7.6.orig/lib/direct/os/linux/glibc/system.c     2014-07-15 02:54:58.000000000 -0400
> ++++ DirectFB-1.7.6/lib/direct/os/linux/glibc/system.c  2015-07-18 16:55:35.077989166 -0400
> +@@ -111,7 +111,7 @@
> + void
> + direct_trap( const char *domain, int sig )
> + {
> +-     sigval_t val;
> ++     union sigval val;
> +
> +      if (direct_config->delay_trap_ms) {
> +           D_LOG( Direct_Trap, VERBOSE, "NOT RAISING signal %d from %s, waiting for %dms... attach gdb --pid=%d\n", sig, domain, direct_config->delay_trap_ms, getpid() );
> diff --git a/meta/recipes-graphics/directfb/directfb/use-PTHREAD_MUTEX_RECURSIVE.patch b/meta/recipes-graphics/directfb/directfb/use-PTHREAD_MUTEX_RECURSIVE.patch
> new file mode 100644
> index 0000000..e65f59e
> --- /dev/null
> +++ b/meta/recipes-graphics/directfb/directfb/use-PTHREAD_MUTEX_RECURSIVE.patch
> @@ -0,0 +1,19 @@
> +This patch is taken from gentoo musl overlay
> +uses recursive mutex directly instead of non-posix version
> +
> +Upstream-Status: Pending
> +Signed-off-by: Khem Raj <raj.khem at gmail.com>
> +
> +
> +diff -Naur DirectFB-1.7.6.orig/lib/direct/os/linux/glibc/mutex.h DirectFB-1.7.6/lib/direct/os/linux/glibc/mutex.h
> +--- DirectFB-1.7.6.orig/lib/direct/os/linux/glibc/mutex.h      2013-12-18 19:16:24.000000000 -0500
> ++++ DirectFB-1.7.6/lib/direct/os/linux/glibc/mutex.h   2015-07-18 16:57:47.178982835 -0400
> +@@ -46,7 +46,7 @@
> + /**********************************************************************************************************************/
> +
> + #define DIRECT_MUTEX_INITIALIZER(name)            { PTHREAD_MUTEX_INITIALIZER }
> +-#define DIRECT_RECURSIVE_MUTEX_INITIALIZER(name)  { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP }
> ++#define DIRECT_RECURSIVE_MUTEX_INITIALIZER(name)  { PTHREAD_MUTEX_RECURSIVE }

This looks completely bogus.

PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP initialises a pthread_mutex_t
structure and PTHREAD_MUTEX_RECURSIVE is an enum. You can't just
replace one with the other.

> +
> + #endif
> +
> --
> 2.7.0
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core



More information about the Openembedded-core mailing list