Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1EHrVW-0005tr-12 for mharc-grub-devel@gnu.org; Tue, 20 Sep 2005 19:26:38 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EHrVR-0005rv-Aw for grub-devel@gnu.org; Tue, 20 Sep 2005 19:26:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EHrVM-0005pn-C5 for grub-devel@gnu.org; Tue, 20 Sep 2005 19:26:30 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EHrVK-0005bm-6b for grub-devel@gnu.org; Tue, 20 Sep 2005 19:26:27 -0400 Received: from [66.163.179.102] (helo=web35308.mail.mud.yahoo.com) by monty-python.gnu.org with smtp (Exim 4.34) id 1EHrGj-0000qU-Dz for grub-devel@gnu.org; Tue, 20 Sep 2005 19:11:21 -0400 Received: (qmail 9518 invoked by uid 60001); 20 Sep 2005 23:10:59 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=c0BrBOfM8LOD5cxTT97utuLohMvtcLBEIa83qurn7kdIQ4+6gbIGO1NZv0lxF4fX01dKmQpzW3QFf/XI0rd//vrYVTKxPkqrbG0Ajb/eCHPcszUGA2Thz7zSTIHZK9227S6PlOIjQRHCuI0HD4ijgByOmeRuQHyvYmuoM993D0w= ; Message-ID: <20050920231059.9516.qmail@web35308.mail.mud.yahoo.com> Received: from [84.53.202.16] by web35308.mail.mud.yahoo.com via HTTP; Tue, 20 Sep 2005 16:10:59 PDT Date: Tue, 20 Sep 2005 16:10:59 -0700 (PDT) From: Ruslan Nikolaev To: grub-devel@gnu.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1442312669-1127257859=:9159" Content-Transfer-Encoding: 8bit Subject: [PATCH] new patch for amd64 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Sep 2005 23:26:35 -0000 --0-1442312669-1127257859=:9159 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi all! I have seen another patch for amd64 by Marco Gerards. In fact month ago I sent the patch that also allows compiling on x86_64. By the way I decided to send new patch (it's really works with amd64). Some bugs was fixed: - it doesn't break x86 compiling now (small bug) - it allows you to compile grub even you haven't libc32 and other 32-bit libraries and OS doesn't support executing 32-bit binaries. Of course -m32 gcc param is always available. But as you can see you also can't check regparm=3 bug in this case :( That is why for x86_64 always using regparm=2 for nested functions in this patch. !!! PLEASE NOTE THAT IT'S NOT REAL NEED TO DO SPECIAL AMD64 VERSION BECAUSE USER CAN CHOOSE TO LOAD 32-bit operating system under x86_64. Moreover you can't switch to 64-bit by bootloader because you need enable paging first (that is not very clear to do by bootloader). NEW PATCH: diff -urN old/configure.ac new/configure.ac --- old/configure.ac 2005-09-11 11:07:36.000000000 +0400 +++ new/configure.ac 2005-09-11 11:19:36.000000000 +0400 @@ -22,6 +22,7 @@ case "$host_cpu" in i[[3456]]86) host_cpu=i386 ;; + x86_64) ;; powerpc) ;; sparc64) ;; *) AC_MSG_ERROR([unsupported CPU type]) ;; @@ -29,6 +30,7 @@ case "$host_cpu"-"$host_vendor" in i386-*) host_vendor=pc ;; + x86_64-*) host_vendor=pc ;; powerpc-*) host_vendor=ieee1275 ;; sparc64-*) host_vendor=ieee1275 ;; *) AC_MSG_ERROR([unsupported machine type]) ;; @@ -64,8 +66,8 @@ tmp_CFLAGS="$tmp_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops" fi - # Force no alignment to save space on i386. - if test "x$host_cpu" = xi386; then + # Force no alignment to save space on i386/x86_64. + if test "x$host_cpu" = xi386 -o "x$host_cpu" = xx86_64; then AC_CACHE_CHECK([whether -falign-loops works], [falign_loop_flag], [ CFLAGS="-falign-loops=1" AC_TRY_COMPILE(, , [falign_loop_flag=yes], [falign_loop_flag=no]) @@ -84,21 +86,35 @@ # Defined in aclocal.m4. grub_ASM_USCORE -if test "x$host_cpu" = xi386; then +if test "x$host_cpu" = xi386 -o "x$host_cpu" = xx86_64; then grub_CHECK_START_SYMBOL grub_CHECK_BSS_START_SYMBOL grub_CHECK_END_SYMBOL fi -if test "x$host_cpu" = xi386; then +if test "x$host_cpu" = xi386 -o "x$host_cpu" = xx86_64; then grub_I386_ASM_PREFIX_REQUIREMENT grub_I386_ASM_ADDR32 grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK - grub_I386_CHECK_REGPARM_BUG + # There is no clean decision how to detect regparm=3 bug on x86_64 + if test "x$host_cpu" = xi386; then + grub_I386_CHECK_REGPARM_BUG + else + AC_DEFINE([NESTED_FUNC_ATTR], [__attribute__ ((__regparm__ (2)))], [Catch gcc bug]) + fi else AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug]) fi +# Keep CC for BUILD_CC +CC_ARCH="$CC" + +# Override x86_64 settings +if test "x$host_cpu" = xx86_64; then + CC="$CC -m32" + LD="ld -melf_i386" +fi + AC_PROG_INSTALL AC_PROG_MAKE_SET AC_CHECK_TOOL(OBJCOPY, objcopy) @@ -115,7 +131,7 @@ AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc], [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])]) else - BUILD_CC="$CC" + BUILD_CC="$CC_ARCH" AC_SUBST(BUILD_CC) fi @@ -132,8 +148,8 @@ AC_CHECK_SIZEOF(void *) AC_CHECK_SIZEOF(long) -# Check LZO when compiling for the i386. -if test "x$host_cpu" = xi386; then +# Check LZO when compiling for the i386/x86_64. +if test "x$host_cpu" = xi386 -o "x$host_cpu" = xx86_64; then # There are three possibilities. LZO version 2 installed with the name # liblzo2, with the name liblzo, and LZO version 1. AC_CHECK_LIB(lzo2, __lzo_init_v2, [LIBLZO="-llzo2"], @@ -161,6 +177,13 @@ CFLAGS="$tmp_CFLAGS" CPPFLAGS="$tmp_CPPFLAGS" +# Create links for x86_64 +if test "x$host_cpu" = xx86_64; then + AC_CONFIG_LINKS([include/grub/x86_64:include/grub/i386 + conf/x86_64-$host_vendor.mk:conf/i386-$host_vendor.mk + conf/x86_64-$host_vendor.rmk:conf/i386-$host_vendor.rmk]) +fi + # Output files. AC_CONFIG_LINKS([include/grub/cpu:include/grub/$host_cpu include/grub/machine:include/grub/$host_cpu/$host_vendor]) --------------------------------- Yahoo! for Good Click here to donate to the Hurricane Katrina relief effort. --0-1442312669-1127257859=:9159 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit
Hi all!
I have seen another patch for amd64 by Marco Gerards. In fact month ago I sent the patch that also allows compiling on x86_64.
 
