Subject: [bug#66263] [PATCH 05/23] gnu: cross-gcc: Enable multilib for avr.

From: Jean-Pierre De Jesus DIAZ <[email-masked]>
Date: Fri, 29 Sep 2023 11:16:09 +0200

* gnu/packages/cross-base.scm (cross-gcc-arguments)
  [target-avr?]: Remove --disable-mutlilib and add --enable-multilib.
---
 gnu/packages/avr.scm        |  4 +---
 gnu/packages/cross-base.scm | 17 +++++++++++++----
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/avr.scm b/gnu/packages/avr.scm
index b9bee5e624..e976203b89 100644
--- a/gnu/packages/avr.scm
+++ b/gnu/packages/avr.scm
@@ -75,9 +75,7 @@ (define avr-gcc
                   ;; several scripts inside this script, each with a #!/bin/sh
                   ;; that needs patching.
                   (substitute* "gcc/genmultilib"
-                    (("#!/bin/sh") (string-append "#!" (which "sh"))))))))
-         ((#:configure-flags flags)
-          #~(delete "--disable-multilib" #$flags))))
+                    (("#!/bin/sh") (string-append "#!" (which "sh"))))))))))
       (native-search-paths
        (list (search-path-specification
               (variable "CROSS_C_INCLUDE_PATH")
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index f55765f1b0..ec7ca2186d 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -197,12 +197,21 @@ (define (cross-gcc-arguments target xgcc libc)
                                 #~((string-append "--with-toolexeclibdir="
                                                   (assoc-ref %outputs "lib")
                                                   "/" #$target "/lib"))
+                                #~())
+
+                         #$@(if (target-avr? target)
+                                #~("--enable-multilib")
+                                #~())
+
                                 #~()))
 
-                   #$(if libc
-                         flags
-                         #~(remove (cut string-match "--enable-languages.*" <>)
-                                   #$flags))))
+                   (remove
+                     (lambda (flag)
+                       (or (and (string-match "--enable-languages.*" flag)
+                                #$libc)
+                           (and (string-match "--disable-multilib" flag)
+                                #$(target-avr? target))))
+                     #$flags)))
         ((#:make-flags flags)
          (if libc
              #~(let ((libc (assoc-ref %build-inputs "libc")))
-- 
2.34.1