summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Kehayias <john.kehayias@protonmail.com>2022-09-16 15:02:01 -0400
committerJohn Kehayias <john.kehayias@protonmail.com>2023-04-22 21:25:28 -0400
commitf9bd7e0f7f15a47fe0b7a57ad5ac65bee6929ae9 (patch)
tree76fc30924e2500cda78536d5f918448283e9bf1d
parent95ca791b446a641a3e9f8cfc1f6cf0e33ca290ab (diff)
nongnu: Add mesa-next.
* nongnu/packages/mesa.scm (libva-without-mesa): New variable. This is unchanged from Guix, but needed locally for mesa to build. (mesa-next): New variable. This is copied from mesa on the core-updates branch of Guix.
-rw-r--r--nongnu/packages/mesa.scm253
1 files changed, 253 insertions, 0 deletions
diff --git a/nongnu/packages/mesa.scm b/nongnu/packages/mesa.scm
index d012a21..d9eae46 100644
--- a/nongnu/packages/mesa.scm
+++ b/nongnu/packages/mesa.scm
@@ -54,3 +54,256 @@
(sha256
(base32
"1zr0hi7k5s7my4q9hyj6ryzg89zyjx24zbqfv3c5rcq9pl87gc00"))))))
+
+;; Copied from (gnu packages gl) without changes, neede for mesa.
+(define libva-without-mesa
+ ;; Delay to work around circular import problem.
+ (delay
+ (package
+ (inherit libva)
+ (name "libva-without-mesa")
+ (inputs (fold alist-delete (package-inputs libva)
+ '("mesa" "wayland")))
+ (arguments
+ (strip-keyword-arguments
+ '(#:make-flags)
+ (substitute-keyword-arguments (package-arguments libva)
+ ((#:configure-flags flags)
+ '(list "--disable-glx"))))))))
+
+;; Copied from (gnu packages gl) on the current core-updates branch. Due to
+;; the number of changes from master, easier to copy the whole definition than
+;; try to modify with an inherit. Once this has been merged to Guix's master
+;; branch, modify this to inherit with the latest source version.
+(define-public mesa-next
+ (package
+ (name "mesa")
+ (version "22.1.7")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (list (string-append "https://mesa.freedesktop.org/archive/"
+ "mesa-" version ".tar.xz")
+ (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
+ "mesa-" version ".tar.xz")
+ (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
+ version "/mesa-" version ".tar.xz")))
+ (sha256
+ (base32
+ "12ax6lmshc8aqzw5ca7ab7f7z64n9nyzci4r1s6y1l0iryr8x0ys"))))
+ (build-system meson-build-system)
+ (propagated-inputs
+ ;; The following are in the Requires.private field of gl.pc.
+ (list libdrm-next
+ libvdpau
+ libx11
+ libxdamage
+ libxfixes
+ libxshmfence
+ libxxf86vm
+ xorgproto))
+ (inputs
+ (list elfutils ;libelf required for r600 when using llvm
+ expat
+ (force libva-without-mesa)
+ libxml2
+ libxrandr
+ libxvmc
+ ;; Note: update the 'clang' input of mesa-opencl when bumping this.
+ llvm
+ wayland
+ wayland-protocols-next))
+ (native-inputs
+ (list bison
+ flex
+ gettext-minimal
+ glslang
+ pkg-config
+ python-libxml2 ;for OpenGL ES 1.1 and 2.0 support
+ python-mako
+ python-wrapper
+ (@ (gnu packages base) which)))
+ (outputs '("out" "bin"))
+ (arguments
+ `(#:configure-flags
+ '(,@(match (%current-system)
+ ("aarch64-linux"
+ ;; TODO: Fix svga driver for non-Intel architectures.
+ '("-Dgallium-drivers=etnaviv,freedreno,kmsro,lima,nouveau,\
+panfrost,r300,r600,swrast,tegra,v3d,vc4,virgl"))
+ ("armhf-linux"
+ ;; Freedreno FTBFS when built on a 64-bit machine.
+ '("-Dgallium-drivers=etnaviv,kmsro,lima,nouveau,panfrost,\
+r300,r600,swrast,tegra,v3d,vc4,virgl"))
+ ((or "powerpc64le-linux" "powerpc-linux" "riscv64-linux")
+ '("-Dgallium-drivers=nouveau,r300,r600,radeonsi,swrast,virgl"))
+ (_
+ '("-Dgallium-drivers=iris,nouveau,r300,r600,radeonsi,\
+svga,swrast,virgl")))
+ ;; Enable various optional features. TODO: opencl requires libclc,
+ ;; omx requires libomxil-bellagio
+ "-Dplatforms=x11,wayland"
+ "-Dglx=dri" ;Thread Local Storage, improves performance
+ ;; "-Dopencl=true"
+ ;; "-Domx=true"
+ "-Dosmesa=true"
+ "-Dgallium-xa=enabled"
+
+ ;; features required by wayland
+ "-Dgles2=enabled"
+ "-Dgbm=enabled"
+ "-Dshared-glapi=enabled"
+
+ ;; Explicitly enable Vulkan on some architectures.
+ ,@(match (%current-system)
+ ((or "i686-linux" "x86_64-linux")
+ '("-Dvulkan-drivers=intel,amd"))
+ ((or "powerpc64le-linux" "powerpc-linux")
+ '("-Dvulkan-drivers=amd,swrast"))
+ ("aarch64-linux"
+ '("-Dvulkan-drivers=freedreno,amd,broadcom,swrast"))
+ ("riscv64-linux"
+ '("-Dvulkan-drivers=amd,swrast"))
+ (_
+ '("-Dvulkan-drivers=auto")))
+
+ ;; Enable the Vulkan overlay layer on all architectures.
+ "-Dvulkan-layers=device-select,overlay"
+
+ ;; Also enable the tests.
+ "-Dbuild-tests=true"
+
+ "-Dllvm=enabled") ; default is x86/x86_64 only
+
+ ;; XXX: 'debugoptimized' causes LTO link failures on some drivers. The
+ ;; documentation recommends using 'release' for performance anyway.
+ #:build-type "release"
+
+ #:modules ((ice-9 match)
+ (srfi srfi-1)
+ (guix build utils)
+ (guix build meson-build-system))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'disable-failing-test
+ (lambda _
+ ;; Disable the intel vulkan (anv_state_pool) tests, as they may
+ ;; fail in a nondeterministic fashion (see:
+ ;; https://gitlab.freedesktop.org/mesa/mesa/-/issues/5446).
+ (substitute* "src/intel/vulkan/meson.build"
+ (("if with_tests")
+ "if false"))
+ ,@(match (%current-system)
+ ("riscv64-linux"
+ ;; According to the test logs the llvm JIT is not designed
+ ;; for this architecture and the llvmpipe tests all segfault.
+ ;; The same is true for mesa:gallium / osmesa-render.
+ `((substitute* '("src/gallium/drivers/llvmpipe/meson.build"
+ "src/gallium/targets/osmesa/meson.build")
+ (("if with_tests") "if false"))))
+ ("powerpc64le-linux"
+ ;; Disable some of the llvmpipe tests.
+ `((substitute* "src/gallium/drivers/llvmpipe/lp_test_arit.c"
+ (("0\\.5, ") ""))))
+ ("powerpc-linux"
+ ;; There are some tests which fail specifically on powerpc.
+ `((substitute* '(;; LLVM ERROR: Relocation type not implemented yet!
+ "src/gallium/drivers/llvmpipe/meson.build"
+ ;; This is probably a big-endian test failure.
+ "src/gallium/targets/osmesa/meson.build")
+ (("if with_tests") "if not with_tests"))
+ (substitute* "src/util/tests/format/meson.build"
+ ;; This is definately an endian-ness test failure.
+ (("'u_format_test', ") ""))
+ ;; It is only this portion of the test which fails.
+ (substitute* "src/mesa/main/tests/meson.build"
+ ((".*mesa_formats.*") ""))
+ ;; This test times out and receives SIGTERM.
+ (substitute* "src/amd/common/meson.build"
+ (("and not with_platform_windows") "and with_platform_windows"))))
+ ("i686-linux"
+ ;; This test is known to fail on i686 (see:
+ ;; https://gitlab.freedesktop.org/mesa/mesa/-/issues/4091).
+ `((substitute* "src/util/meson.build"
+ ((".*'tests/u_debug_stack_test.cpp',.*") ""))))
+ ("aarch64-linux"
+ ;; The ir3_disasm test segfaults.
+ ;; The simplest way to skip it is to run a different test instead.
+ `((substitute* "src/freedreno/ir3/meson.build"
+ (("disasm\\.c'") "delay.c',\n link_args: ld_args_build_id"))))
+ ("armhf-linux"
+ ;; Disable some of the llvmpipe tests.
+ `((substitute* "src/gallium/drivers/llvmpipe/meson.build"
+ (("'lp_test_arit', ") ""))))
+ (_
+ '((display "No tests to disable on this architecture.\n"))))))
+ (add-before 'configure 'fix-dlopen-libnames
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ ;; Remain agnostic to .so.X.Y.Z versions while doing
+ ;; the substitutions so we're future-safe.
+ (substitute* "src/glx/meson.build"
+ (("-DGL_LIB_NAME=\"lib@0@\\.so\\.@1@\"")
+ (string-append "-DGL_LIB_NAME=\"" out
+ "/lib/lib@0@.so.@1@\"")))
+ (substitute* "src/gbm/backends/dri/gbm_dri.c"
+ (("\"libglapi\\.so")
+ (string-append "\"" out "/lib/libglapi.so")))
+ (substitute* "src/gbm/main/backend.c"
+ ;; No need to patch the gbm_gallium_drm.so reference;
+ ;; it's never installed since Mesa removed its
+ ;; egl_gallium support.
+ (("\"gbm_dri\\.so")
+ (string-append "\"" out "/lib/dri/gbm_dri.so"))))))
+ (add-after 'install 'split-outputs
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out"))
+ (bin (assoc-ref outputs "bin")))
+ ;; Not all architectures have the Vulkan overlay control script.
+ (mkdir-p (string-append out "/bin"))
+ (call-with-output-file (string-append out "/bin/.empty")
+ (const #t))
+ (copy-recursively (string-append out "/bin")
+ (string-append bin "/bin"))
+ (delete-file-recursively (string-append out "/bin")))))
+ (add-after 'install 'symlinks-instead-of-hard-links
+ (lambda* (#:key outputs #:allow-other-keys)
+ ;; All the drivers and gallium targets create hard links upon
+ ;; installation (search for "hardlink each megadriver instance"
+ ;; in the makefiles). This is no good for us since we'd produce
+ ;; nars that contain several copies of these files. Thus, turn
+ ;; them into symlinks, which saves ~124 MiB.
+ (let* ((out (assoc-ref outputs "out"))
+ (lib (string-append out "/lib"))
+ (files (find-files lib
+ (lambda (file stat)
+ (and (string-contains file ".so")
+ (eq? 'regular
+ (stat:type stat))))))
+ (inodes (map (compose stat:ino stat) files)))
+ (for-each (lambda (inode)
+ (match (filter-map (match-lambda
+ ((file ino)
+ (and (= ino inode) file)))
+ (zip files inodes))
+ ((_)
+ #f)
+ ((reference others ..1)
+ (format #t "creating ~a symlinks to '~a'~%"
+ (length others) reference)
+ (for-each delete-file others)
+ (for-each (lambda (file)
+ (if (string=? (dirname file)
+ (dirname reference))
+ (symlink (basename reference)
+ file)
+ (symlink reference file)))
+ others))))
+ (delete-duplicates inodes))))))))
+ (home-page "https://mesa3d.org/")
+ (synopsis "OpenGL and Vulkan implementations")
+ (description "Mesa is a free implementation of the OpenGL and Vulkan
+specifications - systems for rendering interactive 3D graphics. A variety of
+device drivers allows Mesa to be used in many different environments ranging
+from software emulation to complete hardware acceleration for modern GPUs.")
+ (license license:x11)))