Subject: bug#41982: [PATCH 0/1] gnu: grub: Cross-build fix for system i686-linux.

From: Jan Nieuwenhuizen <[email-masked]>
Date: Tue, 23 Jun 2020 14:52:46 +0200

Ludovic Courtès writes:

Hello,

> Jan Nieuwenhuizen <[email-masked]> skribis:
>
>> Attempting to reconfigure a i686-linux guix system to a Hurd system, I
>> found that the Grub(-minimal) cross build fails like this
>>
>> 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\"

[..]
>> 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)'
>
> Interesting.  Why doesn’t it happen when doing:
>
>   guix build grub-minimal -s i686-linux
>
> ?  That’s because ‘as’ supports ‘.code64’ there?

Ah, that could be a switch!  I imagined ".code64" was not supported,
"just like" using 64-bit registers.

>> I am not sure if and how to report this upstream.  Ideas for a bug
>> description?  Apparently, non-cross builds "just" work (how?!).
>
> The issue seems to be that ‘.code64’ is not supported by cross
> assemblers to 32-bit Intel, right?

That could be part of the problem, I don't know.  I tested ‘.code64’ on
a 32-bit machine and get

--8<---------------cut here---------------start------------->8---
gcc -c foo-64.S
foo-64.S: Assembler messages:
foo-64.S:23: Error: unknown pseudo-op: `.code64'
foo-64.S:24: Error: bad register name `%rax'
foo-64.S:48: Error: unknown pseudo-op: `.code64'
foo-64.S:49: Error: bad register name `%rip)'
--8<---------------cut here---------------end--------------->8---

so, I'm not sure what's the idea here.

> Is this a defect of cross-as in general, or a misconfiguration in our
> Guix package?  Or is this normal behavior that should be fixed in GRUB?

Good question.  I will send the patch upstream (to Grub), maybe they can
share some light on this?

> Anyway, the patch LGTM!

Pushed to master as cd6b0910dc471afb76677109625af0a42ce3056a

Thanks!
Janneke

-- 
Jan Nieuwenhuizen <[email-masked]> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com