unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: The Man <squishypinkelephant@gmail.com>
To: 74522@debbugs.gnu.org
Cc: The Man <squishypinkelephant@gmail.com>
Subject: [bug#74522] [PATCH 73/73] move libgl provider from mesa to libglvnd+mesa
Date: Sun, 24 Nov 2024 21:42:06 -0600	[thread overview]
Message-ID: <0e0d3ed8749aea7e1052058481bfc429c60d951b.1732504868.git.squishypinkelephant@gmail.com> (raw)
In-Reply-To: <cover.1732504867.git.squishypinkelephant@gmail.com>

Change-Id: I3e9235f3d9755058462679ebd63de0484384d184
---
 gnu/packages/gl.scm | 155 ++++++++++++++++++++++++++++++++++----------
 1 file changed, 122 insertions(+), 33 deletions(-)

diff --git a/gnu/packages/gl.scm b/gnu/packages/gl.scm
index 0a285dfc30..81803519de 100644
--- a/gnu/packages/gl.scm
+++ b/gnu/packages/gl.scm
@@ -74,6 +74,7 @@ (define-module (gnu packages gl)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system meson)
   #:use-module (guix build-system python)
+  #:use-module (guix build-system trivial)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix gexp)
@@ -102,7 +103,7 @@ (define-public glu
            automake
            libtool))
     (propagated-inputs
-     (list mesa)) ; according to glu.pc
+     (list libgl)) ; according to glu.pc
     (home-page "http://www.opengl.org/archives/resources/faq/technical/glu.htm")
     (synopsis "Mesa OpenGL Utility library")
     (description
@@ -137,7 +138,7 @@ (define-public freeglut
     (inputs (list libx11 libxi libxrandr libxxf86vm))
     (propagated-inputs
      ;; Headers from Mesa and GLU are needed.
-     (list glu mesa))
+     (list glu libgl))
     (home-page "https://freeglut.sourceforge.net/")
     (synopsis "Alternative to the OpenGL Utility Toolkit (GLUT)")
     (description
@@ -189,7 +190,7 @@ (define-public ftgl
      `(#:configure-flags '("--disable-static")))
     ;; The pkg-config file lists "freetype2" as Requires.private.
     (propagated-inputs (list freetype))
-    (inputs (list libx11 mesa glu))
+    (inputs (list libx11 libgl glu))
     (native-inputs
      (list pkg-config autoconf automake libtool))
     (synopsis "Font rendering library for OpenGL applications")
@@ -292,7 +293,7 @@ (define libva-without-mesa
       (inherit libva)
       (name "libva-without-mesa")
       (inputs (fold alist-delete (package-inputs libva)
-                    '("mesa" "wayland")))
+                    '("libgl" "wayland")))
       (arguments
        (strip-keyword-arguments
         '(#:make-flags)
@@ -329,6 +330,7 @@ (define-public mesa
      (list elfutils                   ;libelf required for r600 when using llvm
            expat
            (force libva-without-mesa)
+           libglvnd-headers
            libxml2
            libxrandr
            libxvmc
@@ -398,6 +400,8 @@ (define-public mesa
          ;; "-Domx=true"
          "-Dosmesa=true"
          "-Dgallium-xa=enabled"
+         ;; libglvnd support
+         "-Dglvnd=true"
 
          ;; features required by wayland
          "-Dgles2=enabled"
@@ -634,7 +638,14 @@ (define-public mesa
                            (((string-append "\"lib" layer-name ".so\""))
                              (string-append "\"" out "/lib/lib" layer-name ".so\"")))))))
                (for-each fix-layer-path '("VkLayer_MESA_device_select"
-                                          "VkLayer_MESA_overlay"))))))))
+                                          "VkLayer_MESA_overlay")))))
+         (add-after 'install 'fix-egl-vendor-path
+           (lambda _
+             (substitute*
+               (string-append #$output
+                 "/share/glvnd/egl_vendor.d/50_mesa.json")
+               (("libEGL_mesa")
+                 (string-append #$output "/lib/libEGL_mesa"))))))))
     (native-search-paths
      (list (search-path-specification
             ;; Ensure the Mesa VDPAU drivers can be found.
@@ -721,7 +732,7 @@ (define-public mesa-utils
     (source (mesa-demos-source version))
     (build-system gnu-build-system)
     (inputs
-     (list mesa freeglut glew))
+     (list libgl freeglut glew))
     (native-inputs
      (list pkg-config))
     (arguments
@@ -782,7 +793,7 @@ (define-public glew
                    (delete-file (string-append #$output "/lib/libGLEW.a")))))
            #:tests? #f))                ;no 'check' target
     (inputs
-     (list libxi libxmu libx11 mesa))
+     (list libxi libxmu libx11 libgl))
 
     ;; <GL/glew.h> includes <GL/glu.h>.
     (propagated-inputs (list glu))
@@ -809,7 +820,7 @@ (define-public guile-opengl
                "0rbc2wf9x63ilj3n85h8wyllzc2b22abmhs2p2ghjgc253n8gw5q"))))
     (build-system gnu-build-system)
     (native-inputs (list pkg-config))
-    (inputs (list guile-2.2 mesa glu freeglut))
+    (inputs (list guile-2.2 libgl glu freeglut))
     (arguments
      '(#:phases (modify-phases %standard-phases
                  (add-before 'build 'patch-dynamic-link
@@ -817,7 +828,7 @@ (define-public guile-opengl
                      (substitute* "gl/runtime.scm"
                        (("\\(dynamic-link\\)")
                         (string-append "(dynamic-link \""
-                                       (assoc-ref inputs "mesa")
+                                       (assoc-ref inputs "libgl")
                                        "/lib/libGL.so" "\")")))
                      (define (dynamic-link-substitute file lib input)
                        (substitute* file
@@ -827,7 +838,7 @@ (define-public guile-opengl
                                          "/lib/lib" lib "\""))))
                      ;; Replace dynamic-link calls for libGL, libGLU, and
                      ;; libglut with absolute paths to the store.
-                     (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
+                     (dynamic-link-substitute "glx/runtime.scm" "GL" "libgl")
                      (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
                      (dynamic-link-substitute "glut/runtime.scm" "glut"
                                               "freeglut"))))))
@@ -843,7 +854,7 @@ (define-public guile3.0-opengl
     (inherit guile-opengl)
     (name "guile3.0-opengl")
     (inputs
-     (list guile-3.0 mesa glu freeglut))))
+     (list guile-3.0 libgl glu freeglut))))
 
 (define-public libepoxy
   (package
@@ -863,20 +874,20 @@ (define-public libepoxy
       #~(modify-phases %standard-phases
           (add-before 'configure 'patch-paths
             (lambda* (#:key inputs #:allow-other-keys)
-              (let ((mesa-lib
+              (let ((libgl-lib
                      (lambda (file)
                        (search-input-file inputs (string-append "lib/" file)))))
                 (substitute* (find-files "." "\\.[ch]$")
-                  (("libGL.so.1") (mesa-lib "libGL.so.1"))
-                  (("libEGL.so.1") (mesa-lib "libEGL.so.1"))
-                  (("libGLESv1_CM.so.1") (mesa-lib "libGLESv1_CM.so.1"))
-                  (("libGLESv2.so.2") (mesa-lib "libGLESv2.so.2")))))))))
+                  (("libGL.so.1") (libgl-lib "libGL.so.1"))
+                  (("libEGL.so.1") (libgl-lib "libEGL.so.1"))
+                  (("libGLESv1_CM.so.1") (libgl-lib "libGLESv1_CM.so.1"))
+                  (("libGLESv2.so.2") (libgl-lib "libGLESv2.so.2")))))))))
     (build-system meson-build-system)
     (native-inputs
      (list pkg-config python))
     (propagated-inputs
      ;; epoxy.pc: 'Requires.private: gl egl'
-     (list mesa))
+     (list libgl))
     (synopsis "Library for handling OpenGL function pointer management")
     (description
      "A library for handling OpenGL function pointer management.")
@@ -897,21 +908,46 @@ (define-public libglvnd
                (base32
                 "07v3bmwzmg0d4g2zp835v1g7j22j8vz7hjfmqrdqjgxjj6v4jkyr"))))
     (build-system meson-build-system)
-    (arguments
-     '(#:configure-flags '("-Dx11=enabled")
-       #:phases (modify-phases %standard-phases
+    (arguments (list
+      #:configure-flags #~(list
+        "-Dx11=enabled"
+        (string-append "-Dc_link_args=-Wl,-rpath=$ORIGIN:"
+        ;; or else runpath errors with libGLdispatch.so
+        #$(this-package-input "mesa") "/lib"))
+        ;; we also need mesa visibility at te very least
+      #:phases #~(modify-phases %standard-phases
                   (add-after 'unpack 'disable-glx-tests
                     (lambda _
-                      ;; This package is meant to be used alongside Mesa.
+                      ;; This package is meant to be used alongside mesonMesa.
                       ;; To avoid a circular dependency, disable tests that
                       ;; require a running Xorg server.
                       (substitute* "tests/meson.build"
                         (("if with_glx")
-                         "if false")))))))
+                         "if false"))))
+                  (delete 'shrink-runpath) ;; don't erase our hard work
+                  (add-after 'install 'add-external-egl
+                    (lambda _
+                      (mkdir-p (string-append #$output
+                        "/share/egl/egl_external_platform.d")))))))
     (native-inputs
      (list pkg-config))
+    (propagated-inputs
+     (list mesa))
     (inputs
      (list libx11 libxext xorgproto))
+    (native-search-paths (list
+      (search-path-specification
+        (variable "GBM_BACKENDS_PATH")
+        (files '("lib")))
+      (search-path-specification
+        (variable "XDG_DATA_DIRS")
+        (files '("share")))
+      (search-path-specification
+        (variable "__EGL_EXTERNAL_PLATFORM_CONFIG_DIRS")
+        (files '("share/egl/egl_external_platform.d")))
+      (search-path-specification
+        (variable "__EGL_VENDOR_LIBRARY_DIRS")
+        (files '("share/glvnd/egl_vendor.d")))))
     (synopsis "Vendor-neutral OpenGL dispatch library")
     (description
      "libglvnd is a vendor-neutral dispatch layer for arbitrating OpenGL
@@ -926,6 +962,59 @@ (define-public libglvnd
                    license:x11
                    license:expat))))
 
+;; only mesa will use this, keep things small and simple
+(define libglvnd-headers
+  (package
+    (inherit libglvnd)
+    (arguments (list
+      #:phases
+      #~(modify-phases %standard-phases
+        (delete 'configure)
+        (delete 'build)
+        (delete 'check)
+        (replace 'install
+          (lambda* (#:key outputs #:allow-other-keys)
+            (let* ((out (assoc-ref outputs "out"))
+                   (include (string-append out "/include"))
+                   (pkgconfig (string-append out "/lib/pkgconfig")))
+              (copy-recursively "include" include)
+              ;; clean up junk
+              (delete-file (string-append include "/Makefile.am"))
+              (delete-file (string-append include "/meson.build"))
+              (mkdir-p pkgconfig)
+              ;; generate the only .pc file needed to build mesa
+              (call-with-output-file (string-append pkgconfig "/libglvnd.pc")
+                (lambda (port)
+                  (format port "prefix=~a
+includedir=${prefix}/include
+
+datarootdir=${prefix}/share
+datadir=${prefix}/share
+
+Name: libglvnd
+Description: Vendor-neutral OpenGL dispatch library vendor interface
+Version: ~a
+Cflags: -I${includedir}" out #$(package-version this-package))))))))))
+    (native-inputs '())
+    (propagated-inputs '())
+    (inputs '())))
+
+(define-public libgl
+  (package/inherit libglvnd ;; can't be a literal empty shell or nothing will build
+    (name "libgl")
+    (version "glvnd")
+    (inputs '())
+    (native-inputs '())
+    (propagated-inputs (list libglvnd))
+    (build-system trivial-build-system)
+    (arguments
+      (list #:modules '((guix build union))
+        #:builder #~(begin (use-modules (guix build union))
+          (union-build #$output '#$(list libglvnd)))))
+    (synopsis "LibGL package")
+    (description
+     "LibGL package")))
+
 (define-public libopenglrecorder
   (package
     (name "libopenglrecorder")
@@ -986,7 +1075,7 @@ (define-public soil
     (native-inputs
      (list unzip))
     (inputs
-     (list mesa))
+     (list libgl))
     (home-page "https://www.lonesock.net/soil.html")
     (synopsis "OpenGL texture loading library")
     (description
@@ -1052,7 +1141,7 @@ (define-public glfw
     (native-inputs (list doxygen unzip))
     (inputs (list libxkbcommon wayland vulkan-loader))
     (propagated-inputs
-     (list mesa              ;included in public headers
+     (list libgl              ;included in public headers
            ;; These are in 'Requires.private' of 'glfw3.pc'.
            libx11
            libxrandr
@@ -1107,7 +1196,7 @@ (define-public nanovg-for-extempore
       (build-system cmake-build-system)
       (arguments `(#:tests? #f))        ; no tests included
       (inputs
-       (list mesa))
+       (list libgl))
       ;; Extempore refuses to build on architectures other than x86_64
       (supported-systems '("x86_64-linux"))
       (home-page "https://github.com/extemporelang/nanovg")
@@ -1132,7 +1221,7 @@ (define-public gl2ps
         (base32 "1sgzv547h7hrskb9qd0x5yp45kmhvibjwj2mfswv95lg070h074d"))))
     (build-system cmake-build-system)
     (inputs
-     (list libpng mesa zlib))
+     (list libpng libgl zlib))
     (arguments
      `(#:tests? #f))                    ; no tests
     (home-page "https://www.geuz.org/gl2ps/")
@@ -1168,7 +1257,7 @@ (define-public virtualgl
                                          (assoc-ref %outputs "out") "/lib")
                           "-DVGL_USESSL=1"))) ; use OpenSSL
     (build-system cmake-build-system)
-    (inputs (list glu libjpeg-turbo libxtst mesa openssl))
+    (inputs (list glu libjpeg-turbo libxtst libgl openssl))
     (native-inputs (list pkg-config))
     (home-page "https://www.virtualgl.org")
     (synopsis "Redirects 3D commands from an OpenGL application onto a 3D
@@ -1283,11 +1372,11 @@ (define-public glmark2
        (modify-phases %standard-phases
          (add-after 'unpack 'patch-paths
            (lambda* (#:key inputs #:allow-other-keys)
-             (let ((mesa (assoc-ref inputs "mesa")))
+             (let ((libgl (assoc-ref inputs "libgl")))
                (substitute* (find-files "src" "gl-state-.*\\.cpp$")
-                 (("libGL.so") (string-append mesa "/lib/libGL.so"))
-                 (("libEGL.so") (string-append mesa "/lib/libEGL.so"))
-                 (("libGLESv2.so") (string-append mesa "/lib/libGLESv2.so")))
+                 (("libGL.so") (string-append libgl "/lib/libGL.so"))
+                 (("libEGL.so") (string-append libgl "/lib/libEGL.so"))
+                 (("libGLESv2.so") (string-append libgl "/lib/libGLESv2.so")))
                #t))))))
     (native-inputs
      (list pkg-config))
@@ -1298,7 +1387,7 @@ (define-public glmark2
            libpng
            libx11
            libxcb
-           mesa
+           libgl
            wayland
            wayland-protocols))
     (home-page "https://github.com/glmark2/glmark2")
@@ -1329,7 +1418,7 @@ (define-public waffle
                                            (delete-file-recursively f)))
                                        (scandir ".")))))))
     (build-system meson-build-system)
-    (propagated-inputs (list mesa wayland))
+    (propagated-inputs (list libgl wayland))
     (native-inputs (list cmocka pkg-config))
     (home-page "https://waffle.freedesktop.org/")
     (synopsis "Choose OpenGL API at runtime")
-- 
2.46.0





      parent reply	other threads:[~2024-11-25  4:13 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-25  3:38 [bug#74522] [PATCH 00/73] Moving Guix to libglvnd The Man
2024-11-25  3:40 ` [bug#74522] [PATCH 01/73] move libgl provider from mesa to libglvnd+mesa The Man
2024-11-25  3:40 ` [bug#74522] [PATCH 02/73] " The Man
2024-11-25  3:40 ` [bug#74522] [PATCH 03/73] " The Man
2024-11-25  3:40 ` [bug#74522] [PATCH 04/73] " The Man
2024-11-25  3:40 ` [bug#74522] [PATCH 05/73] " The Man
2024-11-25  3:40 ` [bug#74522] [PATCH 06/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 07/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 08/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 09/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 10/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 11/73] " The Man
2024-11-25  5:18   ` Liliana Marie Prikler
2024-11-25  3:41 ` [bug#74522] [PATCH 12/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 13/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 14/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 15/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 16/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 17/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 18/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 19/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 20/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 21/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 22/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 23/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 24/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 25/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 26/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 27/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 28/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 29/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 30/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 31/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 32/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 33/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 34/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 35/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 36/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 37/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 38/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 39/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 40/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 41/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 42/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 43/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 44/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 45/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 46/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 47/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 48/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 49/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 50/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 51/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 52/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 53/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 54/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 55/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 56/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 57/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 58/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 59/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 60/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 61/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 62/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 63/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 64/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 65/73] " The Man
2024-11-25  3:41 ` [bug#74522] [PATCH 66/73] " The Man
2024-11-25  3:42 ` [bug#74522] [PATCH 67/73] " The Man
2024-11-25  3:42 ` [bug#74522] [PATCH 68/73] " The Man
2024-11-25  3:42 ` [bug#74522] [PATCH 69/73] " The Man
2024-11-25  3:42 ` [bug#74522] [PATCH 70/73] " The Man
2024-11-25  3:42 ` [bug#74522] [PATCH 71/73] " The Man
2024-11-25  3:42 ` [bug#74522] [PATCH 72/73] move libgl provider from mesa to libglvnd+mesa TEMP The Man
2024-11-25  3:42 ` The Man [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0e0d3ed8749aea7e1052058481bfc429c60d951b.1732504868.git.squishypinkelephant@gmail.com \
    --to=squishypinkelephant@gmail.com \
    --cc=74522@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).