[bug#60934,CORE-UPDATES] gnu: mesa: Use smaller llvm backend.
Commit Message
* gnu/packages/gl.scm (mesa)[inputs]: Replace llvm with llvm-for-mesa.
* gnu/packages/llvm.scm (llvm-for-mesa): New variable.
---
I wasn't able to tweak this to be able to build a cross compiled mesa. I
was able to build and run glxgears on core-updates with this patch
applied.
gnu/packages/gl.scm | 5 ++---
gnu/packages/llvm.scm | 49 ++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 50 insertions(+), 4 deletions(-)
base-commit: b8d684af76a41f5856b73640eb6f21940f214497
prerequisite-patch-id: 32cb914a2879991546162c9c87e371e7faf56c27
prerequisite-patch-id: 322468b8512360f3addd2e9788a3b53166fc3997
prerequisite-patch-id: 7b9e82394c1c3b8f7cb04ed14c6c17e7e6a19020
Comments
Hi Efraim,
On Wed, Jan 18, 2023 at 04:49 PM, Efraim Flashner wrote:
> * gnu/packages/gl.scm (mesa)[inputs]: Replace llvm with llvm-for-mesa.
> * gnu/packages/llvm.scm (llvm-for-mesa): New variable.
> ---
>
> I wasn't able to tweak this to be able to build a cross compiled mesa. I
> was able to build and run glxgears on core-updates with this patch
> applied.
>
Nice!
Not sure if you already saw my message on guix-devel
https://lists.gnu.org/r/guix-devel/2023-01/msg00218.html but I'll just
repeat the summary: looks like latest mesa wants latest llvm (llvm-15 to
be exact) for current hardware support. I think this is the summary:
https://www.phoronix.com/news/LLVM-15-Branched
Have you tried with other versions of llvm?
I haven't checked what version of mesa is in core-updates or any pending
patches, but I can send an update to the latest version if needed.
I also haven't reviewed/tested this patch, but I do use current mesa via
another channel where I could try it out with this modification for
testing and get back to you.
Thanks for working on this!
John
On Thu, Jan 19, 2023 at 03:14:46AM +0000, John Kehayias wrote:
> Hi Efraim,
>
> On Wed, Jan 18, 2023 at 04:49 PM, Efraim Flashner wrote:
>
> > * gnu/packages/gl.scm (mesa)[inputs]: Replace llvm with llvm-for-mesa.
> > * gnu/packages/llvm.scm (llvm-for-mesa): New variable.
> > ---
> >
> > I wasn't able to tweak this to be able to build a cross compiled mesa. I
> > was able to build and run glxgears on core-updates with this patch
> > applied.
> >
>
> Nice!
>
> Not sure if you already saw my message on guix-devel
> https://lists.gnu.org/r/guix-devel/2023-01/msg00218.html but I'll just
> repeat the summary: looks like latest mesa wants latest llvm (llvm-15 to
> be exact) for current hardware support. I think this is the summary:
> https://www.phoronix.com/news/LLVM-15-Branched
>
> Have you tried with other versions of llvm?
>
> I haven't checked what version of mesa is in core-updates or any pending
> patches, but I can send an update to the latest version if needed.
>
> I also haven't reviewed/tested this patch, but I do use current mesa via
> another channel where I could try it out with this modification for
> testing and get back to you.
>
> Thanks for working on this!
> John
I was going to start with llvm-15 but currently core-updates only has up
to llvm-14 and mesa is currently built there with llvm-13, so that's
what I used. I also ran into a number of cross compiling issues while
trying to test cross compiling on core-updates so I think I'll try
working it on master so it can be more easily tested, and then when it's
good I'll commit it to core-updates. I'll also see about a
master->core-updates merge.
For the next version of the patch I think I'll copy the static libraries
to a static output instead of deleting them. I'm not sure exactly where
they'd be used, but at least in a different output they won't add to the
closure size if we need them and they're available if needed.
I've rebased the patch on top of master which should make testing it
easier. I tested it with glxgears from mesa-utils.
The first patch is just the patch backported.
The second patch makes some small adjustments so that the version of
mesa in master can be built with llvm-for-mesa.
When the patch is ready for inclusion we have a choice between merging
master into core-updates and then applying it, so we can keep llvm-15 as
base-llvm, or I can commit it to master with a TODO that it should
replace the llvm input in mesa in core-updates.
Efraim Flashner (2):
gnu: Add llvm-for-mesa.
HELPER PATCH
gnu/packages/gl.scm | 2 +-
gnu/packages/llvm.scm | 53 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 1 deletion(-)
base-commit: 26bb41d6d503a62e86b853774f6d8313abef2123
@@ -5,7 +5,7 @@
;;; Copyright © 2014, 2015, 2016, 2017 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Nikita <nikita@n0.is>
;;; Copyright © 2016, 2017, 2018, 2020, 2021 Ricardo Wurmus <rekado@elephly.net>
-;;; Copyright © 2017, 2018, 2019, 2021 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2017-2019, 2021, 2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
@@ -298,8 +298,7 @@ (define-public mesa
libxml2
libxrandr
libxvmc
- ;; Note: update the 'clang' input of mesa-opencl when bumping this.
- llvm
+ llvm-for-mesa
wayland
wayland-protocols))
(native-inputs
@@ -7,7 +7,7 @@
;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
;;; Copyright © 2018–2022 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
-;;; Copyright © 2018, 2021, 2022 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2018, 2021-2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
;;; Copyright © 2019 Rutger Helling <rhelling@mykolab.com>
@@ -1886,6 +1886,53 @@ (define-public emacs-clang-rename
;;; LLVM variants.
;;;
+(define-public llvm-for-mesa
+ ;; Note: update the 'clang' input of mesa-opencl when bumping this.
+ (let ((base-llvm llvm-13))
+ (package
+ (inherit base-llvm)
+ ;; If we can separate out the include directory we'd save another 23MB.
+ (outputs (list "out"))
+ (version (package-version base-llvm))
+ (arguments
+ (substitute-keyword-arguments (package-arguments base-llvm)
+ ((#:configure-flags _ ''())
+ #~(list
+ ;; AMDGPU is needed by the vulkan drivers.
+ #$(string-append "-DLLVM_TARGETS_TO_BUILD="
+ (system->llvm-target) ";AMDGPU")
+ "-DLLVM_BUILD_TOOLS=NO"
+ "-DLLVM_BUILD_LLVM_DYLIB=YES"
+ "-DLLVM_LINK_LLVM_DYLIB=YES"
+ "-DLLVM_ENABLE_RTTI:BOOL=TRUE"))
+ ((#:phases phases '%standard-phases)
+ #~(modify-phases #$phases
+ (add-after 'install 'delete-static-libraries
+ (lambda* (#:key outputs #:allow-other-keys)
+ (for-each delete-file
+ (find-files (string-append
+ (assoc-ref outputs "out") "/lib")
+ "\\.a$"))))
+ ;; We don't need it for this version.
+ (replace 'install-opt-viewer
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (delete-file-recursively
+ (string-append out "/share/opt-viewer")))))
+ (add-after 'install 'build-and-install-llvm-config
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (substitute*
+ "tools/llvm-config/CMakeFiles/llvm-config.dir/link.txt"
+ (((string-append "/tmp/guix-build-llvm-"
+ #$version ".drv-0/build/lib"))
+ (string-append out "/lib")))
+ (invoke "make" "llvm-config")
+ (install-file "bin/llvm-config"
+ (string-append out "/bin")))))))))
+ (properties `((hidden? . #t)
+ ,@(package-properties base-llvm))))))
+
(define make-ocaml-llvm
;; Make it a memoizing procedure so its callers below don't end up defining
;; two equal-but-not-eq "ocaml-llvm" packages for the default LLVM.