Subject: [alpine-aports] [PATCH] main/mesa: Upgrade to 18.0.0

From: Taner Tas <[email-masked]>
Date: Mon, 16 Apr 2018 21:21:37 +0300

* Clarify license
* Fix typo related with enabling vulkan drivers
* Add subpackages for radeon and intel vulkan drivers
* Add aarch64 arch to use neon instructions
* Modernize APKBUILD

---
 main/mesa/APKBUILD | 51 ++++++++++++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 18 deletions(-)

diff --git a/main/mesa/APKBUILD b/main/mesa/APKBUILD
index 1bc4e630..c0a8c4f9 100644
--- a/main/mesa/APKBUILD
+++ b/main/mesa/APKBUILD
@@ -1,11 +1,11 @@
 # Maintainer: Natanael Copa <[email-masked]>
 pkgname=mesa
-pkgver=17.3.6
+pkgver=18.0.0
 pkgrel=0
 pkgdesc="Mesa DRI OpenGL library"
 url="http://www.mesa3d.org"
 arch="all"
-license="LGPL"
+license="MIT SGI-B-2.0 BSL-1.0"
 subpackages="$pkgname-dev
 	$pkgname-dri-ati:_dri
 	$pkgname-dri-nouveau:_dri
@@ -15,6 +15,7 @@ subpackages="$pkgname-dev
 	$pkgname-glapi $pkgname-egl $pkgname-gl $pkgname-gles
 	$pkgname-xatracker $pkgname-osmesa $pkgname-gbm
 	$pkgname-libwayland-egl:_wayland
+	$pkgname-vulkan-ati:_vulkan
 	"
 _llvmver=5
 depends_dev="libdrm-dev dri2proto libxext-dev libxdamage-dev libxcb-dev glproto
@@ -37,33 +38,25 @@ _dri_drivers="r200,radeon,nouveau,swrast"
 _gallium_drivers="r300,r600,radeonsi,nouveau,freedreno,swrast,virgl"
 _vulkan_drivers="radeon"
 
-builddir="$srcdir/mesa-$pkgver"
-
 _arch_opts=
 
 case "$CARCH" in
 x86*)
 	_dri_drivers="${_dri_drivers},i915,i965"
 	_gallium_drivers="${_gallium_drivers},svga"
-	_vulcan_drivers="$_vulcan_drivers,intel"
-	subpackages="$subpackages $pkgname-dri-intel:_dri $pkgname-dri-vmwgfx:_dri"
+	_vulkan_drivers="$_vulkan_drivers,intel"
+	subpackages="$subpackages $pkgname-dri-intel:_dri $pkgname-dri-vmwgfx:_dri $pkgname-vulkan-intel:_vulkan"
 	_arch_opts="--enable-dri3"
 	;;
-arm*)
+armhf|aarch64)
 	_gallium_drivers="${_gallium_drivers},vc4"
-	case "$CARCH" in
-	armhf) CFLAGS="$CFLAGS -mfpu=neon";;
-	esac
+	CFLAGS="$CFLAGS -mfpu=neon"
 	;;
 esac
 
 prepare() {
 	cd "$builddir"
-	for i in $source; do
-		case $i in
-		*.patch) msg $i; patch -p1 -i "$srcdir"/$i;;
-		esac
-	done
+	default_prepare
 	libtoolize --force \
 		&& aclocal \
 		&& automake --add-missing \
