-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grub 2.06 fails to install boot loader #23
Comments
It looks like a bug appeared after release of binutils 2.36.1. See https://www.linuxfromscratch.org/lfs/view/stable/chapter08/grub.html , maybe the fix of issue in the beginning of this step will be useful. |
I'll try that and check the those images |
Try to use binutils LD instead of LLVM ld.lld if images wouldn't be correct |
Good point. I haven't tried that. Will do first |
Fix an issue with binutils first, if you would do this. |
Prefixing |
I also tried compiling with I'll try a patch for binutils |
Well, we have to use dear old GCC+Binutils toolchain for GRUB2 again. At least, we tried another way. I just needed to recognize if this error appears again. GRUB 2.06 release promised that it could be built correctly with clang 10. We tried clang 12. It failed. For now, at least. |
My current CMLFS build is llvm12 with binutils and GCC in So I tried LLVM12, LLVM12+Binutils,GCC+LLVM12-binary-tools... I think I forgot to try GCC+binutils. |
Oops. I did: GCC+binutils also generated wrong files sizes. |
I forgot to mention, building grub with clang as compiler...it yields an error when configuring:
|
My progress in building of final system is 34-flex for now. But I have found very small mistake on this step. HELPMAN equals to /tools/bin/true in configure script, but in CMLFS we don't use /tools, do we? We use /llvmtools. And HELPMAN should be equal to /llvmtools/bin/true. When I will build 72-grub, I would tell about that what I would find. |
I did check Alpine Linux and Void Linux... I didnt see any patches or fixes |
Well, I have built and installed GRUB 2.06. It builds fine, installation works fine as well. Generation of config fails due to disabled os-prober. I have built my GRUB for BIOS, so you could get bug with EFI.
and used fix of issue from LFS grub 2.04 built recipe placed after applying of patches and before executing of autogen.sh:
At the very first time, when I used current way configure decided that gcc could not produce executables, so I decided to make a new gcc. But when I switched to gnu toolchain and begin building of new gcc, I decided to stop this madness and build GRUB. GRUB built fine, but os-prober doesn't work. |
Hmmm... I am working another project using MLFS as base and using optimizations from Clear Linux. I just finished building GCC (version 11.2.0!) and binutils (version 2.37) for the final system. I will see when I get to GRUB, if the boot images are still bloated or not. |
Okay. I used binutils 2.37, too. The size of diskboot.img should be 512 bytes, not kbytes, due to the first sector size |
Yes, i did notice that last time i built grub with clang |
I found the way to surpass this error. Create config.cache with cached yes for __bss_start and some others variables:
This wouldn't be enough. I will try to build grub 2.06 now. |
I have successfully built GRUB 2.06 with clang, installed it to system, and successfully installed bootloader.
And become:
TARGET_IMG_LDFLAGS and TARGET_LDFLAGS_OLDMAGIC were:
and become:
|
Well, clang-built grub doesn't work. Maybe because of e2fsprogs isn't installed |
Every of these .img files has additional 23 bytes. For what reason they were added? |
Well, I found the сause of bloated images. This is linker. When we use ld.lld, it gives 23 additional bytes to each *.img and bloats them. I have found it when I forgot to change link /usr/bin/ld from ld.lld to ld.bfd and built grub with GCC. All of *.img files were bloated. |
So if GRUB was built with ld.bfd, no bloat? |
Yes. |
I have tried to reboot with clang-built grub and gcc-built images. Image loaded well, I've got "Welcome to GRUB!", but after that I have got black screen. Therefore, modules must be gcc-built as well. I will try to build grub 2.06 with clang and ld.bfd. And after that I will report about results. |
Well, I have copied all of *.img, *.module and *.mod files from gcc-built grub to clang-built grub. After reinstallation of grub in mbr, I successfully logged in my ubuntu 21.04 via CMLFS GRUB. I did not try build with clang and ld.bfd for now. I will do this now. |
I cannot remember if i was able to build GRUB with Clang+LLD and just copied the [unbloated] boot images from an older build (from MLFS). Or if I had to build GRUB with GCC+Binutils with unbloated images from an old MLFS build |
Make two builds: one built with clang, one built with gcc. All .img, .module and .mod files in clang will be broken. Copy these file from gcc build and it will work |
Most likely I will update the built and use that method. |
072-grub recipe should be:
Check if I am right or not. |
So in short, GRUB still needs to be built with GCC + Binutils's ld.bfd, right? Would be nice to clang-build GRUB but then use GCC+ld.bfd for the boot images. |
In short, you should use clang+ld.bfd. |
I think that besides GRUB being ubiquitous in modern UNIX, it would be interesting to have an alternative too for ones who don't want to make workarounds. |
Chimera Linux uses clang, libc++, LLD, and compiler-rt as defaults like CMLFS. So I checked how grub is compiled via their cports repo. Looks like grub is built with LLVM without binutils! There are patches, so I will try and see |
Even with patches from Chimera linux, configure tests for symbols __bss_start, edata, _edata, end, _end still fail. Therefore a config.cache has to be used as mentioned earlier:
Configure script executes with no errors. But when compiling, build breaks. To get the build to compile, modify the makefiles, as mentioned before, right after running
Build completes without error. For the i386-pc build, the images look fine. Not exactly the same size as mentioned earlier:
This was built using LLVM-15.0.6 without binutils... clang+LLD |
So, with patches from Chimera Linux, you don't have any bloats anymore? |
Did you check work capability of brand new images? If not, you should check their capability for correct work |
It's actually a local commit that I havent uploaded yet for the bsd-userland branch
I'm almost done with my build. I got a small BIOS-based PC i can test on. |
OK, good luck with checking! |
So far Next, let's boot with grub... Edit: Yes! Boots grub! |
Clang+elftoolchain cannot build grub:
Do note, my CMLFS build does not have bison... i replaced it with byacc.I will attempt it again with bison installed |
If I build bison and install it in Next, lets see if it GRUB can boot... |
Grub builds fine under chroot. When it is time to use
grub-install
to install grub as boot loader, install fails asdiskboot.img
is too large at 129Mb. Correct size is 512 Kb.Replacing image (with correct size) from an older build, install progresses but fails again with
boot.img
too large at 535 Kb instead of 512 Kb.Replace
boot.img
from an older build (with correct size) and now install succeeds.The text was updated successfully, but these errors were encountered: