Subject: bug#54407: Issues building grub for powerpc64le, could not force big-endian

From: Christopher Baines <[email-masked]>
Date: Mon, 04 Apr 2022 20:37:23 +0100

Maxime Devos <[email-masked]> writes:

> Christopher Baines schreef op di 15-03-2022 om 21:11 [+0000]:
>> grub can't be built for powerpc64le, I believe the same failure
>> occurs
>> with native builds or cross compilation from x86_64. I think this
>> might
>> have always been the case.
>>
>> This is the error from the build log:
>>
>>   checking for options to get big-endian compilation... no
>>   configure: error: could not force big-endian
>>
>> Looking in the config.log file, it tries a bunch of options with
>> different errors, but this one stands out:
>>
>>   cc1: error: '-m32' not supported in this configuration
>>
>> I know very little about gcc, but I think this might relate to the
>> multilib thing, which I'm guessing is disabled for the gcc in use
>> here.
>>
>> Any ideas about this issue?
>
> Maybe you could add a gcc compiling for 32-bit ppc (maybe without a
> glibc since this is grub) and patch the configuration script to use the
> 32-bit ppc gcc instead of using the 64-bit ppc+-m32?

I've had a go at this, using something like what I've included below,
but I haven't stumbled upon the right options yet, or a way to work out
why gcc still thinks "-m32 not supported".

(define multilib-gcc
  (package
   (inherit gcc)
   (name "foo-gcc")
   (arguments
    (substitute-keyword-arguments (package-arguments gcc)
         ((#:phases phases)
          `(modify-phases ,phases
             (add-after 'unpack 'fix-genmultilib
               (lambda _
                 ;; patch-shebang doesn't work here because there are actually
                 ;; 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)
          `(append (list
                    "--with-endian=little,big"
                    "--enable-multilib"
                    "--with-multilib-list=mx32,m64,m32"
                    )
                   (delete "--disable-multilib" ,flags)))))))