On 05/07/15 20:31 -0700, Daniel Schepler said ... > builtins.c: In function 'blocklist_func': > builtins.c:145: error: invalid storage class for function > 'disk_read_blocklist_func' > builtins.c:145: warning: no previous prototype for 'disk_read_blocklist_func' > builtins.c: In function 'color_func': > builtins.c:609: error: invalid storage class for function 'color_number' > builtins.c:609: warning: no previous prototype for 'color_number'
There were multiple issues in getting grub compiled with gcc 4.0. The patches and explanation for some of these included here. 1. static vars in smp-imps.c are extern in smp-imps.h and smp-imps.h is #included in smp-imps.c. 2. subfuctions used in builtins.c, char_io.c, device.c and asmstub.c are static. The savedefault_helper should be declared before use. 3. console_current_color variable is extern from term.h but declared as static and initialised in asmstub.c gcc4.0 doesn't allow any of these with the current flags used to compile grub. smp-imps.diff, static_subfunc.diff and console_current_color.diff fix the above three respectively. And can be included from debian/patches with 00list.patch applied. However, there are a few more issues: 1. -fwritable-strings is used by grub ... and from ChangeLog 1999-03-26 OKUJI Yoshinori <[EMAIL PROTECTED]> [snip] * grub/Makefile.am (CPPFLAGS): Use -fwritable-strings, because grub assumes that all strings resides at the data section. ... but gcc 4.0 no longer accepts the -fwritable-strings option. It is recommended that character arrays be used for writable strings. With the above patches applied I was able to compile, and after removing -fwritable-strings from {grub,stage2}/Makefile.{am,in}, I managed to successfully build a grub_0.95+cvs20040624-17_i386.deb using 'dpkg-buildpackage -B -uc -rfakeroot'. 2. 'dpkg-buildpackage -b -uc -rfakeroot' doesn't work inspite of the above patches. Giridhar -- Y Giridhar Appaji Nag | http://www.appaji.net/
diff -Nur grub-0.95+cvs20040624.orig/stage2/smp-imps.c grub-0.95+cvs20040624/stage2/smp-imps.c --- grub-0.95+cvs20040624.orig/stage2/smp-imps.c 2001-12-11 13:19:16.000000000 +0530 +++ grub-0.95+cvs20040624/stage2/smp-imps.c 2005-08-07 03:25:57.000000000 +0530 @@ -246,19 +246,45 @@ }; /* - * Exported globals here. + * Private globals here. + */ + +/* + * "imps_any_new_apics" is non-zero if any of the APICS (local or I/O) + * are *not* an 82489DX. This is useful to determine if more than 15 + * CPUs can be supported (true if zero). */ static int imps_any_new_apics = 0; -#if 0 -volatile int imps_release_cpus = 0; -#endif + +/* + * "imps_enabled" is non-zero if the probe sequence found IMPS + * information and was successful. + */ + static int imps_enabled = 0; -static int imps_num_cpus = 1; + +/* + * This contains the local APIC hardware address. + */ + static unsigned imps_lapic_addr = ((unsigned) (&lapic_dummy)) - LAPIC_ID; + +/* + * This represents the number of CPUs found. + */ + +static int imps_num_cpus = 1; + +/* + * These map from virtual cpu numbers to APIC id's and back. + */ static unsigned char imps_cpu_apic_map[IMPS_MAX_CPUS]; static unsigned char imps_apic_cpu_map[IMPS_MAX_CPUS]; +#if 0 +volatile int imps_release_cpus = 0; +#endif /* * MPS checksum function diff -Nur grub-0.95+cvs20040624.orig/stage2/smp-imps.h grub-0.95+cvs20040624/stage2/smp-imps.h --- grub-0.95+cvs20040624.orig/stage2/smp-imps.h 1999-06-24 05:33:28.000000000 +0530 +++ grub-0.95+cvs20040624/stage2/smp-imps.h 2005-08-07 03:25:57.000000000 +0530 @@ -177,41 +177,6 @@ unsigned char dest_apic_intin; }; - -/* - * Exported globals here. - */ - -/* - * "imps_any_new_apics" is non-zero if any of the APICS (local or I/O) - * are *not* an 82489DX. This is useful to determine if more than 15 - * CPUs can be supported (true if zero). - */ -extern int imps_any_new_apics; - -/* - * "imps_enabled" is non-zero if the probe sequence found IMPS - * information and was successful. - */ -extern int imps_enabled; - -/* - * This contains the local APIC hardware address. - */ -extern unsigned imps_lapic_addr; - -/* - * This represents the number of CPUs found. - */ -extern int imps_num_cpus; - -/* - * These map from virtual cpu numbers to APIC id's and back. - */ -extern unsigned char imps_cpu_apic_map[IMPS_MAX_CPUS]; -extern unsigned char imps_apic_cpu_map[IMPS_MAX_CPUS]; - - /* * This is the primary function for probing for Intel MPS 1.1/1.4 * compatible hardware and BIOS information. While probing the CPUs
--- grub-0.95+cvs20040624.orig/stage2/builtins.c 2005-08-07 03:40:20.000000000 +0530 +++ grub-0.95+cvs20040624/stage2/builtins.c 2005-08-07 03:39:26.000000000 +0530 @@ -141,7 +141,7 @@ /* Collect contiguous blocks into one entry as many as possible, and print the blocklist notation on the screen. */ - static void disk_read_blocklist_func (int sector, int offset, int length) + void disk_read_blocklist_func (int sector, int offset, int length) { if (num_sectors > 0) { @@ -605,7 +605,7 @@ }; /* Convert the color name STR into the magical number. */ - static int color_number (char *str) + int color_number (char *str) { char *ptr; int i; @@ -773,13 +773,15 @@ /* default */ +#ifndef GRUB_UTIL +static int savedefault_helper(int); +#endif static int default_func (char *arg, int flags) { #ifndef SUPPORT_DISKLESS #ifndef GRUB_UTIL /* Has a forced once-only default been specified? */ - static int savedefault_helper(int); if ((saved_entryno & STAGE2_ONCEONLY_ENTRY) != 0) { default_entry = saved_entryno & ~STAGE2_ONCEONLY_ENTRY; @@ -1906,7 +1908,7 @@ #endif /* GRUB_UTIL */ /* Save the first sector of Stage2 in STAGE2_SECT. */ - static void disk_read_savesect_func (int sector, int offset, int length) + void disk_read_savesect_func (int sector, int offset, int length) { if (debug) printf ("[%d]", sector); @@ -1922,7 +1924,7 @@ /* Write SECTOR to INSTALLLIST, and update INSTALLADDR and INSTALLSECT. */ - static void disk_read_blocklist_func (int sector, int offset, int length) + void disk_read_blocklist_func (int sector, int offset, int length) { if (debug) printf("[%d]", sector); @@ -3767,7 +3769,7 @@ int to_code, from_code; int map_in_interrupt = 0; - static int find_key_code (char *key) + int find_key_code (char *key) { int i; @@ -3784,7 +3786,7 @@ return 0; } - static int find_ascii_code (char *key) + int find_ascii_code (char *key) { int i; --- grub-0.95+cvs20040624.orig/stage2/char_io.c 2005-08-07 03:40:20.000000000 +0530 +++ grub-0.95+cvs20040624/stage2/char_io.c 2005-08-07 03:48:34.000000000 +0530 @@ -1206,7 +1206,7 @@ memcheck (unsigned long addr, unsigned long len) { #ifdef GRUB_UTIL - static unsigned long start_addr (void) + unsigned long start_addr (void) { int ret; # if defined(HAVE_START_SYMBOL) @@ -1217,7 +1217,7 @@ return ret; } - static unsigned long end_addr (void) + unsigned long end_addr (void) { int ret; # if defined(HAVE_END_SYMBOL) --- grub-0.95+cvs20040624.orig/lib/device.c 2005-08-07 03:40:20.000000000 +0530 +++ grub-0.95+cvs20040624/lib/device.c 2005-08-07 03:57:45.000000000 +0530 @@ -505,12 +505,12 @@ static int read_device_map (FILE *fp, char **map, const char *map_file) { - static void show_error (int no, const char *msg) + void show_error (int no, const char *msg) { fprintf (stderr, "%s:%d: error: %s\n", map_file, no, msg); } - static void show_warning (int no, const char *msg, ...) + void show_warning (int no, const char *msg, ...) { va_list ap; --- grub-0.95+cvs20040624.orig/grub/asmstub.c 2004-03-12 23:01:51.000000000 +0530 +++ grub-0.95+cvs20040624/grub/asmstub.c 2005-08-07 04:04:26.000000000 +0530 @@ -115,7 +115,7 @@ /* We need a nested function so that we get a clean stack frame, regardless of how the code is optimized. */ - static volatile void doit () + volatile void doit () { /* Make sure our stack lives in the simulated memory area. */ asm volatile ("movl %%esp, %0\n\tmovl %1, %%esp\n"
--- grub-0.95+cvs20040624.orig/grub/asmstub.c 2004-03-12 23:01:51.000000000 +0530 +++ grub-0.95+cvs20040624/grub/asmstub.c 2005-08-07 04:25:32.000000000 +0530 @@ -90,7 +90,7 @@ static jmp_buf env_for_exit; /* The current color for console. */ -static int console_current_color = A_NORMAL; +console_current_color = A_NORMAL; /* The file descriptor for a serial device. */ static int serial_fd = -1;
--- grub-0.95+cvs20040624.orig/debian/patches/00list 2005-08-07 04:54:47.000000000 +0530 +++ grub-0.95+cvs20040624/debian/patches/00list 2005-08-07 04:55:00.000000000 +0530 @@ -10,3 +10,6 @@ 2gb_limit.diff kfreebsd.diff grub-special_device_names.diff +smp-imps.diff +static_subfunc.diff +console_current_color.diff