@@ -72,7 +65,6 @@ prepare() {
 
 build() {
 	cd "$builddir"
-
 	export CFLAGS="$CFLAGS -D_XOPEN_SOURCE=700"
 	./configure \
 		--build=$CBUILD \
@@ -85,7 +77,7 @@ build() {
 		--enable-glx-rts \
 		--with-gallium-drivers=${_gallium_drivers} \
 		--with-dri-drivers=${_dri_drivers} \
-		--with-vulcan-drivers=${_vulkan_drivers} \
+		--with-vulkan-drivers=${_vulkan_drivers} \
 		--with-llvm-prefix=/usr/lib/llvm$_llvmver \
 		--enable-llvm \
 		--enable-llvm-shared-libs \
@@ -197,6 +189,16 @@ _mv_gpipe() {
 #	done
 }
 
+_mv_vulkan() {
+	local i
+	install -d "$subpkgdir"/usr/lib
+	install -d "$subpkgdir"/usr/share/vulkan/icd.d
+	for i in "$@"; do
+		mv "$pkgdir"/usr/lib/libvulkan_${i}.so "$subpkgdir"/usr/lib
+		mv "$pkgdir"/usr/share/vulkan/icd.d/${i}* "$subpkgdir"/usr/share/vulkan/icd.d
+	done
+}
+
 _dri() {
 	local n=${subpkgname##*-dri-}
 	pkgdesc="Mesa DRI driver for $n"
@@ -237,7 +239,20 @@ _wayland() {
 	mv "$pkgdir"/usr/lib/libwayland-egl.so.* "$subpkgdir"/usr/lib/
 }
 
-sha512sums="5164ed5a1d3d25031b712a9f443f0e467a29b2bca0a1aa11324ed5c10279411979c9c7482825053926a813e76c58b78a3439c7c81fcd51a7808f53977080828f  mesa-17.3.6.tar.xz
+_vulkan() {
+	local n=${subpkgname##*-vulkan-}
+	pkgdesc="Mesa Vulkan API driver for $n"
+
+	case $n in
+	ati)
+		_mv_vulkan radeon
+		;;
+	intel)
+		_mv_vulkan intel
+		;;
+	esac
+}
+sha512sums="1494bb09357896a2505b3dcfec772268e28c765804f21e144948a314f1d79d99ff9f21062ef5860eb5a5a568b305a9c954585924a7ac8890fe1ebd8df3bcc396  mesa-18.0.0.tar.xz
 c3d4804ebc24c7216e4c9d4995fb92e116be7f478024b44808ee134a4c93bb51d1f66fe5fb6eca254f124c4abf6f81272b027824b3e2650a9607818bf793035a  glx_ro_text_segm.patch
 163498ac0deaaa9ce19a1e12a8a6f3ab4b90fc97e0b65b25d595c0a01201a5daacb063614c53c26d7958e1daccfa94e3e313c83a8cdc04e29a56891230707bec  musl-fixes.patch
 f206c965b60131563ce920341042bdbd6911efe9e9d8edb5422c2c3490b42e903eb2260ba9549184c76a2f4692908706641818609c535efb9ed16f00ee4f6889  musl-fix-includes.patch
-- 
2.17.0

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Mon, 23 Apr 2018 21:20:26 +0200

On Mon, 16 Apr 2018 21:21:37 +0300

> * Add aarch64 arch to use neon instructions

It does not mention that we also enable vc4 driver for aarch64?

> index 1bc4e630..c0a8c4f9 100644

This breaks build on aarch64:

checking whether the C compiler works... no 
configure: error: in `/home/ncopa/aports/main/mesa/src/mesa-18.0.0':
configure: error: C compiler cannot create executables
See `config.log' for more details 

config.log has this explanation:

configure:4657: checking whether the C compiler works
configure:4679: gcc -Os -mfpu=neon -D_XOPEN_SOURCE=700 -Os -Wl,--as-needed conftest.c  >&5
gcc: error: unrecognized command line option '-mfpu=neon'

We cannot add -mfpu=neon to CFLAGS on aarch64

But as I understand your patch, we want enable vc4 driver on aarch64 too?

Is it ok if I apply it with this change:

diff --git a/main/mesa/APKBUILD b/main/mesa/APKBUILD
index c0a8c4f997..404b0385d4 100644
--- a/main/mesa/APKBUILD
+++ b/main/mesa/APKBUILD
@@ -50,7 +50,9 @@ x86*)
        ;;
 armhf|aarch64)
        _gallium_drivers="${_gallium_drivers},vc4"
-       CFLAGS="$CFLAGS -mfpu=neon"
+       case "$CARCH" in
+       armhf) CFLAGS="$CFLAGS -mfpu=neon";;
+       esac
        ;;
 esac

---

---

From: Taner Tas <[email-masked]>
Date: Tue, 24 Apr 2018 08:28:11 +0300

On Mon, 23 Apr 2018 21:20:26 +0200

> It does not mention that we also enable vc4 driver for aarch64?
You're right, will be mentioned.

> +       armhf) CFLAGS="$CFLAGS -mfpu=neon";;

Yes, vc4 can be enabled on aarch64 for Rpi3 too.
Enabling -mfpu=neon seems doesn't needed on aarch64, thus separately enabling on armhf is enough as mentiones above.
I prepared another PR on github with newer version and suggested changes.
Please refer to: https://github.com/alpinelinux/aports/pull/4107

Thanks for review.

-- 
Taner

---