From 5d15e68db31f62d8c6ba3a5a9a507597d6908678 Mon Sep 17 00:00:00 2001 From: q66 Date: Tue, 27 Aug 2019 21:04:21 +0200 Subject: [PATCH] libGL: less buggy CPU feature handling/detection on ppc* Patch has been upstreamed. Also, explicitly control power8 feature usage. [ci skip] --- srcpkgs/libGL/patches/ppc-auxval.patch | 55 ++++++++++++++++++++++++++ srcpkgs/libGL/template | 5 +++ 2 files changed, 60 insertions(+) create mode 100644 srcpkgs/libGL/patches/ppc-auxval.patch diff --git a/srcpkgs/libGL/patches/ppc-auxval.patch b/srcpkgs/libGL/patches/ppc-auxval.patch new file mode 100644 index 0000000000..3fe2725eb4 --- /dev/null +++ b/srcpkgs/libGL/patches/ppc-auxval.patch @@ -0,0 +1,55 @@ +Upstream: https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1785 +Status: Merged + +--- src/util/u_cpu_detect.c ++++ src/util/u_cpu_detect.c +@@ -92,7 +92,7 @@ static int has_cpuid(void); + #endif + + +-#if defined(PIPE_ARCH_PPC) && !defined(PIPE_OS_APPLE) ++#if defined(PIPE_ARCH_PPC) && !defined(PIPE_OS_APPLE) && !defined(PIPE_OS_LINUX) + static jmp_buf __lv_powerpc_jmpbuf; + static volatile sig_atomic_t __lv_powerpc_canjump = 0; + +@@ -126,8 +126,29 @@ check_os_altivec_support(void) + util_cpu_caps.has_altivec = 1; + } + } +-#else /* !PIPE_OS_APPLE */ +- /* not on Apple/Darwin, do it the brute-force way */ ++#elif defined(PIPE_OS_LINUX) /* !PIPE_OS_APPLE */ ++#if defined(PIPE_ARCH_PPC_64) ++ Elf64_auxv_t aux; ++#else ++ Elf32_auxv_t aux; ++#endif ++ int fd = open("/proc/self/auxv", O_RDONLY | O_CLOEXEC); ++ if (fd >= 0) { ++ while (read(fd, &aux, sizeof(aux)) == sizeof(aux)) { ++ if (aux.a_type == AT_HWCAP) { ++ char *env_vsx = getenv("GALLIVM_VSX"); ++ uint64_t hwcap = aux.a_un.a_val; ++ util_cpu_caps.has_altivec = (hwcap >> 28) & 1; ++ if (!env_vsx || env_vsx[0] != '0') { ++ util_cpu_caps.has_vsx = (hwcap >> 7) & 1; ++ } ++ break; ++ } ++ } ++ close(fd); ++ } ++#else /* !PIPE_OS_APPLE && !PIPE_OS_LINUX */ ++ /* not on Apple/Darwin or Linux, do it the brute-force way */ + /* this is borrowed from the libmpeg2 library */ + signal(SIGILL, sigill_handler); + if (setjmp(__lv_powerpc_jmpbuf)) { +@@ -171,7 +192,7 @@ check_os_altivec_support(void) + util_cpu_caps.has_altivec = 0; + } + } +-#endif /* !PIPE_OS_APPLE */ ++#endif /* !PIPE_OS_APPLE && !PIPE_OS_LINUX */ + } + #endif /* PIPE_ARCH_PPC */ + diff --git a/srcpkgs/libGL/template b/srcpkgs/libGL/template index 23b4f47aae..3ee4258953 100644 --- a/srcpkgs/libGL/template +++ b/srcpkgs/libGL/template @@ -45,6 +45,11 @@ ppc*) configure_args+=" -Ddri-drivers=r100,r200,nouveau" configure_args+=" -Dvulkan-drivers=amd" configure_args+=" -Ddri3=true" + # Explicitly control power8 feature usage, disable on BE + case "$XBPS_TARGET_MACHINE" in + ppc64le*) configure_args+=" -Dpower8=true";; + *) configure_args+=" -Dpower8=false";; + esac hostmakedepends+=" clang" subpackages+=" mesa-ati-dri mesa-nouveau-dri" ;;