From 3387aeb4d6d386bccfae1ef08f03fff341607f94 Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 10 May 2021 20:51:51 +0200 Subject: [PATCH] libglvnd: work around crashing on musl systems and multithreaded gl firstly, disable ppc64 tsb assembly since it appears to be broken in multithread contexts; secondly, when not using asm, compile the dispatch code with low optimization level as doing otherwise seems to result in crashes in multithreaded contexts we'll need to fix this properly at some point, for now do this the assembly code is seemingly buggy and causes strange crashes when used with threaded code, so fall back to pure C paths --- .../libglvnd/patches/musl-noasm-use-o0.patch | 52 +++++++++++++++++++ srcpkgs/libglvnd/template | 5 +- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/libglvnd/patches/musl-noasm-use-o0.patch diff --git a/srcpkgs/libglvnd/patches/musl-noasm-use-o0.patch b/srcpkgs/libglvnd/patches/musl-noasm-use-o0.patch new file mode 100644 index 00000000000..0ecf492e1c5 --- /dev/null +++ b/srcpkgs/libglvnd/patches/musl-noasm-use-o0.patch @@ -0,0 +1,52 @@ +From d82adbb78a246d68d67a951cdfc81b757fac2453 Mon Sep 17 00:00:00 2001 +From: Daniel Kolesa +Date: Mon, 10 May 2021 23:02:21 +0200 +Subject: [PATCH] lower optimization for dispatch code when using C + tsb + +there appears to be some bug in the code which causes crashes +with threaded opengl setups; this manifests at least on ppc64(le) +with musl (where one must set `-Dtls=enabled`). I haven't been +able to track it down yet, but this workaround at least makes it +stop happening. +--- + src/GLdispatch/vnd-glapi/meson.build | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git src/GLdispatch/vnd-glapi/meson.build src/GLdispatch/vnd-glapi/meson.build +index 615cdff..94310b3 100644 +--- src/GLdispatch/vnd-glapi/meson.build ++++ src/GLdispatch/vnd-glapi/meson.build +@@ -35,8 +35,12 @@ else + endif + + _entry_files = [] ++_extra_cflags = [] + if gl_dispatch_type == 'pure_c' + _entry_files += 'entry_pure_c.c' ++ if not have_tls ++ _extra_cflags += '-O0' ++ endif + else + _entry_files += 'entry_common.c' + if gl_dispatch_type != 'armv7_tsd' +@@ -73,7 +77,7 @@ libglapi = static_library( + glapi_mapi_tmp_h, + _entry_files, + ], +- c_args : ['-DMAPI_ABI_HEADER="@0@"'.format(glapi_mapi_tmp_h.full_path())], ++ c_args : ['-DMAPI_ABI_HEADER="@0@"'.format(glapi_mapi_tmp_h.full_path())] + _extra_cflags, + include_directories : inc_include, + dependencies : idep_utils_misc, + gnu_symbol_visibility : 'hidden', +@@ -89,7 +93,7 @@ foreach g : ['gl', 'opengl', 'glesv1', 'glesv2'] + c_args : [ + '-DSTATIC_DISPATCH_ONLY', + '-DMAPI_ABI_HEADER="@0@"'.format(header.full_path()), +- ], ++ ] + _extra_cflags, + include_directories : [inc_include, inc_util], + gnu_symbol_visibility : 'hidden', + ) +-- +2.31.1 + diff --git a/srcpkgs/libglvnd/template b/srcpkgs/libglvnd/template index 77b80b0abcf..3d974e70b9a 100644 --- a/srcpkgs/libglvnd/template +++ b/srcpkgs/libglvnd/template @@ -1,7 +1,7 @@ # Template file for 'libglvnd' pkgname=libglvnd version=1.3.2 -revision=1 +revision=2 wrksrc="libglvnd-v${version}" build_style=meson hostmakedepends="pkg-config" @@ -21,7 +21,10 @@ if [ "$XBPS_TARGET_LIBC" = "musl" ]; then configure_args="-Dtls=disabled" fi +# ppc64_tsd (used when ppc64_tls is not available) +# is broken with threads, so disable it on musl case "$XBPS_TARGET_MACHINE" in + ppc*-musl) configure_args+=" -Dasm=disabled";; ppc64*) ;; arm*|mips*|ppc*) configure_args+=" -Dasm=disabled";; esac