Fix for building correct code on i386-pc (CVS-HEAD)
PATCH 1/1 Fix for building correct code on i386-pc (CVS-HEAD)
Hi,
... thanks.
Attached patch fixes problems for compiling correct code on i386-pc... other platforms needs to be modified similarly too...
Thanks,
Vesa Jääskeläinen
Index: conf/common.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/common.rmk,v
retrieving revision 1.7
common.rmk +33 -0
@@ -27,61 +27,73 @@ # For fshelp.mod. fshelp_mod_SOURCES = fs/fshelp.c fshelp_mod_CFLAGS = $(COMMON_CFLAGS) +fshelp_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) fshelp_mod_LDFLAGS = $(COMMON_LDFLAGS) # For fat.mod. fat_mod_SOURCES = fs/fat.c fat_mod_CFLAGS = $(COMMON_CFLAGS) +fat_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) fat_mod_LDFLAGS = $(COMMON_LDFLAGS) # For ufs.mod. ufs_mod_SOURCES = fs/ufs.c ufs_mod_CFLAGS = $(COMMON_CFLAGS) +ufs_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) ufs_mod_LDFLAGS = $(COMMON_LDFLAGS) # For ext2.mod. ext2_mod_SOURCES = fs/ext2.c ext2_mod_CFLAGS = $(COMMON_CFLAGS) +ext2_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) ext2_mod_LDFLAGS = $(COMMON_LDFLAGS) # For minix.mod. minix_mod_SOURCES = fs/minix.c minix_mod_CFLAGS = $(COMMON_CFLAGS) +minix_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) minix_mod_LDFLAGS = $(COMMON_LDFLAGS) # For hfs.mod. hfs_mod_SOURCES = fs/hfs.c hfs_mod_CFLAGS = $(COMMON_CFLAGS) +hfs_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) hfs_mod_LDFLAGS = $(COMMON_LDFLAGS) # For jfs.mod. jfs_mod_SOURCES = fs/jfs.c jfs_mod_CFLAGS = $(COMMON_CFLAGS) +jfs_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) jfs_mod_LDFLAGS = $(COMMON_LDFLAGS) # For iso9660.mod. iso9660_mod_SOURCES = fs/iso9660.c iso9660_mod_CFLAGS = $(COMMON_CFLAGS) +iso9660_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) iso9660_mod_LDFLAGS = $(COMMON_LDFLAGS) # For xfs.mod. xfs_mod_SOURCES = fs/xfs.c xfs_mod_CFLAGS = $(COMMON_CFLAGS) +xfs_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) xfs_mod_LDFLAGS = $(COMMON_LDFLAGS) # For affs.mod. affs_mod_SOURCES = fs/affs.c affs_mod_CFLAGS = $(COMMON_CFLAGS) +affs_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) affs_mod_LDFLAGS = $(COMMON_LDFLAGS) # For sfs.mod. sfs_mod_SOURCES = fs/sfs.c sfs_mod_CFLAGS = $(COMMON_CFLAGS) +sfs_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) sfs_mod_LDFLAGS = $(COMMON_LDFLAGS) # For hfsplus.mod. hfsplus_mod_SOURCES = fs/hfsplus.c hfsplus_mod_CFLAGS = $(COMMON_CFLAGS) +hfsplus_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) hfsplus_mod_LDFLAGS = $(COMMON_LDFLAGS) # Partition maps.
@@ -90,31 +102,37 @@ # For amiga.mod amiga_mod_SOURCES = partmap/amiga.c amiga_mod_CFLAGS = $(COMMON_CFLAGS) +amiga_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) amiga_mod_LDFLAGS = $(COMMON_LDFLAGS) # For apple.mod apple_mod_SOURCES = partmap/apple.c apple_mod_CFLAGS = $(COMMON_CFLAGS) +apple_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) apple_mod_LDFLAGS = $(COMMON_LDFLAGS) # For pc.mod pc_mod_SOURCES = partmap/pc.c pc_mod_CFLAGS = $(COMMON_CFLAGS) +pc_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) pc_mod_LDFLAGS = $(COMMON_LDFLAGS) # For sun.mod sun_mod_SOURCES = partmap/sun.c sun_mod_CFLAGS = $(COMMON_CFLAGS) +sun_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) sun_mod_LDFLAGS = $(COMMON_LDFLAGS) # For acorn.mod acorn_mod_SOURCES = partmap/acorn.c acorn_mod_CFLAGS = $(COMMON_CFLAGS) +acorn_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) acorn_mod_LDFLAGS = $(COMMON_LDFLAGS) # For gpt.mod gpt_mod_SOURCES = partmap/gpt.c gpt_mod_CFLAGS = $(COMMON_CFLAGS) +gpt_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) gpt_mod_LDFLAGS = $(COMMON_LDFLAGS)
@@ -127,71 +145,85 @@ # For hello.mod. hello_mod_SOURCES = hello/hello.c hello_mod_CFLAGS = $(COMMON_CFLAGS) +hello_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) hello_mod_LDFLAGS = $(COMMON_LDFLAGS) # For boot.mod. boot_mod_SOURCES = commands/boot.c boot_mod_CFLAGS = $(COMMON_CFLAGS) +boot_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) boot_mod_LDFLAGS = $(COMMON_LDFLAGS) # For terminal.mod. terminal_mod_SOURCES = commands/terminal.c terminal_mod_CFLAGS = $(COMMON_CFLAGS) +terminal_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) terminal_mod_LDFLAGS = $(COMMON_LDFLAGS) # For ls.mod. ls_mod_SOURCES = commands/ls.c ls_mod_CFLAGS = $(COMMON_CFLAGS) +ls_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) ls_mod_LDFLAGS = $(COMMON_LDFLAGS) # For cmp.mod. cmp_mod_SOURCES = commands/cmp.c cmp_mod_CFLAGS = $(COMMON_CFLAGS) +cmp_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) cmp_mod_LDFLAGS = $(COMMON_LDFLAGS) # For cat.mod. cat_mod_SOURCES = commands/cat.c cat_mod_CFLAGS = $(COMMON_CFLAGS) +cat_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) cat_mod_LDFLAGS = $(COMMON_LDFLAGS) # For help.mod. help_mod_SOURCES = commands/help.c help_mod_CFLAGS = $(COMMON_CFLAGS) +help_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) help_mod_LDFLAGS = $(COMMON_LDFLAGS) # For font.mod. font_mod_SOURCES = font/manager.c font_mod_CFLAGS = $(COMMON_CFLAGS) +font_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) font_mod_LDFLAGS = $(COMMON_LDFLAGS) # For search.mod. search_mod_SOURCES = commands/search.c search_mod_CFLAGS = $(COMMON_CFLAGS) +search_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) search_mod_LDFLAGS = $(COMMON_LDFLAGS) # For test.mod. test_mod_SOURCES = commands/test.c test_mod_CFLAGS = $(COMMON_CFLAGS) +test_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) test_mod_LDFLAGS = $(COMMON_LDFLAGS) # For loopback.mod loopback_mod_SOURCES = disk/loopback.c loopback_mod_CFLAGS = $(COMMON_CFLAGS) +loopback_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) loopback_mod_LDFLAGS = $(COMMON_LDFLAGS) # For configfile.mod configfile_mod_SOURCES = commands/configfile.c configfile_mod_CFLAGS = $(COMMON_CFLAGS) +configfile_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) configfile_mod_LDFLAGS = $(COMMON_LDFLAGS) # For terminfo.mod. terminfo_mod_SOURCES = term/terminfo.c term/tparm.c terminfo_mod_CFLAGS = $(COMMON_CFLAGS) +terminfo_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) terminfo_mod_LDFLAGS = $(COMMON_LDFLAGS) # For blocklist.mod. blocklist_mod_SOURCES = commands/blocklist.c blocklist_mod_CFLAGS = $(COMMON_CFLAGS) +blocklist_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) blocklist_mod_LDFLAGS = $(COMMON_LDFLAGS) # Misc.
@@ -200,6 +232,7 @@ # For gzio.mod. gzio_mod_SOURCES = io/gzio.c gzio_mod_CFLAGS = $(COMMON_CFLAGS) +gzio_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) gzio_mod_LDFLAGS = $(COMMON_LDFLAGS)
Index: conf/i386-pc.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.65
i386-pc.rmk +19 -0
@@ -2,6 +2,7 @@ COMMON_ASFLAGS = -nostdinc -fno-builtin COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32 +COMMON_TARGET_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32 COMMON_LDFLAGS = -melf_i386 -nostdlib # Images.
@@ -37,6 +38,7 @@ machine/memory.h machine/loader.h machine/time.h machine/vga.h \ machine/vbe.h kernel_img_CFLAGS = $(COMMON_CFLAGS) +kernel_img_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) kernel_img_ASFLAGS = $(COMMON_ASFLAGS) kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,8200 $(COMMON_CFLAGS)
@@ -117,21 +119,25 @@ # For _chain.mod. _chain_mod_SOURCES = loader/i386/pc/chainloader.c _chain_mod_CFLAGS = $(COMMON_CFLAGS) +_chain_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) _chain_mod_LDFLAGS = $(COMMON_LDFLAGS) # For chain.mod. chain_mod_SOURCES = loader/i386/pc/chainloader_normal.c chain_mod_CFLAGS = $(COMMON_CFLAGS) +chain_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) chain_mod_LDFLAGS = $(COMMON_LDFLAGS) # For _linux.mod. _linux_mod_SOURCES = loader/i386/pc/linux.c _linux_mod_CFLAGS = $(COMMON_CFLAGS) +_linux_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) _linux_mod_LDFLAGS = $(COMMON_LDFLAGS) # For linux.mod. linux_mod_SOURCES = loader/i386/pc/linux_normal.c linux_mod_CFLAGS = $(COMMON_CFLAGS) +linux_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) linux_mod_LDFLAGS = $(COMMON_LDFLAGS) # For normal.mod.
@@ -141,68 +147,81 @@ normal/menu_entry.c normal/misc.c grub_script.tab.c \ normal/script.c normal/i386/setjmp.S normal_mod_CFLAGS = $(COMMON_CFLAGS) +normal_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) normal_mod_ASFLAGS = $(COMMON_ASFLAGS) -m32 normal_mod_LDFLAGS = $(COMMON_LDFLAGS) # For reboot.mod. reboot_mod_SOURCES = commands/i386/pc/reboot.c reboot_mod_CFLAGS = $(COMMON_CFLAGS) +reboot_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) reboot_mod_LDFLAGS = $(COMMON_LDFLAGS) # For halt.mod. halt_mod_SOURCES = commands/i386/pc/halt.c halt_mod_CFLAGS = $(COMMON_CFLAGS) +halt_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) halt_mod_LDFLAGS = $(COMMON_LDFLAGS) # For serial.mod. serial_mod_SOURCES = term/i386/pc/serial.c serial_mod_CFLAGS = $(COMMON_CFLAGS) +serial_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) serial_mod_LDFLAGS = $(COMMON_LDFLAGS) # For _multiboot.mod. _multiboot_mod_SOURCES = loader/i386/pc/multiboot.c _multiboot_mod_CFLAGS = $(COMMON_CFLAGS) +_multiboot_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) _multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) # For multiboot.mod. multiboot_mod_SOURCES = loader/i386/pc/multiboot_normal.c multiboot_mod_CFLAGS = $(COMMON_CFLAGS) +multiboot_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) # For vbe.mod. vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \ video/i386/pc/vbefill.c vbe_mod_CFLAGS = $(COMMON_CFLAGS) +vbe_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) vbe_mod_LDFLAGS = $(COMMON_LDFLAGS) # For vbeinfo.mod. vbeinfo_mod_SOURCES = commands/i386/pc/vbeinfo.c vbeinfo_mod_CFLAGS = $(COMMON_CFLAGS) +vbeinfo_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) vbeinfo_mod_LDFLAGS = $(COMMON_LDFLAGS) # For vbetest.mod. vbetest_mod_SOURCES = commands/i386/pc/vbetest.c vbetest_mod_CFLAGS = $(COMMON_CFLAGS) +vbetest_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) vbetest_mod_LDFLAGS = $(COMMON_LDFLAGS) # For play.mod. play_mod_SOURCES = commands/i386/pc/play.c play_mod_CFLAGS = $(COMMON_CFLAGS) +play_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) play_mod_LDFLAGS = $(COMMON_LDFLAGS) # For video.mod. video_mod_SOURCES = video/video.c video_mod_CFLAGS = $(COMMON_CFLAGS) +video_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) video_mod_LDFLAGS = $(COMMON_LDFLAGS) # For gfxterm.mod. gfxterm_mod_SOURCES = term/gfxterm.c gfxterm_mod_CFLAGS = $(COMMON_CFLAGS) +gfxterm_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) gfxterm_mod_LDFLAGS = $(COMMON_LDFLAGS) # For videotest.mod. videotest_mod_SOURCES = commands/videotest.c videotest_mod_CFLAGS = $(COMMON_CFLAGS) +videotest_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) videotest_mod_LDFLAGS = $(COMMON_LDFLAGS) include $(srcdir)/conf/common.mk
Quoted 2 lines · Vesa Jääskeläinen
Attached patch fixes problems for compiling correct code on i386-pc... other platforms needs to be modified similarly too...
I'm confused by this; could you explain? If _TARGET_CFLAGS is used for everything to be run on the target, perhaps we should just rename _CFLAGS to _TARGET_CFLAGS.
Also, in the future, could you please supply best-guess code for other architectures? It's ok if you don't know, but in this case it seems it would be easy enough to duplicate your i386-pc.mk changes for the other .mk files.
Quoted 13 lines
Index: conf/common.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/common.rmk,v
retrieving revision 1.7
diff -u -r1.7 common.rmkcommon.rmk +1
-0@@ -27,61 +27,73 @@ # For fshelp.mod. fshelp_mod_SOURCES = fs/fshelp.c fshelp_mod_CFLAGS = $(COMMON_CFLAGS) +fshelp_mod_TARGET_CFLAGS = $(COMMON_TARGET_CFLAGS) fshelp_mod_LDFLAGS = $(COMMON_LDFLAGS)
...
Quoted 8 lines
i386-pc.rmk +1
-0@@ -2,6 +2,7 @@ COMMON_ASFLAGS = -nostdinc -fno-builtin COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32 +COMMON_TARGET_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32 COMMON_LDFLAGS = -melf_i386 -nostdlib
Quoted 4 lines · Hollis Blanchard
Quoted 2 lines · Vesa Jääskeläinen
Attached patch fixes problems for compiling correct code on i386-pc... other platforms needs to be modified similarly too...
Quoted 8 lines
I'm confused by this; could you explain? If
_TARGET_CFLAGSis used for everything to be run on the target, perhaps we should just rename_CFLAGSto_TARGET_CFLAGS.Also, in the future, could you please supply best-guess code for other architectures? It's ok if you don't know, but in this case it seems it would be easy enough to duplicate your i386-pc.mk changes for the other .mk files.
I am also confused. Is this keeping to the changes presented by Okuji? I don't think it is best to move from CFLAGS to something different, this would make it odd when porting to other OS, it also seems off convention.
Okuji's post:
http://lists.gnu.org/archive/html/grub-devel/2006-05/msg00106.html
Cheers
Harley
Quoted 2 lines · Harley D. Eades III
http://lists.gnu.org/archive/html/grub-devel/2006-05/msg00106.html
"host" and "target" are unclear to me here. For example, grub-emu would be compiled for the "host", but grub itself would be for the "target"? When would you ever want to build things differently like that?
Or is this just so you can specify "host" build flags which are totally separate from "target" flags (since the target is built as a freestanding executable)?
In that case, in Vesa's patch, CFLAGS shouldn't need any of these, right? -fno-builtin -mrtd -mregparm=3
-Hollis
Quoted 6 lines · Hollis Blanchard
Quoted 1 line · Harley D. Eades III
http://lists.gnu.org/archive/html/grub-devel/2006-05/msg00106.html
"host" and "target" are unclear to me here. For example, grub-emu would be compiled for the "host", but grub itself would be for the "target"? When would you ever want to build things differently like that?
This is one of the requested features for GRUB. In GRUB Legacy, some group developed GRUB on Sparc, but for PC by cross-compiling (actually, this was Alcatel). It is a good thing that you can install GRUB for an architecture on another.
Okuji
PATCH 1/1 Fix for configure on x86_64 (Was: Re: [patch] Fix for building correct code on i386-pc (CVS-HEAD))
At Wed, 31 May 2006 02:31:49 +0200,
Quoted 5 lines · Yoshinori K. Okuji
Quoted 3 lines · Hollis Blanchard
Quoted 1 line · Harley D. Eades III
http://lists.gnu.org/archive/html/grub-devel/2006-05/msg00106.html
Quoted 8 lines
Quoted 3 lines
"host" and "target" are unclear to me here. For example, grub-emu would be compiled for the "host", but grub itself would be for the "target"? When would you ever want to build things differently like that?
This is one of the requested features for GRUB. In GRUB Legacy, some group developed GRUB on Sparc, but for PC by cross-compiling (actually, this was Alcatel). It is a good thing that you can install GRUB for an architecture on another.
It's actually a necessary feature for GRUB on amd64. On amd64 you have 64-bit executables but GRUB will run in 32-bit mode.
When trying to compile on amd64 I already ran into some problems related to that. First of all on amd64 all binaries are run in 64-bit mode, so the host CFLAGS variable shouldn't have -m32. Secondly LIBS is for the host only and shouldn't be defined when running target tests. As last we set CFLAGS, CC, etc. to the TARGET_*, then we run some checks and change the TARGET_* flags without updating CC, CFLAGS, etc to the new version.
The attached patch should fix those problems. I've tested it on i386-pc and x86_64.
2006-05-31 Jeroen Dekkers <[email protected]>
* configure.ac: Don't set host_m32 for x86_64. Also reset LIBS for the target-specific tests. Make sure that we also have the up-to-date target variables for those tests.
Index: configure.ac
===================================================================
RCS file: /cvsroot/grub/grub2/configure.ac,v
retrieving revision 1.29
configure.ac +9 -1
@@ -41,7 +41,6 @@ AC_CANONICAL_HOST AC_CANONICAL_TARGET case "$host_cpu" in - x86_64) host_m32=1 ;; powerpc64) host_m32=1 ;; esac
@@ -186,10 +185,12 @@ tmp_CC="$CC" tmp_CFLAGS="$CFLAGS" tmp_LDFLAGS="$LDFLAGS" tmp_CPPFLAGS="$CPPFLAGS" +tmp_LIBS="$LIBS" CC="$TARGET_CC" CFLAGS="$TARGET_CFLAGS" CPPFLAGS="$TARGET_CPPFLAGS" LDFLAGS="$TARGET_LDFLAGS" +LIBS="" if test "x$TARGET_CFLAGS" = x; then # debug flags.
@@ -232,6 +233,12 @@ AC_SUBST(TARGET_CFLAGS) AC_SUBST(TARGET_CPPFLAGS) AC_SUBST(TARGET_LDFLAGS) +# Set them to their new values for the tests below. +CC="$TARGET_CC" +CFLAGS="$TARGET_CFLAGS" +CPPFLAGS="$TARGET_CPPFLAGS" +LDFLAGS="$TARGET_LDFLAGS" + # Defined in aclocal.m4. grub_PROG_OBJCOPY_ABSOLUTE grub_ASM_USCORE
@@ -252,6 +259,7 @@ CC="$tmp_CC" CFLAGS="$tmp_CFLAGS" CPPFLAGS="$tmp_CPPFLAGS" LDFLAGS="$tmp_LDFLAGS" +LIBS="$tmp_LIBS" # Check for options. AC_ARG_ENABLE([mm-debug],
Re: [PATCH] Fix for configure on x86_64 (Was: Re: [patch] Fix for building correct code on i386-pc (CVS-HEAD))
Quoted 11 lines · Jeroen Dekkers
It's actually a necessary feature for GRUB on amd64. On amd64 you have 64-bit executables but GRUB will run in 32-bit mode.
When trying to compile on amd64 I already ran into some problems related to that. First of all on amd64 all binaries are run in 64-bit mode, so the host CFLAGS variable shouldn't have -m32. Secondly LIBS is for the host only and shouldn't be defined when running target tests. As last we set CFLAGS, CC, etc. to the TARGET_*, then we run some checks and change the TARGET_* flags without updating CC, CFLAGS, etc to the new version.
Quoted 2 lines
The attached patch should fix those problems. I've tested it on i386-pc and
x86_64.
It looks good. Please check it in.
Thanks,
Okuji
PATCH 1/1 Another fix for x86_64
At Thu, 1 Jun 2006 17:39:13 +0200,
Quoted 13 lines · Yoshinori K. Okuji
Quoted 11 lines · Jeroen Dekkers
It's actually a necessary feature for GRUB on amd64. On amd64 you have 64-bit executables but GRUB will run in 32-bit mode.
When trying to compile on amd64 I already ran into some problems related to that. First of all on amd64 all binaries are run in 64-bit mode, so the host CFLAGS variable shouldn't have -m32. Secondly LIBS is for the host only and shouldn't be defined when running target tests. As last we set CFLAGS, CC, etc. to the TARGET_*, then we run some checks and change the TARGET_* flags without updating CC, CFLAGS, etc to the new version.
Quoted 4 lines
Quoted 2 lines
The attached patch should fix those problems. I've tested it on i386-pc and
x86_64.It looks good. Please check it in.
Now I actually booted GRUB 2 in qemu, I found another bug. :-) We are still using grub_host_* types in grub/kernel.h, but the types of those changed. We should use grub_target_* types there. As I didn't see any other use of grub_host_* types, I just renamed those to grub_target_* and changed the #ifdef. See the patch below.
Jeroen Dekkers
2006-06-07 Jeroen Dekkers <[email protected]>
* include/grub/types.h (grub_host_addr_t): Rename to grub_target_addr_t.
(grub_host_off_t): Rename to grub_target_off_t. (grub_host_size_t): Rename to grub_target_size_t. (grub_host_ssize_t): Rename to grub_target_ssize_t. Refer to GRUB_TARGET_SIZEOF_VOID_P to define those variables.
* include/grub/kernel.h (struct grub_module_header): Change type of OFFSET to grub_target_off_t and type of SIZE to grub_target_size_t. (grub_module_info): Likewise.
Index: include/grub/kernel.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/kernel.h,v retrieving revision 1.8
grub/kernel.h 7 Jun 2006 11:12:39 -0000 renamed from grub/kernel.h 25 Apr 2006 20:08:31 -0000 1.8 +4 -4
@@ -26,9 +26,9 @@ struct grub_module_header { /* The offset of object code. */ - grub_host_off_t offset; + grub_target_off_t offset; /* The size of object code plus this header. */ - grub_host_size_t size; + grub_target_size_t size; }; /* "gmim" (GRUB Module Info Magic). */
@@ -39,9 +39,9 @@ struct grub_module_info /* Magic number so we know we have modules present. */ grub_uint32_t magic; /* The offset of the modules. */ - grub_host_off_t offset; + grub_target_off_t offset; /* The size of all modules plus this header. */ - grub_host_size_t size; + grub_target_size_t size; }; extern grub_addr_t grub_arch_modules_addr (void);
Index: include/grub/types.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/types.h,v retrieving revision 1.9
grub/types.h 7 Jun 2006 11:12:39 -0000 renamed from grub/types.h 4 Jun 2006 15:56:54 -0000 1.9 +9 -9
@@ -69,16 +69,16 @@ typedef unsigned long long grub_uint64_t #endif /* Misc types. */ -#if SIZEOF_VOID_P == 8 -typedef grub_uint64_t grub_host_addr_t; -typedef grub_uint64_t grub_host_off_t; -typedef grub_uint64_t grub_host_size_t; -typedef grub_int64_t grub_host_ssize_t; +#if GRUB_TARGET_SIZEOF_VOID_P == 8 +typedef grub_uint64_t grub_target_addr_t; +typedef grub_uint64_t grub_target_off_t; +typedef grub_uint64_t grub_target_size_t; +typedef grub_int64_t grub_target_ssize_t; #else -typedef grub_uint32_t grub_host_addr_t; -typedef grub_uint32_t grub_host_off_t; -typedef grub_uint32_t grub_host_size_t; -typedef grub_int32_t grub_host_ssize_t; +typedef grub_uint32_t grub_target_addr_t; +typedef grub_uint32_t grub_target_off_t; +typedef grub_uint32_t grub_target_size_t; +typedef grub_int32_t grub_target_ssize_t; #endif #if GRUB_CPU_SIZEOF_VOID_P == 8
Re: [PATCH] Another fix for x86_64
Jeroen Dekkers <[email protected]> writes:
[...]
Quoted 5 lines
Now I actually booted GRUB 2 in qemu, I found another bug. :-) We are still using grub_host_* types in
grub/kernel.h, but the types of those changed. We should use grub_target_* types there. As I didn't see any other use of grub_host_* types, I just renamed those to grub_target_* and changed the #ifdef. See the patch below.
This looks fine to me, could you please commit this patch?
--
Marco
Vesa Jääskeläinen <[email protected]> writes:
Hi Vesa,
Quoted 2 lines
Attached patch fixes problems for compiling correct code on i386-pc... other platforms needs to be modified similarly too...
Isn't this also required for the kernel? How about replacing the module specific CLFAGs, instead of adding TARGET_CFLAG? I assume the old one isn't used anymore...
--
Marco
Quoted 2 lines · Vesa Jääskeläinen
Attached patch fixes problems for compiling correct code on i386-pc... other platforms needs to be modified similarly too...
Sorry. This is my mistake. I've fixed it differently right now.
Okuji