Skip to contentSkip to conversation

bug: cygwin support breaks cross compiles on cygwin

DISCUSSION Patrick Georgi 5 participants 9 messages Aug 8, 2008 – Aug 9, 2008

lore
Share & tools
lore
#0 lore raw

Hi,

I used cygwin to build grub2/i386-coreboot using an i386-elf cross compiler. unfortunately the test in configure only looks for the host platform and enables pe2elf in that case, even though my compiler emits ELF already.

my workaround is to just change that test (there's no OS cyg_win), but of course that's no permanent solution. Bean proposed on IRC to look if the target compiler emits PE, and enable pe2elf based on that.

Regards,
Patrick Georgi

#1 lore raw
Quoted 10 lines · Patrick Georgi

Hi,

I used cygwin to build grub2/i386-coreboot using an i386-elf cross compiler. unfortunately the test in configure only looks for the host platform and enables pe2elf in that case, even though my compiler emits ELF already.

my workaround is to just change that test (there's no OS cyg_win), but of course that's no permanent solution.
Bean proposed on IRC to look if the target compiler emits PE, and enable pe2elf based on that.

Hi,

Yes, we can solve this with script. Another way is to do some test in grub-pe2elf. If the image is already elf, it does nothing and return true. This should fix the problem as well.

Signature · 1 line
Bean
#2 lore raw
In reply to Patrick Georgi
Quoted 8 lines · Patrick Georgi

Hi,

I used cygwin to build grub2/i386-coreboot using an i386-elf cross compiler. unfortunately the test in configure only looks for the host platform and enables pe2elf in that case, even though my compiler emits ELF already.

my workaround is to just change that test (there's no OS cyg_win), but of course that's no permanent solution. Bean proposed on IRC to look if the target compiler emits PE, and enable pe2elf based on that.

Thanks for the info.

A simple fix is probably a test for target_os also, please try attached patch (and re-run autoconf).

Christian

configure.ac +4 -3
index 7a5938a..41e08f1 100644
@@ -206,9 +206,10 @@ AC_MSG_RESULT([$TARGET_IMG_LDFLAGS_AC])
 
 # For platforms where ELF is not the default link format.
 AC_MSG_CHECKING([for command to convert module to ELF format])
-if test "$host_os" = cygwin; then
-  TARGET_OBJ2ELF='grub-pe2elf.exe'
-fi
+case "${host_os}:${target_os}" in
+  cygwin:cygwin) TARGET_OBJ2ELF='grub-pe2elf.exe' ;;
+  *) ;;
+esac
 AC_SUBST(TARGET_OBJ2ELF)
 AC_MSG_RESULT([$TARGET_OBJ2ELF])
 
#3 lore raw
In reply to Patrick Georgi
Quoted 11 lines · Patrick Georgi

Hi,

I used cygwin to build grub2/i386-coreboot using an i386-elf cross compiler. unfortunately the test in configure only looks for the host platform and enables pe2elf in that case, even though my compiler emits ELF already.

my workaround is to just change that test (there's no OS cyg_win), but of course that's no permanent solution.
Bean proposed on IRC to look if the target compiler emits PE, and enable pe2elf based on that.

I have observed that grub-pe2elf is included even in native builds for ELF platforms. Perhaps this is caused by the same bug?

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#4 lore raw
Quoted 4 lines · Robert Millan
Quoted 2 lines · Patrick Georgi

Hi,

Quoted 10 lines
Quoted 5 lines

I used cygwin to build grub2/i386-coreboot using an i386-elf cross compiler. unfortunately the test in configure only looks for the host platform and enables pe2elf in that case, even though my compiler emits ELF already.

my workaround is to just change that test (there's no OS cyg_win), but of course that's no permanent solution. Bean proposed on IRC to look if the target compiler emits PE, and enable pe2elf based on that.

I have observed that grub-pe2elf is included even in native builds for ELF platforms. Perhaps this is caused by the same bug?

No, grub-pe2elf is build and installed even if is not necessary for the build process. This should be no problem.

Christian

#5 lore raw

Hello,

Am Freitag, den 08.08.2008, 14:59 +0200 schrieb Christian Franke:

Quoted 4 lines

No, grub-pe2elf is build and installed even if is not necessary for the build process. This should be no problem.

Well it's the same as with that --enable-debug thingy ;)

In our Debian trunk SVN I already commited a change to remove grub.d/10_windows because Debian/Ubuntu users just don't have a need for this.
It would be better if Robert and me don't need to do such changes. We could just remove grub-pe2elf, too.
But why should it be build for everybody if only Cygwin users have a use for it?
Then clearly the whole build process needs a change so that grub-pe2elf is only build on Cygwin.
I doubt GRUB 2 is/will be used that much on Cygwin as with native Linux.

#6 lore raw
Quoted 10 lines · Felix Zielcke

Hello,

Am Freitag, den 08.08.2008, 14:59 +0200 schrieb Christian Franke:

Quoted 3 lines

No, grub-pe2elf is build and installed even if is not necessary for the build process. This should be no problem.

Well it's the same as with that --enable-debug thingy ;)

Quoted 10 lines

In our Debian trunk SVN I already commited a change to remove grub.d/10_windows because Debian/Ubuntu users just don't have a need for this.
It would be better if Robert and me don't need to do such changes. We could just remove grub-pe2elf, too.
But why should it be build for everybody if only Cygwin users have a use for it?
Then clearly the whole build process needs a change so that grub-pe2elf is only build on Cygwin.

I agree. I posted a patch which handles both grub.d/10_windows and grub-pe2elf.

Christian

#7 lore raw

Hello,

Am Freitag, den 08.08.2008, 23:13 +0200 schrieb Christian Franke:

Quoted 4 lines

I agree. I posted a patch which handles both grub.d/10_windows and grub-pe2elf.

Thanks I even saw that mail before this.
I even reverted now my rm -f 10_windows change to current Debian trunk, but to commit I wait untill your patch is commited upstream ;)

#8 lore raw
Quoted 13 lines · Felix Zielcke

Am Freitag, den 08.08.2008, 23:13 +0200 schrieb Christian Franke:

Quoted 3 lines

I agree. I posted a patch which handles both grub.d/10_windows and grub-pe2elf.

Thanks I even saw that mail before this.
I even reverted now my rm -f 10_windows change to current Debian trunk, but to commit I wait untill your patch is commited upstream ;)

Done.

The quick fix for the cross-compiler problem is also included. Does not actually check the output format of the target compiler, but should work for now.

Christian