grub2 for Cygwin
Quoted 7 lines · Bean
Quoted 4 lines · Christian Franke
...
Just for info: GRUB2 is now available as an experimental package in the Cygwin distribution.
Quoted 5 lines
Hi,
That's nice, but how do you create elf file in cygwin, use cross compilation tools ?
The cygwin distro does not include any cross compilation tools. A package that require tools not in the distro would not be accepted.
The package is actually build with native cygwin gcc+binutils.
The related discussion+patches are already on this list, e.g:
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00238.html
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00237.html
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00174.html
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00161.html
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00160.html
Quoted 3 lines
... Also, are tools like grub-setup working in cygwin environment ?
Yes, grub-setup builds and works OOTB. "grub-install /dev/sda", grub-emu, grub-mkrescue, ... all work as expected. I use the cygwin version of GRUB2 on two Windows+Linux work PC. It is IMO useful to install+maintain boot manager from cygwin bash when Windows is the main work OS.
Christian
Quoted 18 lines · Christian Franke
Quoted 4 lines · Bean
Quoted 1 line · Christian Franke
...
Quoted 9 lines
Quoted 3 lines
Just for info: GRUB2 is now available as an experimental package in the Cygwin distribution.
Hi,
That's nice, but how do you create elf file in cygwin, use cross compilation tools ?
The cygwin distro does not include any cross compilation tools. A package that require tools not in the distro would not be accepted.
Quoted 8 lines
The package is actually build with native cygwin gcc+binutils.
The related discussion+patches are already on this list, e.g:
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00238.html
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00237.html
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00174.html
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00161.html
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00160.html
It seems you have spent a lot of effect to make it work, but some trick is not very appealing. I personally don't mind, but I don't know if it can be accepted by others.
Quoted 10 lines
Quoted 4 lines
... Also, are tools like grub-setup working in cygwin environment ?
Yes, grub-setup builds and works OOTB. "grub-install
/dev/sda", grub-emu, grub-mkrescue, ... all work as expected. I use the cygwin version of GRUB2 on two Windows+Linux work PC. It is IMO useful to install+maintain boot manager from cygwin bash when Windows is the main work OS.
Can you make it work with mingw, for example, use the -mno-cygwin compile flag ?
Signature · 1 line
Bean
Quoted 17 lines · Bean
Quoted 4 lines · Christian Franke
...
The cygwin distro does not include any cross compilation tools. A package that require tools not in the distro would not be accepted.Quoted 9 lines
The package is actually build with native cygwin gcc+binutils.
The related discussion+patches are already on this list, e.g:
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00238.html
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00237.html
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00174.html
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00161.html
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00160.html
Quoted 2 lines
It seems you have spent a lot of effect to make it work, but some trick is not very appealing.
Which trick in particular is not appealing ?
The external linker script will be necessary also on other platforms where the builtin "ld -N" script does not work as expected. The hack in the loader is ugly, but was necessary to undo a hack in the PE backend of libbfd.
Here the diffstat for the cygwin changes based on the "-D 2008-03-27" CVS release:
Makefile.in | 4 + aclocal.m4 | 18 +++++ conf/i386-pc-cygwin-img-ld.sc | 53 +++++++++++++++ conf/i386-pc.rmk | 12 +-- configure.ac | 37 +++++++++++ genkernsyms.sh.in | 7 +- genmk.rb | 8 +- gensymlist.sh.in | 6 + include/grub/dl.h | 5 - include/grub/symbol.h | 6 + kern/dl.c | 40 +++++++++-- kern/i386/dl.c | 30 ++++++++ util/biosdisk.c | 34 +++++++--- util/getroot.c | 141 +++++++++++++++++++++++++++++++++++++++++- util/grub-mkdevicemap.c | 19 ++++- util/grub-probe.c | 25 ++++++- util/i386/pc/grub-install.in | 8 +- util/update-grub.in | 25 +++++-- util/update-grub_lib.in | 22 +----- 19 files changed, 436 insertions(+), 64 deletions(-)
These are IMO not so much changes for a rather different platform without native ELF support.
Quoted 3 lines
I personally don't mind, but I don't know
if it can be accepted by others.
OK, if there is no chance to get this accepted, grub2 project managers should tell me soon.
It does not make much sense to spent time sending cygwin releated patches upstream, when all these are eventually rejected.
Quoted 4 lines
...
Can you make it work with mingw, for example, use the -mno-cygwin compile flag ?
I have not planned to do this in the near future. Of course, it is possible, but there are more issues to solve:
No /dev/... device support, no native shell script support, CR/LF issues, ...
And: The PE->elf conversion problem will remain.
So a backward compatible fix for mingw would likely be much less appealing than the one for cygwin :-)
The cygwin port of grub2 is targeted to users who want a *n[iu]x environment, but (have to) use Windows as main work OS for whatever reason. They likely have already installed cygwin :-)
Christian
Quoted 2 lines · Christian Franke
OK, if there is no chance to get this accepted, grub2 project managers should tell me soon.
I'm not a project manager, but I would hate to see useful code discarded.
I think the ability to install GRUB from Windows would allow creating installers for Windows that install a free OS without reboots and would not rely on booting from any media other than the hard drive. I think a non-Cygwin port would be preferred for that, but Cygwin could be a useful stepping stone, a testbed and the build environment for the native port.
Quoted 2 lines
It does not make much sense to spent time sending cygwin releated patches upstream, when all these are eventually rejected.
Maybe we could start with simple changes that don't make the code significantly more complex?
I think it would be nice to have a universal infrastructure for all platforms that would use linker scripts instead of strip and objcopy on all platforms.
Perhaps you could clone git://repo.or.cz/grub2.git and keep the patches in your local copy? The great thing about git is that it relieves the urgency of merges, as the changes can be held as separate patches and rebased to the current tree as needed.
Quoted 3 lines
The cygwin port of grub2 is targeted to users who want a *n[iu]x environment, but (have to) use Windows as main work OS for whatever reason. They likely have already installed cygwin :-)
Why would they benefit from GRUB? Just wondering.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 9 lines · Pavel Roskin
Quoted 2 lines · Christian Franke
OK, if there is no chance to get this accepted, grub2 project managers should tell me soon.
I'm not a project manager, but I would hate to see useful code discarded.
:-)
Quoted 8 lines
I think the ability to install GRUB from Windows would allow creating installers for Windows that install a free OS without reboots and would not rely on booting from any media other than the hard drive. I think a non-Cygwin port would be preferred for that, but Cygwin could be a useful stepping stone, a testbed and the build environment for the native port.
Yes, it actually is. I also use cygwin to build the non-Cygwin packages for my other Windows ports (smartmontools, hdparm).
Cygwin's "kernel" is essentially a dll which emulates a Linux/POSIX API. The GRUB2 cygwin binaries need only the following files to run OOTB from Windows cmd.exe:
cygwin1.dll
cyglzo2-2.dll
cygncurses-8.dll (grub-emu only)
terminfo/c/cygwin (grub-emu only)
The shell scripts would require additional files from bash and coreutils, of course.
Quoted 4 lines
...
Maybe we could start with simple changes that don't make the code significantly more complex?
OK, then I would suggest to (re)start with the small change for grub-mkdevicemap.
http://lists.gnu.org/archive/html/grub-devel/2007-12/msg00179.html
The patch is still current and already got positive feedback from Marco and Robert. I can also repost it, if desired.
Quoted 4 lines
I think it would be nice to have a universal infrastructure for all platforms that would use linker scripts instead of strip and objcopy on all platforms.
objcopy has to be used if the native object format on a platform is not (the) ELF (variant the grub loader expects).
Unfortunately, libbfd is apparently not designed to support conversion of relocation info.
Quoted 2 lines
Perhaps you could clone
git://repo.or.cz/grub2.gitand keep the patches in your local copy?
OK, added this as remote to my repo.
Quoted 5 lines
The great thing about git is that it relieves the
urgency of merges, as the changes can be held as separate patches and rebased to the current tree as needed.
BTW: Thanks to the clean upstream changes, merging from CVS was never a problem since I started the Cygwin port in oct 2007.
Quoted 6 lines
Quoted 2 lines
The cygwin port of grub2 is targeted to users who want a *n[iu]x environment, but (have to) use Windows as main work OS for whatever reason. They likely have already installed cygwin :-)
Why would they benefit from GRUB? Just wondering.
The ability to maintain the boot manger and create rescue discs from Cygwin shell without reboot is useful. (There were some requests for a Cygwin release in the past, e.g: http://savannah.gnu.org/bugs/?20497)
Christian
Quoted 8 lines · Christian Franke
OK, then I would suggest to (re)start with the small change for grub-mkdevicemap.
http://lists.gnu.org/archive/html/grub-devel/2007-12/msg00179.html
The patch is still current and already got positive feedback from Marco and Robert.
I can also repost it, if desired.
I understand you were asked to commit it yourself. Did you get the write access to the repository?
Quoted 10 lines
Quoted 4 lines
I think it would be nice to have a universal infrastructure for all platforms that would use linker scripts instead of strip and objcopy on all platforms.
objcopy has to be used if the native object format on a platform is not (the) ELF (variant the grub loader expects).
Unfortunately, libbfd is apparently not designed to support conversion of relocation info.
I see.
Quoted 4 lines
Quoted 2 lines
Perhaps you could clone
git://repo.or.cz/grub2.gitand keep the patches in your local copy?OK, added this as remote to my repo.
One part of that patch is in the repository already. I saw that your patch makes some function static. I checked the source for missing prototypes, and committed the needed fixes. It should be trivial to merge.
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
The cygwin port of grub2 is targeted to users who want a *n[iu]x environment, but (have to) use Windows as main work OS for whatever reason. They likely have already installed cygwin :-)
Why would they benefit from GRUB? Just wondering.
The ability to maintain the boot manger and create rescue discs from Cygwin shell without reboot is useful.
I see. Thanks for your answers!
Signature · 2 lines
Regards, Pavel Roskin
Quoted 5 lines · Pavel Roskin
Quoted 2 lines · Christian Franke
OK, then I would suggest to (re)start with the small change for grub-mkdevicemap.
Quoted 10 lines
Quoted 5 lines
http://lists.gnu.org/archive/html/grub-devel/2007-12/msg00179.html
The patch is still current and already got positive feedback from Marco and Robert. I can also repost it, if desired.
I understand you were asked to commit it yourself. Did you get the write access to the repository?
No. Last post of this thread was:
http://lists.gnu.org/archive/html/grub-devel/2008-01/msg00540.html
Christian
Quoted 14 lines · Christian Franke
Quoted 13 lines · Pavel Roskin
Quoted 9 lines · Christian Franke
OK, then I would suggest to (re)start with the small change for grub-mkdevicemap.
http://lists.gnu.org/archive/html/grub-devel/2007-12/msg00179.html
The patch is still current and already got positive feedback from Marco and Robert.
I can also repost it, if desired.
Quoted 7 lines
Quoted 4 lines
I understand you were asked to commit it yourself. Did you get the write access to the repository?
No. Last post of this thread was:
http://lists.gnu.org/archive/html/grub-devel/2008-01/msg00540.html
Marco, you said (see URL above) you're ok with Christian having write access.
If this is so, do you have a minute to give it to him? thanks :-)
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call… if you are unable to speak? (as seen on /.)
Quoted 5 lines · Christian Franke
The cygwin distro does not include any cross compilation tools. A package that require tools not in the distro would not be accepted.
The package is actually build with native cygwin gcc+binutils.
Sorry, I got out of context. What was the problem with providing ELF-capable toolchain in cygwin again?
I think that'd be much better than adding support for PE to GRUB (either native or via conversion layers).
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call… if you are unable to speak? (as seen on /.)
Quoted 11 lines · Robert Millan
Quoted 5 lines · Christian Franke
The cygwin distro does not include any cross compilation tools. A package that require tools not in the distro would not be accepted.
The package is actually build with native cygwin gcc+binutils.
Sorry, I got out of context. What was the problem with providing ELF-capable toolchain in cygwin again?
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00233.html
http://lists.gnu.org/archive/html/grub-devel/2007-12/msg00014.html
In fact, something like a i386-linux cross gcc suite would be necessary.
Quoted 4 lines
I think that'd be much better than adding support for PE to GRUB (either native or via conversion layers).
Yes. But this only better in theory, unless someone maintains such a toolchain for the Cygwin distro.
In practice, there now exists a working grub2 package which builds with native gcc :-)
Christian
Quoted 8 lines · Christian Franke
Quoted 5 lines
I think that'd be much better than adding support for PE to GRUB (either native
or via conversion layers).Yes. But this only better in theory, unless someone maintains such a toolchain for the Cygwin distro.
I don't think it'd be that bad. ELF is the standard in binary format nowadays, with only Microsoft going their own, awkward way (as usual).
Alternatively, why don't you convert PE to ELF somewhere in util/ or so? See how the EFI port handles the reverse conversion (the ia64 patch adds more of this).
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call… if you are unable to speak? (as seen on /.)
Quoted 5 lines · Robert Millan
Alternatively, why don't you convert PE to ELF somewhere in util/ or so? See how the EFI port handles the reverse conversion (the ia64 patch adds more of this).
I already have such a tool (based on objcopy with a small fix for PE->ELF added). See this thread:
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00174.html
Christian
Quoted 10 lines · Christian Franke
Quoted 5 lines · Robert Millan
Alternatively, why don't you convert PE to ELF somewhere in util/ or so? See how the EFI port handles the reverse conversion (the ia64 patch adds more of this).
I already have such a tool (based on objcopy with a small fix for
PE->ELFadded). See this thread:
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00174.html
I understand that it may be difficult to fix this in a way the binutils maintainers will accept, but in your own words (from that thread), the alternative of fixing it in GRUB is a workaround.
GRUB (and specially this part of GRUB) is very constrained in size. A few bytes can make the difference between safely embedding core.img in the post-MBR area or jumping directly to a hard-coded offset in your filesystem. I think you should really try either fixing BFD or working around the problem somewhere else (the runtime ELF loader seems like the worst of all the options to me).
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call… if you are unable to speak? (as seen on /.)
Quoted 9 lines · Robert Millan
Quoted 4 lines
I already have such a tool (based on objcopy with a small fix for
PE->ELFadded). See this thread:
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00174.htmlI understand that it may be difficult to fix this in a way the binutils maintainers will accept, but in your own words (from that thread), the alternative of fixing it in GRUB is a workaround.
Yes, I will remove this hack.
Quoted 4 lines
I think you should really try either fixing BFD or working around the problem somewhere else (the runtime ELF loader seems like the worst of all the options to me).
Fixing this in BFD is difficult, the PE and ELF backends don't care about relocation format conversion.
To provide a self-contained package for Cygwin in the future, I will add the reduced+fixed objcopy to my branch of the source tree and modify Makefile accordingly.
I don't see any other option which fits into the limited time I have for this project.
Christian