By the way I decided to send new patch (it's really works with amd64).
 
Some bugs was fixed:
- it doesn't break x86 compiling now (small bug)
- it allows you to compile grub even you haven't libc32 and other 32-bit libraries and OS doesn't support executing 32-bit binaries. Of course -m32 gcc param is always available. But as you can see you also can't check regparm=3 bug in this case :( That is why for x86_64 always using regparm=2 for nested functions in this patch.
 
!!! PLEASE NOTE THAT IT'S NOT REAL NEED TO DO SPECIAL AMD64 VERSION BECAUSE USER CAN CHOOSE TO LOAD 32-bit operating system under x86_64. Moreover you can't switch to 64-bit by bootloader because you need enable paging first (that is not very clear to do by bootloader).
 
NEW PATCH:
 
diff -urN old/configure.ac new/configure.ac
--- old/configure.ac 2005-09-11 11:07:36.000000000 +0400
+++ new/configure.ac 2005-09-11 11:19:36.000000000 +0400
@@ -22,6 +22,7 @@
 
 case "$host_cpu" in
   i[[3456]]86) host_cpu=i386 ;;
+  x86_64) ;;
   powerpc) ;;
   sparc64) ;;
   *) AC_MSG_ERROR([unsupported CPU type]) ;;
@@ -29,6 +30,7 @@
 
 case "$host_cpu"-"$host_vendor" in
   i386-*) host_vendor=pc ;;
