GNU bug report logs - #49569
[PATCH] gnu: Add make-single-arch-llvm procedure.

Previous Next

Package: guix-patches;

Reported by: Efraim Flashner <efraim <at> flashner.co.il>

Date: Thu, 15 Jul 2021 10:07:01 UTC

Severity: normal

Tags: patch

Done: Efraim Flashner <efraim <at> flashner.co.il>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49569 in the body.
You can then email your comments to 49569 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#49569; Package guix-patches. (Thu, 15 Jul 2021 10:07:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Efraim Flashner <efraim <at> flashner.co.il>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 15 Jul 2021 10:07:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: guix-patches <at> gnu.org
Cc: Efraim Flashner <efraim <at> flashner.co.il>
Subject: [PATCH] gnu: Add make-single-arch-llvm procedure.
Date: Thu, 15 Jul 2021 13:04:52 +0300
* gnu/packages/llvm.scm (make-single-arch-llvm): New procedure.
(llvm-native-12, llvm-native): New variables.
---

Using this copy of llvm for packages like mesa will reduce the closure
of those packages. I don't suppose it would work as well for compilers
like rust which use LLVM for compiling and targeting different
architectures.

This drops the size of llvm-12 from 167M to 111M.

 gnu/packages/llvm.scm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 575c63c713..35cecdfd84 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1347,3 +1347,27 @@ LLVM."))))
 (define-public ocaml-llvm-9 (make-ocaml-llvm llvm-9))
 (define-public ocaml-llvm-10 (make-ocaml-llvm llvm-10))
 (define-public ocaml-llvm-11 (make-ocaml-llvm llvm-11))
