Mentions légales du service

Skip to content
Snippets Groups Projects

intel-oneapi-mkl : we now change rpath using patchelf

Closed Marko requested to merge sed-bso/guix-hpc-non-free-ene-konponketak:master into master
All threads resolved!
+ 86
68
@@ -17,6 +17,7 @@
#:use-module (gnu packages base)
#:use-module (gnu packages cpio)
#:use-module (gnu packages tbb)
#:use-module (gnu packages bootstrap)
#:use-module (gnu packages sycl)
#:use-module (gnu packages compression)
#:use-module (gnu packages elf)
@@ -54,9 +55,7 @@
(let* ((command (string-append "rpm2cpio "
rpm
" | cpio -i"))
(status (system command)))
(unless (zero? status)
(error (format #f
"command '~a' failed with ~a"
@@ -73,7 +72,7 @@
(libdir (string-append out "/lib"))
(includedir (string-append out "/include"))
(linktool (string-append bindir "/mkl_link_tool")))
;; Install libraries. Don't install .a files: that saves
;; ~1 GB and presumably nobody cares.
(for-each (lambda (lib)
@@ -104,8 +103,7 @@
;; Let's not publish or obtain substitutes for that.
#:substitutable? #f))
(native-inputs (list tar gzip cpio rpm patchelf))
(inputs (list `(,(canonical-package gcc) "lib")))
(inputs `(("gcc:lib" ,gcc "lib")))
;; 32-bit libraries are not installed.
(supported-systems '("x86_64-linux"))
@@ -163,7 +161,13 @@ reference a C interface.")
(base32 sha))))
(build-system gnu-build-system)
(arguments
`(#:phases (modify-phases %standard-phases
`(
;; Let's not publish or obtain substitutes for that.
#:substitutable? #f
;; XXX: This would check DT_RUNPATH, but patchelf populate DT_RPATH,
;; not DT_RUNPATH.
#:validate-runpath? #f
#:phases (modify-phases %standard-phases
(delete 'configure)
(delete 'check)
(delete 'build)
@@ -171,75 +175,89 @@ reference a C interface.")
(lambda _
;; extract all the debian packages to opt/intel
(for-each (lambda (deb)
(format #t "extracting ~a...~%" deb)
(let* ((command (string-append "ar x " deb
" && tar xf data.tar.xz && rm data.tar.xz"))
(status (system command)))
(unless (zero? status)
(error (format #f
"command '~a' failed with ~a"
(format #t "extracting ~a...~%" deb)
(let* ((command (string-append "ar x " deb
" && tar xf data.tar.xz && rm data.tar.xz"))
(status (system command)))
(unless (zero? status)
(error (format #f
"command '~a' failed with ~a"
command status)))))
(find-files "." "\\.deb$"))))
(delete 'validate-runpath)
(replace 'install
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(source-prefix (string-append
"opt/intel/oneapi/mkl/"
,(package-version this-package)))
(libdir (string-append out "/lib"))
(bindir (string-append out "/bin"))
(linktool (string-append bindir
"/intel64/mkl_link_tool"))
(includedir (string-append out "/include")))
(for-each (lambda (lib)
(install-file lib libdir))
(filter (lambda (x)
(not (or (string-contains x "tbb")
(string-contains x "sycl")))) ;FIXME : probleme with sycl and tbb
(define out
(assoc-ref outputs "out"))
(define libc
(assoc-ref inputs "libc"))
(define gcc-lib
(assoc-ref inputs "gcc:lib"))
(define source-prefix
(string-append "opt/intel/oneapi/mkl/"
,(package-version this-package)))
(define source-inc
(string-append source-prefix "/include"))
(define source-bin
(string-append source-prefix "/bin"))
(define source-cmake
(string-append source-prefix "/lib/cmake"))
(define libdir
(string-append out "/lib"))
(define bindir
(string-append out "/bin"))
(define ld.so
(string-append libc ,(glibc-dynamic-linker)))
(define linktool
(string-append bindir "/intel64/mkl_link_tool"))
(define includedir
(string-append out "/include"))
(define must-be-patched
(filter (lambda (x)
(not (or (string-contains x "tbb") ;current link problems
(string-contains x "sycl"))))
(find-files (string-append
source-prefix
"/lib/intel64")
"\\.so$")))
(for-each (lambda (lib)
(symlink lib
(string-append lib ".2"))) ;FIXME : dirty hack for symbolic link
(find-files libdir "\\.so$"))
(for-each (lambda (lib)
(let ((libspec (string-append
source-prefix
"/lib/intel64/libmkl_" lib
".so.2")))
(if (file-exists? libspec) ;some so.2 are not symbolic links
(install-file libspec libdir))))
(list "avx" "avx2" "avx512" "def"))
(if (directory-exists? (string-append source-prefix
"/include"))
(copy-recursively (string-append source-prefix
"/include")
includedir))
(if (directory-exists? (string-append source-prefix
"/bin"))
(copy-recursively (string-append source-prefix
"/bin") bindir))
(if (directory-exists? (string-append source-prefix
"/lib/cmake"))
(copy-recursively (string-append source-prefix
"/lib/cmake/")
(string-append libdir "/cmake")))
(when (file-exists? linktool)
(invoke "patchelf" linktool "--set-rpath"
(string-join (list (dirname (search-input-file
inputs
"/lib/libgcc_s.so"))
(dirname (search-input-file
inputs
"/lib/libstdc++.so.6")))
":")))))))
;; Let's not publish or obtain substitutes for that.
#:substitutable? #f))))
"\\.so(\\..*)?$"))) ; take into account .so and .so.2
(define rpath
(string-join (list "$ORIGIN"
(string-append libc "/lib")
(string-append gcc-lib "/lib"))
":"))
(define (patch-elf file)
(make-file-writable file)
(unless (string-contains file ".so")
(format #t "Setting interpreter on '~a'...~%" file)
(invoke "patchelf" "--set-interpreter" ld.so
file))
(format #t "Setting RPATH on '~a'...~%" file)
(invoke "patchelf" "--set-rpath" rpath
"--force-rpath" file))
(for-each
(lambda (lib)
(when (and (elf-file? lib) (not (symbolic-link? lib)))
(patch-elf lib))) ;modify runpath
must-be-patched)
(for-each (lambda (lib) (install-file lib libdir)) ; and install
must-be-patched)
(when (directory-exists? source-inc)
(copy-recursively source-inc includedir))
(when (directory-exists? source-bin)
(copy-recursively source-bin bindir))
(when (directory-exists? source-cmake)
(copy-recursively source-cmake (string-append libdir "/cmake")))
(when (file-exists? linktool)
(invoke "patchelf" linktool "--set-rpath"
(string-join
(list (dirname (search-input-file
inputs
"/lib/libgcc_s.so"))
(dirname (search-input-file
inputs "/lib/libstdc++.so.6"))) ":")))
#t)))))))
(define-public intel-oneapi-mkl+main
(make-intel-oneapi-mkl "2023.2.0" "49495" "amd64" ""
Loading