Cross compiling GRUB 1.95
I am trying to cross compile GRUB 1.95 from an i686 linux system to an i686 linux uclibc system. However, when I run the configure script I get the error:
checking if GCC has the regparm=3 bug... configure: error: cannot run test program while cross compiling
How can I bypass this test or otherwise get it to compile?
Quoted 8 lines · Will Buik
I am trying to cross compile GRUB 1.95 from an i686 linux system to an i686 linux uclibc system. However, when I run the configure script I get the error:
checking if GCC has the regparm=3 bug... configure: error: cannot run test program while cross compiling
How can I bypass this test or otherwise get it to compile?
Hmm. From the documentation
(http://www.gnu.org/software/autoconf/manual/html_node/Runtime.html), I would expect something like the following to work:
Index: aclocal.m4
===================================================================
RCS file: /cvsroot/grub/grub2/aclocal.m4,v
retrieving revision 1.5
aclocal.m4 14 Nov 2006 03:14:21 -0000 renamed from aclocal.m4 13 Aug 2005 18:44:14 -0000 1.5 +1 -0
@@ -327,6 +327,7 @@ main (void) } ]])], [grub_cv_i386_check_nested_functions=no], + [grub_cv_i386_check_nested_functions=yes], [grub_cv_i386_check_nested_functions=yes])]) AC_MSG_RESULT([$grub_cv_i386_check_nested_functions])
Even worse though, it seems this test is totally ignored -- regparm(2) is always used, no matter the outcome. So perhaps we should do this instead:
Index: aclocal.m4
===================================================================
RCS file: /cvsroot/grub/grub2/aclocal.m4,v
retrieving revision 1.5
aclocal.m4 14 Nov 2006 03:17:44 -0000 renamed from aclocal.m4 13 Aug 2005 18:44:14 -0000 1.5 +0 -51
54 lines not on this page · raw message
Index: configure.ac
===================================================================
RCS file: /cvsroot/grub/grub2/configure.ac,v
retrieving revision 1.33
configure.ac 14 Nov 2006 03:17:44 -0000 renamed from configure.ac 12 Jul 2006 20:42:52 -0000 1.33 +7 -1
@@ -253,7 +253,13 @@ if test "x$target_cpu" = xi386; then grub_I386_ASM_PREFIX_REQUIREMENT grub_I386_ASM_ADDR32 grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK - grub_I386_CHECK_REGPARM_BUG + + # Check if the C compiler has a bug while using nested functions when + # mregparm is used on the i386. Some gcc versions do not pass the third + # parameter correctly to the nested function. + AC_DEFINE([NESTED_FUNC_ATTR], + [__attribute__ ((__regparm__ (2)))], + [Catch gcc bug]) else AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug]) fi
But wait, it gets even better! It turns out there are almost no users of NESTED_FUNC_ATTR in grub2; only a few filesystems use it. If it only affects nested functions with three or more arguments, then at least functions like read_blocklist() would be broken. (If it affects all nested functions, then almost everything is broken.)
Some attention is needed here from people who know what NESTED_FUNC_ATTR is supposed to be doing.
-Hollis