Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 787221 - sys-boot/grub-2.06[grub_platforms_xen] fails to build with sys-devel/binutils-2.36
Summary: sys-boot/grub-2.06[grub_platforms_xen] fails to build with sys-devel/binutils...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Mike Gilbert
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-30 19:48 UTC by Agostino Sarubbo
Modified: 2021-09-23 18:49 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log.xz (build.log.xz,76.56 KB, application/x-xz)
2021-04-30 19:48 UTC, Agostino Sarubbo
Details
patch fixing .note.ABI-tags and .bss sections overlap (grub-2.06-note.ABI-tag-bss-sections-overlap-fix.patch,359 bytes, patch)
2021-05-05 15:31 UTC, Jiří Moravec
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2021-04-30 19:48:13 UTC
https://blogs.gentoo.org/ago/2020/07/04/gentoo-tinderbox/

Issue: sys-boot/grub-2.06_rc1 fails to compile.
Discovered on: amd64 (internal ref: tinderbox)

NOTE:
This machine uses GCC-11: https://gcc.gnu.org/gcc-11/porting_to.html
If you think this is a GCC-11 related issue, please block bug 732706.
Comment 1 Agostino Sarubbo gentoo-dev 2021-04-30 19:48:17 UTC
Created attachment 704730 [details]
build.log.xz

build log and emerge --info (compressed because it exceeds attachment limit, use 'xzless' to read it)
Comment 2 Agostino Sarubbo gentoo-dev 2021-04-30 19:48:18 UTC
Possible context of error(s):

collect2: error: ld returned 1 exit status
Comment 3 Mike Gilbert gentoo-dev 2021-04-30 20:07:46 UTC
Relevant line from the log:

> /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: section .note.gnu.property VMA [0000000000400158,0000000000400187] overlaps section .bss VMA [000000000000f000,000000000041e1b7]

I can reproduce the issue with gcc-10.3.0 and gcc-11.1.0.

Maybe something to do with binutils?
Comment 4 Sergei Trofimovich (RETIRED) gentoo-dev 2021-05-01 10:06:54 UTC
Yes, it's a binutils-2.36 section.

I suggest ignoring .note.gnu.property. The change should be similar to https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/5HOETPBPQKC2Y5PRFFSYDHBPWOTC7VQV/
Comment 5 Mike Gilbert gentoo-dev 2021-05-02 02:52:29 UTC
I get the same error with binutils-2.35.2.

This might just be some regression in grub-2.06~rc1.
Comment 6 Mike Gilbert gentoo-dev 2021-05-02 02:56:48 UTC
Same error with grub-2.04.
Comment 7 Mike Gilbert gentoo-dev 2021-05-02 03:18:21 UTC
I believe this is the failing command. I don't see any linker scripts referenced.

> x86_64-pc-linux-gnu-gcc -std=gnu99 -Os -m64 -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 -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-ident -mcmodel=large -fno-PIE -fno-pie -fno-stack-protector -Wtrampolines   -ffreestanding   -m64 -Wl,-melf_x86_64 -no-pie -Wl,--build-id=none  -nostdlib -Wl,-N -Wl,-N -Wl,-Ttext,0   -o kernel.exec kern/x86_64/xen/kernel_exec-startup.o kern/x86_64/kernel_exec-dl.o kern/x86_64/xen/kernel_exec-hypercall.o kern/i386/kernel_exec-tsc.o kern/i386/xen/kernel_exec-tsc.o kern/xen/kernel_exec-init.o term/xen/kernel_exec-console.o disk/xen/kernel_exec-xendisk.o commands/kernel_exec-boot.o term/kernel_exec-terminfo.o term/kernel_exec-tparm.o commands/kernel_exec-extcmd.o lib/kernel_exec-arg.o kern/kernel_exec-compiler-rt.o kern/kernel_exec-mm.o kern/kernel_exec-time.o kern/generic/kernel_exec-millisleep.o kern/kernel_exec-buffer.o kern/kernel_exec-command.o kern/kernel_exec-corecmd.o kern/kernel_exec-device.o kern/kernel_exec-disk.o kern/kernel_exec-dl.o kern/kernel_exec-env.o kern/kernel_exec-err.o kern/kernel_exec-file.o kern/kernel_exec-fs.o kern/kernel_exec-list.o kern/kernel_exec-main.o kern/kernel_exec-misc.o kern/kernel_exec-parser.o kern/kernel_exec-partition.o kern/kernel_exec-rescue_parser.o kern/kernel_exec-rescue_reader.o kern/kernel_exec-term.o kern/kernel_exec-verifiers.o kernel_exec-symlist.o
Comment 8 Sergei Trofimovich (RETIRED) gentoo-dev 2021-05-02 11:22:41 UTC
Yeah, looks like grub uses default linker script. It might be a binutils bug. 

I'll try to extract small example and file a bug against binutils.
Comment 9 Sergei Trofimovich (RETIRED) gentoo-dev 2021-05-02 14:49:53 UTC
After distilling it down to tiny assembly files I found a NOTABUG on binutils tracker:
    https://sourceware.org/PR27377

The suggestion is to use not
    -Wl,-Ttext,0
