After seeing some issues with clang compiling grub I have found it is appending /lib/ld-linux.so.2 to the end of /usr/lib/grub/i386-pc/diskboot.img and /usr/lib/grub/i386-pc/boot.img, so this makes it too large to install on a MBR system. I found a workaround to the issue using truncate to remove the extra bytes and was going to add this to an ebuild until I remembered that isn't a standard command so can't be used. Instead I have updated the clang wiki page so it's easy to find the fix: https://wiki.gentoo.org/wiki/Clang#Grub2_on_MBR_systems I doubt there is much Gentoo can do with this but I feel this is a blocker to a system wide clang system so filing the bug so at least this is known to highlight in documentation. Steps to reproduce: 1. Use clang stage3 on mbr system 2. emerge -va sys-boot/grub 3. grub-install /dev/sda Error: Installing for i386-pc plaftorm. grub-install: error: diskboot.img size must be 512 bytes. Workaround: 1. truncate -s 512 /usr/lib/grub/i386-pc/diskboot.img 2. truncate -s 512 /usr/lib/grub/i386-pc/boot.img 3. grub-install /dev/sda I will upstream this as well and update this report for tracking purposes with those URLs.
You might want to send an email to the grub-devel mailing list; possibly they can implement some workaround. https://lists.gnu.org/mailman/listinfo/grub-devel/
(In reply to Mike Gilbert from comment #1) > You might want to send an email to the grub-devel mailing list; possibly > they can implement some workaround. > > https://lists.gnu.org/mailman/listinfo/grub-devel/ Good idea, this can be followed here: https://lists.gnu.org/archive/html/grub-devel/2023-01/msg00000.html
https://lists.gnu.org/archive/html/grub-devel/2023-01/msg00085.html See patch submitted by username234 to the mailing list.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c382388940b194bf1a8bb1c4392394a699108165 commit c382388940b194bf1a8bb1c4392394a699108165 Author: Mike Gilbert <floppym@gentoo.org> AuthorDate: 2023-01-17 15:53:27 +0000 Commit: Mike Gilbert <floppym@gentoo.org> CommitDate: 2023-01-17 16:03:01 +0000 sys-boot/grub: backport fix for MBR images with clang Closes: https://bugs.gentoo.org/889432 Signed-off-by: Mike Gilbert <floppym@gentoo.org> ...py-Remove-.interp-section-from-.img-files.patch | 31 ++ sys-boot/grub/grub-2.06-r5.ebuild | 336 +++++++++++++++++++++ 2 files changed, 367 insertions(+)