All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] new patch for amd64
@ 2005-09-20 23:10 Ruslan Nikolaev
  2005-09-21 11:38 ` Yoshinori K. Okuji
  2005-09-21 13:07 ` [PATCH] new patch for amd64 Marco Gerards
  0 siblings, 2 replies; 10+ messages in thread
From: Ruslan Nikolaev @ 2005-09-20 23:10 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 4191 bytes --]

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. 

[-- Attachment #2: Type: text/html, Size: 5458 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-09-24 22:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-20 23:10 [PATCH] new patch for amd64 Ruslan Nikolaev
2005-09-21 11:38 ` Yoshinori K. Okuji
2005-09-21 23:03   ` 2Yoshinori K. Okuji Ruslan Nikolaev
2005-09-21 13:07 ` [PATCH] new patch for amd64 Marco Gerards
2005-09-21 22:47   ` 2Marco Gerards Ruslan Nikolaev
2005-09-21 23:10     ` 2Marco Gerards (new) Ruslan Nikolaev
2005-09-22 18:16       ` Marco Gerards
2005-09-22 22:43         ` 2Marco Gerards (important info) Ruslan Nikolaev
2005-09-23 13:46           ` Marco Gerards
2005-09-24 22:17             ` 2Marco Gerards (answer) Ruslan Nikolaev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.