but
    -Wl,-Ttext-segment,0
Comment 10 Jiří Moravec 2021-05-05 15:31:52 UTC
Created attachment 706194 [details, diff]
patch fixing .note.ABI-tags and .bss sections overlap
Comment 11 Jiří Moravec 2021-05-05 15:40:09 UTC
(In reply to Sergei Trofimovich from comment #9)

Thank you for pointing me to problem solution. Proposed patch is maybe crude, but functional for me.
Comment 12 Mike Gilbert gentoo-dev 2021-05-05 17:10:08 UTC
I would appreciate it if someone who actually understands this could send a patch upstream for review.

I have no way of testing if this actually works at runtime.
Comment 14 Mike Gilbert gentoo-dev 2021-05-05 17:16:56 UTC
Comment on attachment 706194 [details, diff]
patch fixing .note.ABI-tags and .bss sections overlap

Assuming this is the correct thing to do, configure.ac should be patched instead of configure.
Comment 15 Tomáš Mózes 2021-05-15 04:49:39 UTC
It was possible to build grub with patch from #c14, but grub-mkimage (as described in https://wiki.xenproject.org/wiki/PvGrub2 or used by app-emulation/grub-xen-host) failed:

grub-mkimage: error: `/usr/lib/grub/x86_64-xen/kernel.img' is miscompiled: its start address is 0x150 instead of 0x0: ld.gold bug?.
Comment 16 Tomáš Mózes 2021-05-15 04:52:20 UTC
(In reply to Tomáš Mózes from comment #15)
> It was possible to build grub with patch from #c14, but grub-mkimage (as
> described in https://wiki.xenproject.org/wiki/PvGrub2 or used by
> app-emulation/grub-xen-host) failed:
> 
> grub-mkimage: error: `/usr/lib/grub/x86_64-xen/kernel.img' is miscompiled:
> its start address is 0x150 instead of 0x0: ld.gold bug?.

The failure is with binutils-2.36.1-r1. Grub compiles fine and grub-xen-host too with the stable binutils-2.35.2.
Comment 17 Andreas K. Hüttel archtester gentoo-dev 2021-07-20 22:08:07 UTC
https://build.opensuse.org/package/view_file/Base:System/grub2/0001-Fix-build-error-in-binutils-2.36.patch

Please try adding this patch to grub (and test if the result not just builds but also works!)
Comment 18 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-08-05 06:07:33 UTC
(In reply to Andreas K. Hüttel from comment #17)
> https://build.opensuse.org/package/view_file/Base:System/grub2/0001-Fix-
> build-error-in-binutils-2.36.patch
> 
> Please try adding this patch to grub (and test if the result not just builds
> but also works!)

Tomáš, are you able to give this a go? Cheers!
Comment 19 BigBug 2021-09-08 16:35:43 UTC
Same for me ... But that Suse patch (also need to enable GRUB_AUTORECONF=1 because of aclocal-1.15 needed) - fixes the problem.
Comment 20 Tomáš Mózes 2021-09-08 17:47:46 UTC
(In reply to Sam James from comment #18)
> (In reply to Andreas K. Hüttel from comment #17)
> > https://build.opensuse.org/package/view_file/Base:System/grub2/0001-Fix-
> > build-error-in-binutils-2.36.patch
> > 
> > Please try adding this patch to grub (and test if the result not just builds
> > but also works!)
> 
> Tomáš, are you able to give this a go? Cheers!

I've just compile tested it, I don't use sys-boot/grub[grub_platforms_xen].
Comment 21 Mike Gilbert gentoo-dev 2021-09-14 13:49:22 UTC
(In reply to Andreas K. Hüttel from comment #17)
> https://build.opensuse.org/package/view_file/Base:System/grub2/0001-Fix-
> build-error-in-binutils-2.36.patch
> 
> Please try adding this patch to grub (and test if the result not just builds
> but also works!)

It looks like this patch was sent for review upstream, but has not been accepted/applied.

https://lists.gnu.org/archive/html/grub-devel/2021-08/msg00002.html
Comment 22 moritori 2021-09-23 17:47:40 UTC
I'm having the same problem with both binutils-2.36 and the 2.37 which was stabilized a couple of days ago.

I think it is not good to have a broken stable ebuild for grub. If we cannot fix the problem yet, then we should require binutils<2.36 if the efi use-flag is used.

Otherwise let me know, if I can support with testing patches. I'm actually using grub-xen productively.
Comment 23 Larry the Git Cow gentoo-dev 2021-09-23 18:49:53 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=abe655fe66964de0a45e8d0c158bdf3958cdfd1c

commit abe655fe66964de0a45e8d0c158bdf3958cdfd1c
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2021-09-23 18:47:53 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2021-09-23 18:47:53 +0000

    sys-boot/grub: fix xen build with binutils-2.36
    
    Closes: https://bugs.gentoo.org/787221
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 sys-boot/grub/files/grub-2.06-binutils-2.36.patch | 44 +++++++++++++++++++++++
 sys-boot/grub/grub-2.06-r1.ebuild                 |  3 +-
 2 files changed, 46 insertions(+), 1 deletion(-)