unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#49717] [PATCH] gnu: mesa-opencl-icd: Use absolute path for the library.
@ 2021-07-24 10:01 Ivan Gankevich
  2021-07-27 16:40 ` bug#49717: " Guillaume Le Vaillant
  0 siblings, 1 reply; 2+ messages in thread
From: Ivan Gankevich @ 2021-07-24 10:01 UTC (permalink / raw)
  To: 49717; +Cc: Ivan Gankevich

* gnu/packages/gl.scm (mesa-opencl-icd): Use absolute path for OpenCL
  platform library in "mesa.icd" file.  With this patch setting
  LD_LIBRARY_PATH=$LIBRARY_PATH is no longer needed to run OpenCL
  applications.
---
 gnu/packages/gl.scm | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/gl.scm b/gnu/packages/gl.scm
index c14e7c0d53..f693efb36b 100644
--- a/gnu/packages/gl.scm
+++ b/gnu/packages/gl.scm
@@ -475,10 +475,26 @@ from software emulation to complete hardware acceleration for modern GPUs.")
   (package/inherit mesa-opencl
     (name "mesa-opencl-icd")
     (arguments
-     (substitute-keyword-arguments (package-arguments mesa)
-       ((#:configure-flags flags)
-        `(cons "-Dgallium-opencl=icd"
-               ,(delete "-Dgallium-opencl=standalone" flags)))))))
+      (substitute-keyword-arguments (package-arguments mesa)
+        ((#:configure-flags flags)
+         `(cons "-Dgallium-opencl=icd"
+                ,(delete "-Dgallium-opencl=standalone" flags)))
+        ((#:phases phases)
+         `(modify-phases ,phases
+            (add-after 'install 'mesa-icd-absolute-path
+              (lambda _
+                ;; Use absolute path for OpenCL platform library.
+                ;; Otherwise we would have to set LD_LIBRARY_PATH=LIBRARY_PATH
+                ;; for ICD in our applications to find OpenCL platform.
+                (use-modules (guix build utils)
+                             (ice-9 textual-ports))
+                (let* ((out (assoc-ref %outputs "out"))
+                       (mesa-icd (string-append out "/etc/OpenCL/vendors/mesa.icd"))
+                       (old-path (call-with-input-file mesa-icd get-string-all))
+                       (new-path (string-append out "/lib/" (string-trim-both old-path))))
+                  (if (file-exists? new-path)
+                    (call-with-output-file mesa-icd
+                      (lambda (port) (format port "~a\n" new-path)))))))))))))
 
 (define-public mesa-headers
   (package/inherit mesa
-- 
2.32.0





^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#49717: [PATCH] gnu: mesa-opencl-icd: Use absolute path for the library.
  2021-07-24 10:01 [bug#49717] [PATCH] gnu: mesa-opencl-icd: Use absolute path for the library Ivan Gankevich
@ 2021-07-27 16:40 ` Guillaume Le Vaillant
  0 siblings, 0 replies; 2+ messages in thread
From: Guillaume Le Vaillant @ 2021-07-27 16:40 UTC (permalink / raw)
  To: Ivan Gankevich; +Cc: 49717-done

[-- Attachment #1: Type: text/plain, Size: 99 bytes --]

I added a copyright line and pushed the patch as
8cfd9ef831caff790c837eca87b1164801459108.
Thanks.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-27 16:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-24 10:01 [bug#49717] [PATCH] gnu: mesa-opencl-icd: Use absolute path for the library Ivan Gankevich
2021-07-27 16:40 ` bug#49717: " Guillaume Le Vaillant

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).