+  x86_64-*) host_vendor=pc ;;
   powerpc-*) host_vendor=ieee1275 ;;
   sparc64-*) host_vendor=ieee1275 ;;
   *) AC_MSG_ERROR([unsupported machine type]) ;;
@@ -64,8 +66,8 @@
     tmp_CFLAGS="$tmp_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops"
   fi
 
-  # Force no alignment to save space on i386.
-  if test "x$host_cpu" = xi386; then
+  # Force no alignment to save space on i386/x86_64.
+  if test "x$host_cpu" = xi386 -o "x$host_cpu" = xx86_64; then
     AC_CACHE_CHECK([whether -falign-loops works], [falign_loop_flag], [
       CFLAGS="-falign-loops=1"
       AC_TRY_COMPILE(, , [falign_loop_flag=yes], [falign_loop_flag=no])
@@ -84,21 +86,35 @@
 
 # Defined in aclocal.m4.
 grub_ASM_USCORE
-if test "x$host_cpu" = xi386; then
+if test "x$host_cpu" = xi386 -o "x$host_cpu" = xx86_64; then
   grub_CHECK_START_SYMBOL
   grub_CHECK_BSS_START_SYMBOL
   grub_CHECK_END_SYMBOL
 fi
 
-if test "x$host_cpu" = xi386; then
+if test "x$host_cpu" = xi386 -o "x$host_cpu" = xx86_64; then
   grub_I386_ASM_PREFIX_REQUIREMENT
   grub_I386_ASM_ADDR32
   grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK
-  grub_I386_CHECK_REGPARM_BUG
+  # There is no clean decision how to detect regparm=3 bug on x86_64
+  if test "x$host_cpu" = xi386; then
+    grub_I386_CHECK_REGPARM_BUG
+  else
+    AC_DEFINE([NESTED_FUNC_ATTR], [__attribute__ ((__regparm__ (2)))], [Catch gcc bug])
+  fi
 else
   AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug])
 fi
 
+# Keep CC for BUILD_CC
+CC_ARCH="$CC"
+
+# Override x86_64 settings
+if test "x$host_cpu" = xx86_64; then
+  CC="$CC -m32"
+  LD="ld -melf_i386"
+fi
+
 AC_PROG_INSTALL
 AC_PROG_MAKE_SET
 AC_CHECK_TOOL(OBJCOPY, objcopy)
@@ -115,7 +131,7 @@
   AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
    [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
 else
-  BUILD_CC="$CC"
+  BUILD_CC="$CC_ARCH"
   AC_SUBST(BUILD_CC)
 fi
 
@@ -132,8 +148,8 @@
 AC_CHECK_SIZEOF(void *)
 AC_CHECK_SIZEOF(long)
 
-# Check LZO when compiling for the i386.
-if test "x$host_cpu" = xi386; then
+# Check LZO when compiling for the i386/x86_64.
+if test "x$host_cpu" = xi386 -o "x$host_cpu" = xx86_64; then
   # There are three possibilities. LZO version 2 installed with the name
   # liblzo2, with the name liblzo, and LZO version 1.
   AC_CHECK_LIB(lzo2, __lzo_init_v2, [LIBLZO="-llzo2"],
@@ -161,6 +177,13 @@
 CFLAGS="$tmp_CFLAGS"
 CPPFLAGS="$tmp_CPPFLAGS"
 
+# Create links for x86_64
+if test "x$host_cpu" = xx86_64; then
+  AC_CONFIG_LINKS([include/grub/x86_64:include/grub/i386
+ conf/x86_64-$host_vendor.mk:conf/i386-$host_vendor.mk
+ conf/x86_64-$host_vendor.rmk:conf/i386-$host_vendor.rmk])
+fi
+
 # Output files.
 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$host_cpu
  include/grub/machine:include/grub/$host_cpu/$host_vendor])
 


Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort. --0-1442312669-1127257859=:9159--