This should be a much cleaner option than maintaining libgcc.h by hand.  Only
tested on sparc, but it should also cast out the build problems on powerpc.

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
2009-10-20  Robert Millan  <rmh.g...@aybabtu.com>

	* genlibgcc_h.sh.in: New file.

	* conf/powerpc-ieee1275.rmk (MOSTLYCLEANFILES): Add `libgcc.h'.
	(libgcc.h): New rule.
	(kernel_syms.lst): Add `libgcc.h' to header list.
	* conf/sparc64-ieee1275.rmk: Likewise.

	* include/grub/sparc64/libgcc.h: Remove.  Update all users.
	* include/grub/powerpc/libgcc.h: Likewise.

	* configure.ac: Stop checking for libgcc symbols.
	* include/grub/misc.h [!GRUB_UTIL] (memset, memcmp): New prototypes
	(provided by libc.so or kernel.img, NOT libgcc).

Index: conf/powerpc-ieee1275.rmk
===================================================================
--- conf/powerpc-ieee1275.rmk	(revision 2641)
+++ conf/powerpc-ieee1275.rmk	(working copy)
@@ -10,19 +10,22 @@ script/sh/lexer.c_DEPENDENCIES = grub_script.tab.h
 
 # Images.
 
-MOSTLYCLEANFILES += symlist.c kernel_syms.lst
+MOSTLYCLEANFILES += symlist.c kernel_syms.lst libgcc.h
 DEFSYMFILES += kernel_syms.lst
 
 kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
 	env.h err.h file.h fs.h kernel.h misc.h mm.h net.h parser.h reader.h \
-	symbol.h term.h time.h types.h powerpc/libgcc.h loader.h partition.h \
+	symbol.h term.h time.h types.h loader.h partition.h \
 	msdos_partition.h ieee1275/ieee1275.h machine/kernel.h handler.h list.h \
 	command.h
 
+libgcc.h: genlibgcc_h.sh
+	/bin/sh $< > $@ || (rm -f $@; exit 1)
+
 symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
 	/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
-kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
+kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) libgcc.h config.h genkernsyms.sh
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Programs
Index: conf/sparc64-ieee1275.rmk
===================================================================
--- conf/sparc64-ieee1275.rmk	(revision 2641)
+++ conf/sparc64-ieee1275.rmk	(working copy)
@@ -23,14 +23,14 @@ diskboot_img_ASFLAGS = $(COMMON_ASFLAGS)
 diskboot_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-Ttext,0x4200
 diskboot_img_FORMAT = binary
 
-MOSTLYCLEANFILES += symlist.c kernel_syms.lst
+MOSTLYCLEANFILES += symlist.c kernel_syms.lst libgcc.h
 DEFSYMFILES += kernel_syms.lst
 
 kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
 	env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
 	partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
 	list.h handler.h command.h \
-	sparc64/libgcc.h ieee1275/ieee1275.h machine/kernel.h \
+	ieee1275/ieee1275.h machine/kernel.h \
 	sparc64/ieee1275/ieee1275.h
 kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c	\
 	kern/ieee1275/ieee1275.c kern/main.c kern/device.c		\
@@ -54,7 +54,10 @@ kernel_img_FORMAT = binary
 symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
 	/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
-kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
+libgcc.h: genlibgcc_h.sh
+	/bin/sh $< > $@ || (rm -f $@; exit 1)
+
+kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) libgcc.h config.h genkernsyms.sh
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Utilities.
Index: configure.ac
===================================================================
--- configure.ac	(revision 2642)
+++ configure.ac	(working copy)
@@ -411,9 +411,6 @@ AC_SUBST(TARGET_ASFLAGS)
 AC_SUBST(TARGET_CPPFLAGS)
 AC_SUBST(TARGET_LDFLAGS)
 
-# Check for libgcc symbols (must be performed before we add -nostdlib to LDFLAGS)
-AC_CHECK_FUNCS(__bswapsi2 __bswapdi2)
-
 # Set them to their new values for the tests below.
 CC="$TARGET_CC"
 if test "x$TARGET_APPLE_CC" = x1 ; then
@@ -615,7 +612,7 @@ else
   rm -rf include/grub/machine
   cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 2>/dev/null
 fi
-AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh])
+AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh genlibgcc_h.sh])
 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
 AC_OUTPUT
 [
Index: include/grub/misc.h
===================================================================
--- include/grub/misc.h	(revision 2641)
+++ include/grub/misc.h	(working copy)
@@ -78,6 +78,8 @@ grub_strncat (char *dest, const char *src, int c)
 #if !defined (GRUB_UTIL) || !defined (APPLE_CC)
 void *EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n);
 void *EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n);
+void *EXPORT_FUNC(memset) (void *s, int c, grub_size_t n);
+int EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n);
 #endif
 
 int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n);
Index: include/grub/sparc64/libgcc.h
===================================================================
--- include/grub/sparc64/libgcc.h	(revision 2641)
+++ include/grub/sparc64/libgcc.h	(working copy)
@@ -1,31 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2004,2007  Free Software Foundation, Inc.
- *
- *  GRUB is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  GRUB is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <config.h>
-
-void EXPORT_FUNC (memset) (void);
-
-#ifdef HAVE___BSWAPSI2
-typedef int SItype __attribute__ ((mode (SI)));
-SItype EXPORT_FUNC (__bswapsi2) (SItype);
-#endif
-
-#ifdef HAVE___BSWAPDI2
-typedef int DItype __attribute__ ((mode (DI)));
-DItype EXPORT_FUNC (__bswapdi2) (DItype);
-#endif
Index: include/grub/powerpc/libgcc.h
===================================================================
--- include/grub/powerpc/libgcc.h	(revision 2641)
+++ include/grub/powerpc/libgcc.h	(working copy)
@@ -1,24 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2004,2007  Free Software Foundation, Inc.
- *
- *  GRUB is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  GRUB is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-void EXPORT_FUNC (memset) (void);
-void EXPORT_FUNC (__ashldi3) (void);
-void EXPORT_FUNC (__ashrdi3) (void);
-void EXPORT_FUNC (__lshrdi3) (void);
-void EXPORT_FUNC (__trampoline_setup) (void);
-void EXPORT_FUNC (__ucmpdi2) (void);
Index: genlibgcc_h.sh.in
===================================================================
--- genlibgcc_h.sh.in	(revision 0)
+++ genlibgcc_h.sh.in	(revision 0)
@@ -0,0 +1,31 @@
+#! /bin/sh
+#
+# Copyright (C) 2006,2009  Free Software Foundation, Inc.
+#
+# GRUB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GRUB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+
+### The configure script will replace these variables.
+
+: ${srcd...@srcdir@}
+: ${...@cc@}
+
+
+cat <<EOF
+/* This file is automatically generated by $0. DO NOT EDIT! */
+
+EOF
+
+nm --defined-only `$CC -print-libgcc-file-name` \
+  | sed -ne "s/^[0-9]* T //p" \
+  | sed -e "s/\(.*\)/void EXPORT_FUNC (\1) (void);/"
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to