unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Jan Nieuwenhuizen <janneke@gnu.org>
To: bug-grub@gnu.org
Cc: 41982@debbugs.gnu.org
Subject: bug#41982: [PATCH] grub-core: Build fixes for i386
Date: Tue, 23 Jun 2020 14:57:00 +0200	[thread overview]
Message-ID: <87ftamrlcz.fsf@gnu.org> (raw)
In-Reply-To: <87pn9sy14x.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 4330 bytes --]

Hi!

When cross-compiling Grub-2.04 from i386-linux-gnu to i586-pc-hurd on
GNU Guix, I got this error

--8<---------------cut here---------------start------------->8---
i586-pc-gnu-gcc -DHAVE_CONFIG_H -I. -I..  -Wall -W  -DGRUB_MACHINE_PCBIOS=1 -DGRUB_MACHINE=I386_PC -m32 -nostdinc -isystem /gnu/store/5s0ldm31100d9ix15d1lmbsvi0aa77pq-gcc-cross-i586-pc-gnu-7.5.0-lib/lib/gcc/i586-pc-gnu/7.5.0/include -I../include -I../include -DGRUB_FILE=\"lib/cmos_datetime.c\" -I. -I. -I.. -I.. -I../include -I../include -I../grub-core/lib/libgcrypt-grub/src/    -D_FILE_OFFSET_BITS=64 -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations  -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -march=i386 -m32 -mrtd -mregparm=3 -falign-jumps=1 -falign-loops=1 -falign-functions=1 -freg-struct-return -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow -msoft-float -fno-dwarf2-cfi-asm -mno-stack-arg-probe -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-stack-protector -Wtrampolines -Werror   -ffreestanding   -MT lib/datetime_module-cmos_datetime.o -MD -MP -MF lib/.deps-core/datetime_module-cmos_datetime.Tpo -c -o lib/datetime_module-cmos_datetime.o `test -f 'lib/cmos_datetime.c' || echo './'`lib/cmos_datetime.c
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:98: Error: bad register name `%rax'
lib/i386/relocator64.S:132: Error: bad register name `%rip)'
make[3]: *** [Makefile:32165: lib/i386/relocator_module-relocator64.o] Error 1
make[3]: *** Waiting for unfinished jobs....
mv -f lib/i386/.deps-core/relocator_module-relocator_common_c.Tpo lib/i386/.deps-core/relocator_module-relocator_common_c.Po
mv -f lib/i386/.deps-core/relocator_module-relocator.Tpo lib/i386/.deps-core/relocator_module-relocator.Po
mv -f kern/.deps-core/elf_module-elf.Tpo kern/.deps-core/elf_module-elf.Po
mv -f lib/.deps-core/datetime_module-cmos_datetime.Tpo lib/.deps-core/datetime_module-cmos_datetime.Po
mv -f fs/.deps-core/xfs_module-xfs.Tpo fs/.deps-core/xfs_module-xfs.Po
mv -f lib/.deps-core/crypto_module-crypto.Tpo lib/.deps-core/crypto_module-crypto.Po
mv -f lib/.deps-core/relocator_module-relocator.Tpo lib/.deps-core/relocator_module-relocator.Po
make[3]: Leaving directory '/tmp/guix-build-grub-minimal-2.04.drv-0/grub-2.04/grub-core'
make[2]: *** [Makefile:26403: all] Error 2
make[2]: Leaving directory '/tmp/guix-build-grub-minimal-2.04.drv-0/grub-2.04/grub-core'
make[1]: *** [Makefile:11304: all-recursive] Error 1
make[1]: Leaving directory '/tmp/guix-build-grub-minimal-2.04.drv-0/grub-2.04'
make: *** [Makefile:3343: all] Error 2
command "make" "-j" "8" failed with status 2
--8<---------------cut here---------------end--------------->8---

In Guix we are now using the patch attached, which seems to fix this for
us.  We are not entirely sure if this is the proper fix though, see
<https://bugs.gnu.org/41982>.

Paraphrasing the questions raised there: why does this seem to compile
on i386?  Is that because the non-cross 32-bit ‘as’ supports ‘.code64’?
Is the Guix's cross-assembler ‘i586-pc-gnu-as’ configured wrong and
should it support this?