+
+(define* (make-single-arch-llvm llvm #:optional (system (or (%current-target-system)
+                                                            (%current-system))))
+  (package
+    (inherit llvm)
+    (name (string-append "llvm-for-" (string-downcase
+                                       (system->llvm-target system))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments llvm)
+       ((#:configure-flags cf)
+        `(cons* ,(string-append "-DLLVM_TARGETS_TO_BUILD="
+                                (system->llvm-target system))
+                ,cf))))
+    (synopsis "Compiler with support for a single architecture")))
+
+(define-public llvm-native-12
+  (package
+    (inherit (make-single-arch-llvm llvm-12))
+    (name "llvm-native")))
+
+(define-public llvm-native
+  (package
+    (inherit (make-single-arch-llvm llvm))
+    (name "llvm-native")))

base-commit: 17c8fedc256406047c7a1e8317bc52641c621286
-- 
2.32.0





Information forwarded to guix-patches <at> gnu.org:
bug#49569; Package guix-patches. (Mon, 26 Jul 2021 16:48:02 GMT) Full text and rfc822 format available.

Message #8 received at 49569 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: 49569 <at> debbugs.gnu.org
Subject: Re: bug#49569: [PATCH] gnu: Add make-single-arch-llvm procedure.
Date: Mon, 26 Jul 2021 18:47:14 +0200
Hi,

Efraim Flashner <efraim <at> flashner.co.il> skribis:

> * gnu/packages/llvm.scm (make-single-arch-llvm): New procedure.
> (llvm-native-12, llvm-native): New variables.
> ---
>
> Using this copy of llvm for packages like mesa will reduce the closure
> of those packages. I don't suppose it would work as well for compilers
> like rust which use LLVM for compiling and targeting different
> architectures.
>
> This drops the size of llvm-12 from 167M to 111M.

That’s less impressive than I would have thought.

For Mesa perhaps we could maybe have a variant that’s even more
stripped?

The downside of this is that we risk having several LLVM copies on
typical installations.

Thoughts?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#49569; Package guix-patches. (Tue, 27 Jul 2021 12:31:02 GMT) Full text and rfc822 format available.

Message #11 received at 49569 <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 49569 <at> debbugs.gnu.org
Subject: Re: bug#49569: [PATCH] gnu: Add make-single-arch-llvm procedure.
Date: Tue, 27 Jul 2021 15:29:29 +0300
[Message part 1 (text/plain, inline)]
On Mon, Jul 26, 2021 at 06:47:14PM +0200, Ludovic Courtès wrote:
> Hi,
> 
> Efraim Flashner <efraim <at> flashner.co.il> skribis:
> 
> > * gnu/packages/llvm.scm (make-single-arch-llvm): New procedure.
> > (llvm-native-12, llvm-native): New variables.
> > ---
> >
> > Using this copy of llvm for packages like mesa will reduce the closure
> > of those packages. I don't suppose it would work as well for compilers
> > like rust which use LLVM for compiling and targeting different
> > architectures.
> >
> > This drops the size of llvm-12 from 167M to 111M.
> 
> That’s less impressive than I would have thought.
> 
> For Mesa perhaps we could maybe have a variant that’s even more
> stripped?
> 
> The downside of this is that we risk having several LLVM copies on
> typical installations.
> 
> Thoughts?
> 
> Thanks,
> Ludo’.

I think you're mostly shocked by the large numbers, it is a drop of 33%.

It turns out that llvm-julia uses something similar to only target one
arch, so the idea's there somewhere. We could probably add it in there
too for dlang. Icecat/icedove/mozjs-78 should be OK to switch. And
xf86-video-vmware already has mesa as an input and could likely use a
special llvm-for-mesa version.

I can look at mesa and see which libraries from llvm it links to and see
about just building those. A first look shows 50 llvm libraries from
mesa and about 150 from llvm <at> 11, with the 4 libraries being
libOSMesa  libvulkan_radeon  libxatracker  libXvMCnouveau


-- 
Efraim Flashner   <efraim <at> flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#49569; Package guix-patches. (Tue, 27 Jul 2021 13:10:01 GMT) Full text and rfc822 format available.

Message #14 received at 49569 <at> debbugs.gnu.org (full text, mbox):

From: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
To: 49569 <at> debbugs.gnu.org, Efraim Flashner <efraim <at> flashner.co.il>
Subject: Re: [bug#49569] [PATCH] gnu: Add make-single-arch-llvm procedure.
Date: Tue, 27 Jul 2021 10:09:19 -0300
Hello,

Em quinta-feira, 15 de julho de 2021, às 07:04:52 -03, Efraim Flashner
escreveu:
> * gnu/packages/llvm.scm (make-single-arch-llvm): New procedure.
> (llvm-native-12, llvm-native): New variables.
> ---
> 
> Using this copy of llvm for packages like mesa will reduce the closure
> of those packages. I don't suppose it would work as well for compilers
> like rust which use LLVM for compiling and targeting different
> architectures.
> 
> This drops the size of llvm-12 from 167M to 111M.

I don’t have an opinion on the issue that Ludo’ raised, just one comment
about the code below.

>  gnu/packages/llvm.scm | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
> index 575c63c713..35cecdfd84 100644
> --- a/gnu/packages/llvm.scm
> +++ b/gnu/packages/llvm.scm
> @@ -1347,3 +1347,27 @@ LLVM."))))
>  (define-public ocaml-llvm-9 (make-ocaml-llvm llvm-9))
>  (define-public ocaml-llvm-10 (make-ocaml-llvm llvm-10))
>  (define-public ocaml-llvm-11 (make-ocaml-llvm llvm-11))
> +
> +(define* (make-single-arch-llvm llvm #:optional (system (or (%current-target-system)
> +                                                            (%current-system))))
> +  (package
> +    (inherit llvm)
> +    (name (string-append "llvm-for-" (string-downcase
> +                                       (system->llvm-target system))))

‘system->llvm-target’ needs a Nix system identifier but
‘%current-target-system’ contains a GNU triplet, so the above won’t work
when cross-compiling for armhf-linux – whose GNU triplet is
“arm-unknown-linux-gnueabihf”.

I suggest changing the default value of ‘system’ to

    (or (and=> (%current-target-system) gnu-triplet->nix-system)
        (%current-system))

which is the default argument for ‘system->llvm-target’.

If I can add a shameless plug, patch 2 of my “Target check fixes and
cleanups” series¹ adds a helper procedure with the code above. :-)

> +    (arguments
> +     (substitute-keyword-arguments (package-arguments llvm)
> +       ((#:configure-flags cf)
> +        `(cons* ,(string-append "-DLLVM_TARGETS_TO_BUILD="
> +                                (system->llvm-target system))

Same problem here.

-- 
Thanks,
Thiago

¹ https://issues.guix.gnu.org/49672






Information forwarded to guix-patches <at> gnu.org:
bug#49569; Package guix-patches. (Tue, 27 Jul 2021 17:11:02 GMT) Full text and rfc822 format available.

Message #17 received at 49569 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: 49569 <at> debbugs.gnu.org
Subject: Re: bug#49569: [PATCH] gnu: Add make-single-arch-llvm procedure.
Date: Tue, 27 Jul 2021 19:10:36 +0200
Efraim Flashner <efraim <at> flashner.co.il> skribis:

> On Mon, Jul 26, 2021 at 06:47:14PM +0200, Ludovic Courtès wrote:
>> Hi,
>> 
>> Efraim Flashner <efraim <at> flashner.co.il> skribis:
>> 
>> > * gnu/packages/llvm.scm (make-single-arch-llvm): New procedure.
>> > (llvm-native-12, llvm-native): New variables.
>> > ---
>> >
>> > Using this copy of llvm for packages like mesa will reduce the closure
>> > of those packages. I don't suppose it would work as well for compilers
>> > like rust which use LLVM for compiling and targeting different
>> > architectures.
>> >
>> > This drops the size of llvm-12 from 167M to 111M.
>> 
>> That’s less impressive than I would have thought.

[...]

> I think you're mostly shocked by the large numbers, it is a drop of 33%.
>
> It turns out that llvm-julia uses something similar to only target one
> arch, so the idea's there somewhere. We could probably add it in there
> too for dlang. Icecat/icedove/mozjs-78 should be OK to switch. And
> xf86-video-vmware already has mesa as an input and could likely use a
> special llvm-for-mesa version.

OK, maybe that’d be an improvement, and indeed, 33% is not negligible.

> I can look at mesa and see which libraries from llvm it links to and see
> about just building those. A first look shows 50 llvm libraries from
> mesa and about 150 from llvm <at> 11, with the 4 libraries being
> libOSMesa  libvulkan_radeon  libxatracker  libXvMCnouveau

Makes sense.

Does Mesa require some special GPU compiler backend in addition to the
native backend?

Thanks,
Ludo’.




Reply sent to Efraim Flashner <efraim <at> flashner.co.il>:
You have taken responsibility. (Mon, 30 Jan 2023 18:13:01 GMT) Full text and rfc822 format available.

Notification sent to Efraim Flashner <efraim <at> flashner.co.il>:
bug acknowledged by developer. (Mon, 30 Jan 2023 18:13:01 GMT) Full text and rfc822 format available.

Message #22 received at 49569-done <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 49569-done <at> debbugs.gnu.org
Subject: Re: bug#49569: [PATCH] gnu: Add make-single-arch-llvm procedure.
Date: Mon, 30 Jan 2023 20:12:33 +0200
[Message part 1 (text/plain, inline)]
I think we can drop this with llvm-for-mesa in core-updates.

-- 
Efraim Flashner   <efraim <at> flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 28 Feb 2023 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 173 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.