Skip to contentSkip to conversation

Don't use AC_CHECK_FUNCS for the target, it requires target libc headers

PATCH New Pavel Roskin 1 participant 2 messages Jun 9, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Don't use AC_CHECK_FUNCS for the target, it requires target libc headers

ChangeLog:
configure.ac: Remove check for __bswapsi2 and __bswapdi2. include/grub/powerpc/libgcc.h: Use weak attribute for all exports.
include/grub/sparc64/libgcc.h: Likewise. Don't use preprocessor conditionals.
---

 configure.ac                  |    3 ---
 include/grub/powerpc/libgcc.h |   10 +++++-----
 include/grub/sparc64/libgcc.h |    8 ++------
 3 files changed, 7 insertions(+), 14 deletions(-)
configure.ac +0 -3
index e448c2f..8ece359 100644
@@ -409,9 +409,6 @@ CFLAGS="$TARGET_CFLAGS"
 CPPFLAGS="$TARGET_CPPFLAGS"
 LDFLAGS="$TARGET_LDFLAGS"
 
-# Check for target functions.
-AC_CHECK_FUNCS(__bswapsi2 __bswapdi2)
-
 # Defined in aclocal.m4.
 grub_PROG_TARGET_CC
 if test "x$TARGET_APPLE_CC" != x1 ; then
include/grub/powerpc/libgcc.h +5 -5
index acdd146..bed9377 100644
@@ -16,8 +16,8 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-void EXPORT_FUNC (memset) (void);
-void EXPORT_FUNC (__ashldi3) (void);
-void EXPORT_FUNC (__lshrdi3) (void);
-void EXPORT_FUNC (__trampoline_setup) (void);
-void EXPORT_FUNC (__ucmpdi2) (void);
+void EXPORT_FUNC (memset) (void) __attribute__ ((weak));
+void EXPORT_FUNC (__ashldi3) (void) __attribute__ ((weak));
+void EXPORT_FUNC (__lshrdi3) (void) __attribute__ ((weak));
+void EXPORT_FUNC (__trampoline_setup) (void) __attribute__ ((weak));
+void EXPORT_FUNC (__ucmpdi2) (void) __attribute__ ((weak));
include/grub/sparc64/libgcc.h +2 -6
index 4a6b619..5d18c5c 100644
@@ -20,12 +20,8 @@
 
 void EXPORT_FUNC (memset) (void);
 
-#ifdef HAVE___BSWAPSI2
 typedef int SItype __attribute__ ((mode (SI)));
-SItype EXPORT_FUNC (__bswapsi2) (SItype);
-#endif
+SItype EXPORT_FUNC (__bswapsi2) (SItype) __attribute__ ((weak));
 
-#ifdef HAVE___BSWAPDI2
 typedef int DItype __attribute__ ((mode (DI)));
-DItype EXPORT_FUNC (__bswapdi2) (DItype);
-#endif
+DItype EXPORT_FUNC (__bswapdi2) (DItype) __attribute__ ((weak));
#1 lore raw

PATCH 2/2 Allow compilation without having target libc installed

ChangeLog:
* configure.ac: Use -nostdlib when probing for the target.
* include/grub/multiboot2.h: Provide compatibility defines for multiboot.h.
* include/multiboot2.h: Don't include stdint.h. It's the responsibility of the code that includes that header.
* loader/i386/pc/multiboot2.c: Include multiboot2.h after grub/multiboot2.h.
* loader/ieee1275/multiboot2.c: Likewise.
* loader/multiboot2.c: Likewise.
* loader/multiboot_loader.c: Likewise.
---

 configure.ac                 |    2 +-
 include/grub/multiboot2.h    |    5 +++++
 include/multiboot2.h         |    2 --
 loader/i386/pc/multiboot2.c  |    2 +-
 loader/ieee1275/multiboot2.c |    2 +-
 loader/multiboot2.c          |    2 +-
 loader/multiboot_loader.c    |    2 +-
 7 files changed, 10 insertions(+), 7 deletions(-)
configure.ac +1 -1
index 8ece359..e29495a 100644
@@ -405,7 +405,7 @@ AC_SUBST(TARGET_LDFLAGS)
 
 # Set them to their new values for the tests below.
 CC="$TARGET_CC"
-CFLAGS="$TARGET_CFLAGS"
+CFLAGS="$TARGET_CFLAGS -nostdlib"
 CPPFLAGS="$TARGET_CPPFLAGS"
 LDFLAGS="$TARGET_LDFLAGS"
 
include/grub/multiboot2.h +5 -0
index bfbffcc..6d7f19d 100644
@@ -24,6 +24,11 @@
 #include <grub/err.h>
 #include <grub/elf.h>
 
+#ifndef GRUB_UTIL
+typedef grub_uint32_t uint32_t;
+#define __WORDSIZE (8 * GRUB_TARGET_SIZEOF_VOID_P)
+#endif
+
 struct multiboot_tag_header;
 
 grub_err_t
include/multiboot2.h +0 -2
index 0f2b0cf..7270075 100644
@@ -34,8 +34,6 @@
 
 #ifndef ASM_FILE
 
-#include "stdint.h"
-
 /* XXX not portable? */
 #if __WORDSIZE == 64
 typedef uint64_t multiboot_word;
loader/i386/pc/multiboot2.c +1 -1
index 2c14ee2..7d7c685 100644
@@ -17,8 +17,8 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <multiboot2.h>
 #include <grub/multiboot2.h>
+#include <multiboot2.h>
 #include <grub/elf.h>
 #include <grub/err.h>
 #include <grub/machine/loader.h>
loader/ieee1275/multiboot2.c +1 -1
index c253fc9..61f21b0 100644
@@ -17,10 +17,10 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <multiboot2.h>
 #include <grub/loader.h>
 #include <grub/ieee1275/ieee1275.h>
 #include <grub/multiboot2.h>
+#include <multiboot2.h>
 #include <grub/err.h>
 #include <grub/elf.h>
 #include <grub/misc.h>
loader/multiboot2.c +1 -1
index fd82828..6f8a679 100644
@@ -17,10 +17,10 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <multiboot2.h>
 #include <grub/loader.h>
 #include <grub/machine/loader.h>
 #include <grub/multiboot2.h>
+#include <multiboot2.h>
 #include <grub/elfload.h>
 #include <grub/file.h>
 #include <grub/err.h>
loader/multiboot_loader.c +1 -1
index 11ba666..707f55e 100644
@@ -17,10 +17,10 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <multiboot2.h>
 #include <grub/machine/machine.h>
 #include <grub/multiboot.h>
 #include <grub/multiboot2.h>
+#include <multiboot2.h>
 #include <grub/elf.h>
 #include <grub/file.h>
 #include <grub/err.h>