Subject: Re: bug#31380: grub fails to build on i686-linux

From: Mark H Weaver <[email-masked]>
Date: Wed, 13 Jun 2018 23:43:18 -0400

retitle 31380 grub fails to build on i686-linux
severity 31380 serious
thanks

Mark H Weaver <[email-masked]> writes:
> On the 'core-updates' branch, both 'grub' and 'grub-efi' fail to build
> on i686-linux.  See below for the relevant excerpt from the build log
> of 'grub-efi', but the error is the same for both.

core-updates has since been merged to master, so this is now a serious
problem for i686 users.  It prevents building any system, and therefore
prevents i686 users from applying security updates.

> lib/i386/relocator64.S: Assembler messages:
> lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64'
> lib/i386/relocator64.S:74: Error: bad register name `%rax'
> lib/i386/relocator64.S:88: Error: bad register name `%rsp'
> lib/i386/relocator64.S:98: Error: bad register name `%rax'
> lib/i386/relocator64.S:132: Error: bad register name `%rip)'

I looked into this, and the problem is that our 'binutils' package on
i686-linux is not configured to support 64-bit instructions.

Here's a proposed patch that I hope will fix the problem, although I'm
unable to easily test it because I no longer use binary substitutes, and
I have not yet built the core packages for i686-linux.

However, I've applied this patch to my x86_64 system, and verified that
it does not cause any problems there.

Would someone be willing to test it and report back?

       Mark

>From 6fb0495569846b6399583a6c32ee341dde2e1785 Mon Sep 17 00:00:00 2001
From: Mark H Weaver <[email-masked]>
Date: Mon, 11 Jun 2018 19:21:39 -0400
Subject: [PATCH] UNTESTED: gnu: grub: Fix build on 32-bit x86.

---
 gnu/packages/bootloaders.scm | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index a86c73731..8c8588973 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -61,7 +61,8 @@
   #:use-module (guix packages)
   #:use-module (guix utils)
   #:use-module (srfi srfi-1)
-  #:use-module (srfi srfi-26))
+  #:use-module (srfi srfi-26)
+  #:use-module (ice-9 regex))
 
 (define unifont
   ;; GNU Unifont, <http://gnu.org/s/unifont>.
@@ -144,6 +145,19 @@
        ("texinfo" ,texinfo)
        ("help2man" ,help2man)
 
+       ;; FIXME: When building GRUB 2.02 on 32-bit x86, we need a binutils
+       ;; capable of assembling 64-bit instructions.  However, our default
+       ;; binutils on 32-bit x86 is not 64-bit capable.
+       ,@(if (string-match "^i[3456]86-" (%current-system))
+             `(("binutils"
+                ,(package/inherit
+                  binutils
+                  (arguments
+                   (substitute-keyword-arguments (package-arguments binutils)
+                     ((#:configure-flags flags ''())
+                      `(cons "--enable-64-bit-bfd" ,flags)))))))
+             '())
+
        ;; Dependencies for the test suite.  The "real" QEMU is needed here,
        ;; because several targets are used.
        ("parted" ,parted)
-- 
2.17.1