Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 889432 - sys-boot/grub clang appends string so can't be used on MBR
Summary: sys-boot/grub clang appends string so can't be used on MBR
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: systemwide-clang
  Show dependency tree
 
Reported: 2023-01-03 00:28 UTC by immolo
Modified: 2023-01-17 16:03 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description immolo 2023-01-03 00:28:10 UTC
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.
Comment 1 Mike Gilbert gentoo-dev 2023-01-03 01:04:12 UTC
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/
Comment 2 immolo 2023-01-03 13:51:10 UTC
(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
Comment 3 immolo 2023-01-17 12:27:11 UTC
https://lists.gnu.org/archive/html/grub-devel/2023-01/msg00085.html

See patch submitted by username234 to the mailing list.
Comment 4 Larry the Git Cow gentoo-dev 2023-01-17 16:03:13 UTC
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(+)