[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] new patch for amd64

From: Ruslan Nikolaev
Subject: [PATCH] new patch for amd64
Date: Tue, 20 Sep 2005 16:10:59 -0700 (PDT)

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).
diff -urN old/ new/
--- old/ 2005-09-11 11:07:36.000000000 +0400
+++ new/ 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"
-  # 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], [
       AC_TRY_COMPILE(, , [falign_loop_flag=yes], [falign_loop_flag=no])
@@ -84,21 +86,35 @@
 # Defined in aclocal.m4.
-if test "x$host_cpu" = xi386; then
+if test "x$host_cpu" = xi386 -o "x$host_cpu" = xx86_64; then
-if test "x$host_cpu" = xi386; then
+if test "x$host_cpu" = xi386 -o "x$host_cpu" = xx86_64; then
+  # 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
   AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug])
+# Keep CC for BUILD_CC
+# Override x86_64 settings
+if test "x$host_cpu" = xx86_64; then
+  CC="$CC -m32"
+  LD="ld -melf_i386"
@@ -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.])])
@@ -132,8 +148,8 @@
-# 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 @@
+# 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-$$
+ conf/x86_64-$host_vendor.rmk:conf/i386-$host_vendor.rmk])
 # Output files.

Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.
reply via email to

[Prev in Thread] Current Thread [Next in Thread]