Grub 2 builds with the Gold linker, but makes the machine unbootable after grub2-setup is run; "GRUB is loading" never shows up and the screen remains blank indefinitely. Having had to recover my machine a few times because of this, I suggest that we add a check in the ebuild to bail out if the Gold linker is detected.
Created attachment 327008 [details, diff] add check for gold to ebuild This patch adds a check in src_prepare() to die if the Gold linker is detected.
Confirmed in qemu. Looks like there is a bug report upstream that nobody has looked at.
+ 20 Oct 2012; Mike Gilbert <floppym@gentoo.org> grub-2.00-r1.ebuild, + grub-9999.ebuild: + Add pkg_pretend check to bail out if we are using the gold linker. Bug 439082 + by Ambroz Bizjak.
there should be only one place in grub-2.00-r1 that still needs tweaking configure.ac: CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100" change the 8000 to 0x8000
(In reply to comment #4) I gave that a shot, but grub still doesn't load.
Created attachment 353312 [details, diff] Force ld.bfd via --fuse-ld CFLAG As stated in BUG#466536 (where I initially added this by mistake): Would it make more sense to « append-cflags "-fuse-ld=bfd" », instead of complaining about gold usage, until the bug is resolved upstream?
Created attachment 354098 [details, diff] Force ld.bfd via --fuse-ld CFLAG (grub-2.00-r4.ebuild) Fixed for grub-2.00-r4.ebuild. Applies cleanly with "-F 9999".
If I am not mistaken, the -fuse-ld option does not work before gcc-4.8.0.
Comment on attachment 354098 [details, diff] Force ld.bfd via --fuse-ld CFLAG (grub-2.00-r4.ebuild) Holy... damn. I just looked at the patch. I expected patch to actually do something sensible.
(In reply to Mike Gilbert from comment #8) > If I am not mistaken, the -fuse-ld option does not work before gcc-4.8.0. Mike, Can't you do something similar to what I've done in sys-firmware/sgabios?
(In reply to Doug Goldstein from comment #10) > Can't you do something similar to what I've done in sys-firmware/sgabios? I assume you are referring to this: emake CC=$(tc-getCC) LD="$(tc-getLD).bfd" AR=$(tc-getAR) \ OBJCOPY=$(tc-getOBJCOPY) That would only be effective if grub's build system actually calls $(LD) directly. When the linker is invoked indirectly via the C compiler, ${LD} is ignored. That's the entire reason the "-fuse-ld" gcc option was added. If you think I'm wrong here, let me know and I will double-check the grub build system to see how it is invoking the linker.
(In reply to Mike Gilbert from comment #11) > (In reply to Doug Goldstein from comment #10) > > Can't you do something similar to what I've done in sys-firmware/sgabios? > > I assume you are referring to this: > > emake CC=$(tc-getCC) LD="$(tc-getLD).bfd" AR=$(tc-getAR) \ > OBJCOPY=$(tc-getOBJCOPY) > > That would only be effective if grub's build system actually calls $(LD) > directly. When the linker is invoked indirectly via the C compiler, ${LD} is > ignored. That's the entire reason the "-fuse-ld" gcc option was added. > > If you think I'm wrong here, let me know and I will double-check the grub > build system to see how it is invoking the linker. I guess I phased it poorly. It wasn't a "hey do this" it was more "would this work". You are correct the grub build system would have to directly call LD, if its invoked via the compiler it wouldn't work.
(In reply to Doug Goldstein from comment #12) Ah, ok. Well, I just had a quick glance at a build log, it it looks like it is running $(CC) to do the linking. I guess I could set up a special case if the user has at least gcc-4.8 and is using gold. I'll probably wait until I add a new grub snapshot to do that, which should be pretty soon.
+*grub-2.00_p5086 (04 Aug 2013) + + 04 Aug 2013; Mike Gilbert <floppym@gentoo.org> +grub-2.00_p5086.ebuild, + grub-9999.ebuild: + New snapshot, resolves bug 468136. Append -fuse-ld=bfd to LDFLAGS for gcc-4.8+ + as a workaround for bug 439082.
Commit message: Use new toolchain helpers for selecting the bfd linker http://sources.gentoo.org/sys-boot/grub/grub-0.97-r14.ebuild?r1=1.6&r2=1.7 http://sources.gentoo.org/sys-boot/grub/grub-2.00_p5107-r2.ebuild?r1=1.9&r2=1.10 http://sources.gentoo.org/sys-boot/grub/grub-2.02_beta2-r3.ebuild?r1=1.5&r2=1.6 http://sources.gentoo.org/sys-boot/grub/grub-2.02_beta2-r6.ebuild?r1=1.3&r2=1.4 http://sources.gentoo.org/sys-boot/grub/grub-2.02_beta2-r7.ebuild?r1=1.6&r2=1.7 http://sources.gentoo.org/sys-boot/grub/grub-9999-r1.ebuild?r1=1.29&r2=1.30
+ 17 Mar 2015; Mike Gilbert <floppym@gentoo.org> grub-2.00_p5107-r2.ebuild, + grub-2.02_beta2-r3.ebuild, grub-2.02_beta2-r6.ebuild, + grub-2.02_beta2-r7.ebuild, grub-9999-r1.ebuild: + We need to set TARGET_LDFLAGS, not LDFLAGS.
Is this still a problem with grub-2.02_rc* ?
is this still a problem for the stable sys-boot/grub-2.02
Yes, it is still a problem. Please don't ask again unless you have some evidence to the contrary.