(FWIW, this is not specific for the Hurd, cross compiling from
i686-linux-gnu to i686-linux-gnu show the same error.  The use case for
that may be a bit thin to warrant a bug report.)

Ideas welcome!

Greetings,
Janneke


[-- Attachment #2: 0001-grub-core-Build-fixes-for-i386.patch --]
[-- Type: text/x-patch, Size: 1797 bytes --]

From 270667540146f8ef9ea7a44258a71b3837a7af4a Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
Date: Sun, 21 Jun 2020 15:10:40 +0200
Subject: [PATCH] grub-core: Build fixes for i386

* grub-core/lib/i386/relocator64.S: Avoid x86_64 instructions on i386.
---
 grub-core/lib/i386/relocator64.S | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/grub-core/lib/i386/relocator64.S b/grub-core/lib/i386/relocator64.S
index 148f38adb..45fed9444 100644
--- a/grub-core/lib/i386/relocator64.S
+++ b/grub-core/lib/i386/relocator64.S
@@ -63,7 +63,9 @@ VARIABLE(grub_relocator64_cr3)
 	movq	%rax, %cr3
 #endif
 
+#ifdef __x86_64__
 	.code64
+#endif
 
 	/* mov imm64, %rax */
 	.byte 	0x48
@@ -71,7 +73,14 @@ VARIABLE(grub_relocator64_cr3)
 VARIABLE(grub_relocator64_rsp)
 	.quad	0
 
+#ifndef __x86_64__
+	/* movq	%rax, %rsp */
+	.byte 	0x48
+	.byte	0x89
+	.byte	0xc4
+#else
 	movq	%rax, %rsp
+#endif
 
 #ifdef GRUB_MACHINE_EFI
 	jmp	LOCAL(skip_efi_stack_align)
@@ -95,8 +104,15 @@ LOCAL(skip_efi_stack_align):
 VARIABLE(grub_relocator64_rsi)
 	.quad	0
 
+#ifndef	__x86_64__
+	/* movq	%rax, %rsi */
+	.byte 	0x48
+	.byte	0x89
+	.byte 	0xc6
+#else
 	movq	%rax, %rsi
-	
+#endif
+
 	/* mov imm64, %rax */
 	.byte 	0x48
 	.byte	0xb8
@@ -128,6 +144,14 @@ VARIABLE(grub_relocator64_rdx)
 #ifdef __APPLE__
 	.byte 0xff, 0x25
 	.quad 0
+#elif !defined (__x86_64__)
+	/* jmp *LOCAL(jump_addr) (%rip) */
+	.byte 0xff
+        .byte 0x25
+	.byte 0
+	.byte 0
+	.byte 0
+	.byte 0
 #else
 	jmp *LOCAL(jump_addr) (%rip)
 #endif
-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com


[-- Attachment #3: Type: text/plain, Size: 152 bytes --]


-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

  parent reply	other threads:[~2020-06-23 12:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-21 13:55 bug#41982: [PATCH 0/1] gnu: grub: Cross-build fix for system i686-linux Jan Nieuwenhuizen
2020-06-21 13:59 ` bug#41982: [PATCH 1/1] " Jan (janneke) Nieuwenhuizen
2020-06-23  9:27 ` bug#41982: [PATCH 0/1] " Ludovic Courtès
2020-06-23 12:52   ` Jan Nieuwenhuizen
2020-06-23 15:54     ` Ludovic Courtès
2020-06-25 15:52       ` Jan Nieuwenhuizen
2020-06-23 12:57 ` Jan Nieuwenhuizen [this message]
2020-07-08 17:29   ` bug#41982: [PATCH v2] grub-core: Build fixes for i386 Jan Nieuwenhuizen
2020-07-13 13:51     ` Ludovic Courtès
2020-07-13 14:03       ` Jan Nieuwenhuizen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ftamrlcz.fsf@gnu.org \
    --to=janneke@gnu.org \
    --cc=41982@debbugs.gnu.org \
    --cc=bug-grub@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).