From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lhB4R-0000vc-KR for mharc-grub-devel@gnu.org; Thu, 13 May 2021 09:08:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh8gj-0000d1-9i for grub-devel@gnu.org; Thu, 13 May 2021 06:35:30 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37130) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lh8gi-0004CQ-Mv; Thu, 13 May 2021 06:35:28 -0400 Received: from [2001:980:1b4f:1:42d2:832d:bb59:862] (port=43602 helo=dundal.janneke.lilypond.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh8gi-0004RJ-Bt; Thu, 13 May 2021 06:35:28 -0400 From: Jan Nieuwenhuizen To: Daniel Kiper Cc: "Mikhail B. WproxyM" , grub-devel@gnu.org Subject: Re: boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64) Organization: AvatarAcademy.nl References: <20210505163302.hkkti2ewr3iebht6@tomti.i.net-space.pl> X-Url: http://AvatarAcademy.nl Date: Thu, 13 May 2021 12:35:25 +0200 In-Reply-To: <20210505163302.hkkti2ewr3iebht6@tomti.i.net-space.pl> (Daniel Kiper's message of "Wed, 5 May 2021 18:33:02 +0200") Message-ID: <87eeeaor9u.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Mailman-Approved-At: Thu, 13 May 2021 09:08:06 -0400 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 10:35:31 -0000 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Daniel Kiper writes: Hello Daniel, > May I ask you to try latest GRUB master git branch [1]? The GRUB 2.04 > release is a few years old. We are going to release 2.06 soon. Sure. The bug is still there (see attached patch to reproduce using Guix): --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix build --system=3Di686-linux --target=3Di586-pc-gnu gr= ub=20 starting phase `unpack' grub-2.06~rc1/ [..] starting phase `configure' source directory: "/tmp/guix-build-grub-2.06-rc1.drv-0/grub-2.06~rc1" (rela= tive from build: ".") build directory: "/tmp/guix-build-grub-2.06-rc1.drv-0/grub-2.06~rc1" configure flags: ("CC_FOR_BUILD=3Dgcc" "CONFIG_SHELL=3D/gnu/store/v1g7f3p4f= 0851mywrla8qmr9hb8jgfjr-bash-minimal-5.0.16/bin/bash" "SHELL=3D/gnu/store/v= 1g7f3p4f0851mywrla8qmr9hb8jgfjr-bash-minimal-5.0.16/bin/bash" "--prefix=3D/= gnu/store/753q8z0xa9ijap3p3phpsvns7287c7sn-grub-2.06-rc1" "--enable-fast-in= stall" "--build=3Di686-unknown-linux-gnu" "--host=3Di586-pc-gnu" "PYTHON=3D= true") [..] starting phase `build' [..] i586-pc-gnu-gcc -DHAVE_CONFIG_H -I. -I.. -Wall -W -DGRUB_MACHINE_PCBIOS= =3D1 -DGRUB_MACHINE=3DI386_PC -m32 -nostdinc -isystem /gnu/store/q8af3pvwsk= nn132pl1nzrb5281i4pgij-gcc-cross-i586-pc-gnu-7.5.0-lib/lib/gcc/i586-pc-gnu/= 7.5.0/include -I../include -I../include -DGRUB_FILE=3D\"lib/i386/relocator.= c\" -I. -I. -I.. -I.. -I../include -I../include -I../grub-core/lib/libgcryp= t-grub/src/ -D_FILE_OFFSET_BITS=3D64 -std=3Dgnu99 -Os -m32 -Wall -W -Wsh= adow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-decla= rations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-= args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declarat= ion -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmul= tichar -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-protot= ypes -Wmissing-declarations -Wextra -Wattributes -Wendif-labels -Winit-sel= f -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnul= l -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macro= s -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-p= rototypes -Wmissing-declarations -Wformat=3D2 -march=3Di386 -mrtd -mregparm= =3D3 -falign-jumps=3D1 -falign-loops=3D1 -falign-functions=3D1 -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-un= wind-tables -fno-ident -fno-stack-protector -Wtrampolines -Werror -ffrees= tanding -MT lib/i386/relocator_module-relocator.o -MD -MP -MF lib/i386/.d= eps-core/relocator_module-relocator.Tpo -c -o lib/i386/relocator_module-rel= ocator.o `test -f 'lib/i386/relocator.c' || echo './'`lib/i386/relocator.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)' --8<---------------cut here---------------end--------------->8--- >> > lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64' >> >> So, the working patch is attached. Please add it to grub2. > > You can find a few comments below... Thanks! >> From 270667540146f8ef9ea7a44258a71b3837a7af4a Mon Sep 17 00:00:00 2001 >> From: "Jan (janneke) Nieuwenhuizen" >> 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. > > Please describe in the commit message why this patch is needed and how > the issue can be reproduced. I have added: --8<---------------cut here---------------start------------->8--- This fixes cross-compiling to x86 (e.g., the Hurd) from x86-linux. To reproduce, update the Grub source description in your local Guix archive and run ./pre-inst-env guix build --system=3Di686-linux --target=3Di586-pc-gnu g= rub=20 or install an x86 cross-build environment on x86-linux (32bit!) and configure to cross build and make, e.g., do something like ./configure \ CC_FOR_BUILD=3Dgcc \ --build=3Di686-unknown-linux-gnu --host=3Di586-pc-gnu make --8<---------------cut here---------------end--------------->8--- >> diff --git a/grub-core/lib/i386/relocator64.S b/grub-core/lib/i386/reloc= ator64.S >> index 148f38adb..45fed9444 100644 [..] >> +#ifndef __x86_64__ >> + /* movq %rax, %rsp */ >> + .byte 0x48 >> + .byte 0x89 >> + .byte 0xc4 >> +#else >> movq %rax, %rsp >> +#endif > > I would do it other way around to increase readability... > > #ifdef __x86_64__ > movq %rax, %rsp > #else > /* movq %rax, %rsp */ > .byte 0x48 > ... Done. >> +#ifndef __x86_64__ >> + /* movq %rax, %rsi */ >> + .byte 0x48 >> + .byte 0x89 >> + .byte 0xc6 >> +#else >> movq %rax, %rsi >> - >> +#endif > > Ditto... Ok. >> #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 > > #if defined(__APPLE__) || !defined (__x86_64__) > .byte 0xff, 0x25 > .quad 0 > #else > jmp *LOCAL(jump_addr) (%rip) > #endif Ah, yes; that's better. Also updated. > A patch should be prepared on top of latest GRUB master git branch [1]. Sure, but well.. https://lists.gnu.org/archive/html/bug-grub/2020-06/msg00013.html it was when I sent the report ;) Luckily it still applied cleanly to current master. > And please use "git-send-email" to send the patch as Adrian said... Sure, sent separately to bug-grub. Greetings, Janneke --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=grub-hurd-cross-build-reproducer.patch diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm index 56bef57cb7..78923e4303 100644 --- a/gnu/packages/bootloaders.scm +++ b/gnu/packages/bootloaders.scm @@ -88,18 +88,15 @@ (define-public grub (package (name "grub") - (version "2.04") + (version "2.06-rc1") (source (origin (method url-fetch) - (uri (string-append "mirror://gnu/grub/grub-" version ".tar.xz")) + (uri (string-append "https://alpha.gnu.org/pub/gnu/grub/" + "grub-2.06~rc1" ".tar.xz")) + (file-name (string-append "grub-" version ".tar.xz")) (sha256 (base32 - "0zgp5m3hmc9jh8wpjx6czzkh5id2y8n1k823x2mjvm2sk6b28ag5")) - (patches (search-patches - "grub-efi-fat-serial-number.patch" - "grub-setup-root.patch" - "grub-verifiers-Blocklist-fallout-cleanup.patch" - "grub-cross-system-i686.patch")))) + "112l2isb0rgdz4zz4ssmf5hklv0viz0674fdwr1h1d9a3vrg31rc")))) (build-system gnu-build-system) (arguments `(#:configure-flags --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.com --=-=-=--