From 6dd3ef2fcb96315322ff5a5d80e7de38152069fc Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Tue, 5 Mar 2019 11:22:14 -0800 Subject: [PATCH] mesa: Add new package tracking newer Mesa version (!256) This adds a Mesa package overriding Mesa in Alpine, and: 1) builds a much newer version of Mesa than what is found in Alpine (by *not* building amd/radeonsi support, so no dependency on llvm). 2) builds Mesa with tegra and etnaviv drivers (note, as of now, the librem5 devkit gpu is not supported in the etnaviv driver here) This breaks "pmbootstrap qemu" for some people, use --host-qemu as workaround for now (a fix will be available soon): https://wiki.postmarketos.org/wiki/Troubleshooting:QEMU#Using_QEMU_from_the_host_system Since this also fixes the blackscreen bug on lg-hammerhead, the trade-off with the qemu bug is worth it. [ci:skip-build]: already built successfully in CI --- .../mesa/10-adjust-cache-deflate-buffer.patch | 16 ++ temp/mesa/20-musl.patch | 83 ++++++ temp/mesa/APKBUILD | 252 ++++++++++++++++++ ...on-add-toggle-for-TLS-support-in-GLX.patch | 71 +++++ 4 files changed, 422 insertions(+) create mode 100644 temp/mesa/10-adjust-cache-deflate-buffer.patch create mode 100644 temp/mesa/20-musl.patch create mode 100644 temp/mesa/APKBUILD create mode 100644 temp/mesa/meson-add-toggle-for-TLS-support-in-GLX.patch diff --git a/temp/mesa/10-adjust-cache-deflate-buffer.patch b/temp/mesa/10-adjust-cache-deflate-buffer.patch new file mode 100644 index 000000000..3c116cb69 --- /dev/null +++ b/temp/mesa/10-adjust-cache-deflate-buffer.patch @@ -0,0 +1,16 @@ +diff -ru mesa-18.1.7.orig/src/util/disk_cache.c mesa-18.1.7/src/util/disk_cache.c +--- mesa-18.1.7.orig/src/util/disk_cache.c 2018-08-24 19:25:19.000000000 +0300 ++++ mesa-18.1.7/src/util/disk_cache.c 2018-12-14 13:59:15.433631846 +0200 +@@ -721,8 +721,11 @@ + /* From the zlib docs: + * "If the memory is available, buffers sizes on the order of 128K or 256K + * bytes should be used." ++ * ++ * But that is performance optimization for large files. To keep stack usage ++ * in sensible amount (wrt. musl default stack) we use smaller stack on Alpine. + */ +-#define BUFSIZE 256 * 1024 ++#define BUFSIZE 4 * 1024 + + /** + * Compresses cache entry in memory and writes it to disk. Returns the size diff --git a/temp/mesa/20-musl.patch b/temp/mesa/20-musl.patch new file mode 100644 index 000000000..3c0f15dd6 --- /dev/null +++ b/temp/mesa/20-musl.patch @@ -0,0 +1,83 @@ +--- a/src/gallium/winsys/svga/drm/vmw_screen.h.orig 2015-05-07 14:02:28.033079796 +0200 ++++ b/src/gallium/winsys/svga/drm/vmw_screen.h 2015-05-07 14:02:48.832054666 +0200 +@@ -35,6 +35,8 @@ + #define VMW_SCREEN_H_ + + ++#include /* dev_t */ ++ + #include "pipe/p_compiler.h" + #include "pipe/p_state.h" + +--- a/src/gallium/state_trackers/nine/threadpool.h.orig 2015-05-07 14:10:53.443337212 +0200 ++++ b/src/gallium/state_trackers/nine/threadpool.h 2015-05-07 14:11:04.210307653 +0200 +@@ -24,6 +24,8 @@ + #ifndef _THREADPOOL_H_ + #define _THREADPOOL_H_ + ++#include ++ + #define MAXTHREADS 1 + + struct threadpool { +--- a/src/util/rand_xor.c.orig 2017-06-20 00:38:57.199474067 +0200 ++++ b/src/util/rand_xor.c 2017-06-20 00:40:31.351279557 +0200 +@@ -23,7 +23,9 @@ + */ + + #if defined(__linux__) ++#include + #include ++#include + #include + #include + #else +--- a/src/gallium/state_trackers/nine/nine_debug.c ++++ b/src/gallium/state_trackers/nine/nine_debug.c +@@ -73,8 +73,8 @@ + } + + #if defined(HAVE_PTHREAD) +-# if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \ +- (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12)) ++# if defined(__linux__) && !(defined(__GLIBC__) || \ ++ (__GLIBC__ < 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12))) + if (dbg_flags & DBG_TID) + tid = pthread_self(); + # endif +--- a/src/util/u_thread.h ++++ b/src/util/u_thread.h +@@ -61,9 +61,8 @@ + static inline void u_thread_setname( const char *name ) + { + #if defined(HAVE_PTHREAD) +-# if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \ +- (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12)) && \ +- defined(__linux__) ++# if defined(__linux__) && !(defined(__GLIBC__) || \ ++ (__GLIBC__ < 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12))) + pthread_setname_np(pthread_self(), name); + # endif + #endif +@@ -93,8 +92,8 @@ + static inline bool u_thread_is_self(thrd_t thread) + { + #if defined(HAVE_PTHREAD) +-# if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \ +- (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12)) ++# if defined(__linux__) && !(defined(__GLIBC__) || \ ++ (__GLIBC__ < 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12))) + return pthread_equal(pthread_self(), thread); + # endif + #endif +--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h ++++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h +@@ -28,6 +28,8 @@ + #ifndef RADV_AMDGPU_WINSYS_H + #define RADV_AMDGPU_WINSYS_H + ++#include ++ + #include "radv_radeon_winsys.h" + #include "ac_gpu_info.h" + #include "addrlib/addrinterface.h" diff --git a/temp/mesa/APKBUILD b/temp/mesa/APKBUILD new file mode 100644 index 000000000..c5a2428f9 --- /dev/null +++ b/temp/mesa/APKBUILD @@ -0,0 +1,252 @@ +# Forked from Alpine, so we can upgrade the version and build etnaviv and tegra +pkgname=mesa +pkgver=9999 +_pkgver=19.0 +pkgrel=0 +pkgdesc="[${_pkgver}] Mesa DRI OpenGL library" +url="https://www.mesa3d.org" +arch="all" +license="MIT SGI-B-2.0 BSL-1.0" +subpackages=" + $pkgname-dev + $pkgname-dri-swrast:_dri + $pkgname-dri-nouveau:_dri + $pkgname-dri-freedreno:_dri + $pkgname-dri-virtio:_dri + $pkgname-glapi $pkgname-egl $pkgname-gl $pkgname-gles + $pkgname-osmesa $pkgname-gbm + + " +depends_dev=" + libdrm-dev + libxext-dev + libxdamage-dev + libxcb-dev + libxshmfence-dev + " +makedepends=" + $depends_dev + bison + eudev-dev + expat-dev + flex + gettext + libelf-dev + libtool + libxfixes-dev + libva-dev + libvdpau-dev + libx11-dev + libxrandr-dev + libxxf86vm-dev + libxt-dev + libxvmc-dev + makedepend + py-mako + py3-libxml2 + python3 + talloc-dev + wayland-dev + wayland-protocols + xorgproto + zlib-dev + meson + ninja + " +source=" + https://gitlab.freedesktop.org/mesa/mesa/-/archive/${_pkgver}/mesa-${_pkgver}.tar.gz + 10-adjust-cache-deflate-buffer.patch + 20-musl.patch + meson-add-toggle-for-TLS-support-in-GLX.patch + " +replaces="mesa-dricore" + +_dri_driverdir=/usr/lib/dri +_dri_drivers="nouveau" +_gallium_drivers="swrast,freedreno,virgl,nouveau" + +case "$CARCH" in +x86*) + _dri_drivers="${_dri_drivers},i915,i965" + _gallium_drivers="${_gallium_drivers},svga" + subpackages="$subpackages \ + $pkgname-dri-intel:_dri \ + $pkgname-dri-vmwgfx:_dri" + ;; +armhf|aarch64) + _gallium_drivers="${_gallium_drivers},vc4,kmsro,etnaviv,tegra" + subpackages="$subpackages $pkgname-dri-vc4:_dri + $pkgname-dri-etnaviv:_dri + $pkgname-dri-imx:_dri + $pkgname-dri-tegra:_dri" + ;; +esac +builddir="$srcdir/mesa-${_pkgver}" + + +build() { + cd "$builddir" + + export CFLAGS="$CFLAGS -D_XOPEN_SOURCE=700" + mkdir "$builddir"/build + meson -Ddri-search-path="$_dri_driverdir" \ + -Dgallium-drivers="$_gallium_drivers" \ + -Ddri-drivers="$_dri_drivers" \ + -Dvulkan-drivers= \ + -Dplatforms=x11,wayland,drm \ + -Ddri3=true \ + -Degl=true \ + -Dglx=dri \ + -Dgles1=true \ + -Dgles2=true \ + -Dshared-glapi=true \ + -Dosmesa=gallium \ + -Dgbm=true \ + -Dglx-tls=false \ + -Dprefix="$pkgdir"/usr "$builddir"/build + ninja -C "$builddir"/build +} + +package() { + cd "$builddir" + ninja -C "$builddir"/build install +} + +egl() { + pkgdesc="[${_pkgver}] Mesa libEGL runtime libraries" + replaces="mesa" + + install -d "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libEGL.so* "$subpkgdir"/usr/lib/ +} + +gl() { + pkgdesc="[${_pkgver}] Mesa libGL runtime libraries" + replaces="mesa" + + install -d "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libGL.so* "$subpkgdir"/usr/lib/ +} + +glapi() { + pkgdesc="[${_pkgver}] Mesa shared glapi" + replaces="$pkgname-gles" + + install -d "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libglapi.so.* "$subpkgdir"/usr/lib/ +} + +gles() { + pkgdesc="[${_pkgver}] Mesa libGLESv2 runtime libraries" + replaces="mesa" + + install -d "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libGLES*.so* "$subpkgdir"/usr/lib/ +} + + +osmesa() { + pkgdesc="[${_pkgver}] Mesa offscreen rendering libraries" + + install -d "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libOSMesa.so.* "$subpkgdir"/usr/lib/ +} + +gbm() { + pkgdesc="[${_pkgver}] Mesa gbm library" + replaces="mesa" + + install -d "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libgbm.so.* "$subpkgdir"/usr/lib/ +} + +_mv_dri() { + install -d "$subpkgdir"/$_dri_driverdir + + while [ $# -gt 0 ]; do + mv "$pkgdir"/$_dri_driverdir/${1}.so \ + "$subpkgdir"/$_dri_driverdir/ + shift + done +} + +_mv_vdpau() { + local i + install -d "$subpkgdir"/usr/lib/vdpau + for i in "$@"; do + mv "$pkgdir"/usr/lib/vdpau/libvdpau_$i.* \ + "$subpkgdir"/usr/lib/vdpau/ + done +} + +_mv_gpipe() { + return 0 + # http://cgit.freedesktop.org/mesa/mesa/commit/?id=44ec468e8033553c26a112cebba41c343db00eb1 + # https://code.google.com/p/chromium/issues/detail?id=412089 +# local i +# install -d "$subpkgdir"/usr/lib/gallium-pipe +# for i in "$@"; do +# mv "$pkgdir"/usr/lib/gallium-pipe/pipe_$i.* \ +# "$subpkgdir"/usr/lib/gallium-pipe/ +# done +} + + + +_mv_va() { + local i + install -d "$subpkgdir"/usr/lib/dri + for i in "$@"; do + mv "$pkgdir"/usr/lib/dri/${i}_drv_video.so \ + "$subpkgdir"/usr/lib/dri/ + done +} + +_dri() { + local n=${subpkgname##*-dri-} + pkgdesc="[${_pkgver}] Mesa DRI driver for $n" + + case $n in + intel) + _mv_dri i915_dri i965_dri + ;; + freedreno) + _mv_dri msm_dri kgsl_dri + ;; + swrast) + _mv_dri swrast_dri kms_swrast_dri && _mv_gpipe swrast + ;; + vc4) + _mv_dri vc4_dri + ;; + vmwgfx) + _mv_dri vmwgfx_dri && _mv_gpipe vmwgfx + ;; + virtio) + _mv_dri virtio_gpu_dri + ;; + swrast) + _mv_dri swrast_dri kms_swrast_dri && _mv_gpipe swrast + ;; + etnaviv) + _mv_dri etnaviv_dri + ;; + imx) + _mv_dri imx-drm_dri + ;; + tegra) + _mv_dri tegra_dri + ;; + nouveau) + _mv_dri nouveau_dri nouveau_vieux_dri \ + && _mv_vdpau nouveau \ + && _mv_gpipe nouveau \ + && _mv_va nouveau + ;; + esac +} + +sha512sums="a8b7da7552ba120011dbb81943e343dfd43b35e59daab3206ad9befc9f9152ab87a1e4ac5509580a541611df5a0349219ed6c839884bbffcd7d58111b7035b57 mesa-19.0.tar.gz +cdf22d2da3328e116c379264886bd01fd3ad5cc45fe03dc6fd97bdc4794502598ee195c0b9d975fa264d6ac31c6fa108c0535c91800ecf4fcabfd308e53074cc 10-adjust-cache-deflate-buffer.patch +02db65893d55b5667d9c3bc193fc089e5408596431e06363fe2adea00c9e3c4e80612f3d03dc61f931d1a6ae04340bccf55e1376cf00bbf2433990713649d286 20-musl.patch +a7bbc0d8836fe5eb7220c7b41d8af439878a3876302de32739243232f979ea9c63d2069fcd78bef370eafef0a21f491ef99219ae686e965326475764244bbe5d meson-add-toggle-for-TLS-support-in-GLX.patch" diff --git a/temp/mesa/meson-add-toggle-for-TLS-support-in-GLX.patch b/temp/mesa/meson-add-toggle-for-TLS-support-in-GLX.patch new file mode 100644 index 000000000..106436863 --- /dev/null +++ b/temp/mesa/meson-add-toggle-for-TLS-support-in-GLX.patch @@ -0,0 +1,71 @@ +From patchwork Thu Jan 24 18:47:58 2019 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Subject: meson: add toggle for TLS support in GLX +From: Patrick Steinhardt +X-Patchwork-Id: 280319 +Message-Id: <225b2b2d4a43c43f035a55dd8e9c2217482f8fee.1548355622.git.ps@pks.im> +To: mesa-dev@lists.freedesktop.org +Cc: Patrick Steinhardt +Date: Thu, 24 Jan 2019 19:47:58 +0100 + +The musl libc library does not have any support for the +"initial-exec" TLS model and is unlikely to ever implement it. +Thus, TLS support in GLX has been turned off in musl-based +distributions to work around problems when dlopen'ing drivers. +While this is easily possible using the autoconf build system by +passing `--disable-glx-tls`, meson does not yet have such an +option. + +Add a new toggle "glx-tls" that defaults to `true` to gain parity +with autoconf. If disabled, `GLX_USE_TLS` will not be defined and +thus mesa will be built without TLS support. + +Signed-off-by: Patrick Steinhardt +--- + meson.build | 6 +++++- + meson_options.txt | 6 ++++++ + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 34e2a03254..3981bf1a67 100644 +--- a/meson.build ++++ b/meson.build +@@ -50,6 +50,7 @@ with_tests = get_option('build-tests') + with_valgrind = get_option('valgrind') + with_libunwind = get_option('libunwind') + with_asm = get_option('asm') ++with_glx_tls = get_option('glx-tls') + with_glx_read_only_text = get_option('glx-read-only-text') + with_glx_direct = get_option('glx-direct') + with_osmesa = get_option('osmesa') +@@ -332,7 +333,10 @@ if with_egl and not (with_platform_drm or with_platform_surfaceless) + endif + endif + +-pre_args += '-DGLX_USE_TLS' ++if with_glx_tls ++ pre_args += '-DGLX_USE_TLS' ++endif ++ + if with_glx != 'disabled' + if not (with_platform_x11 and with_any_opengl) + error('Cannot build GLX support without X11 platform support and at least one OpenGL API') +diff --git a/meson_options.txt b/meson_options.txt +index bfb06c4dd4..8ff63f20b4 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -224,6 +224,12 @@ option( + value : true, + description : 'Build assembly code if possible' + ) ++option( ++ 'glx-tls', ++ type : 'boolean', ++ value : true, ++ description : 'Enable TLS support in GLX' ++) + option( + 'glx-read-only-text', + type : 'boolean',