This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] fix cross builds of sim/ppc
- From: Nathan Froyd <froydnj at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 13 Nov 2009 13:55:20 -0800
- Subject: [PATCH] fix cross builds of sim/ppc
The patch below fixes a cross build problem with sim/ppc. sim/ppc
builds various tools which are then used to generate source files for
the simulator. The problem is that as things currently stand, those
build-machine tools use a config.h generated for the host machine. This
mismatch can cause the build to fail, depending on the differences
between headers.
The patch fixes this by detecting the cross-compilation case and
generating a build-config.h file that correctly reflects the
idiosyncrasies of the build machine. build-config.h is then included in
the necessary source files. The logic is lifted straight from gcc's own
makefiles.
Tested with cross to powerpc-eabi for i686-pc-linux-gnu and i686-mingw32
hosts. OK to commit?
-Nathan
* configure.ac: If build != host, create a separate build-config.h
file desecribing the build machine.
* configure: Regenerate.
* lf.c: Include build-config.h instead of config.h
* dgen.c: Likewise.
* igen.c: Likewise.
* misc.c: Likewise.
* misc.h: Likewise.
* filter.c: Likewise.
* table.c: Likewise.
Index: configure
===================================================================
RCS file: /cvs/src/src/sim/ppc/configure,v
retrieving revision 1.23
diff -u -u -r1.23 configure
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/sim/ppc/configure.ac,v
retrieving revision 1.12
diff -u -u -r1.12 configure.ac
--- configure.ac 15 Sep 2009 23:26:44 -0000 1.12
+++ configure.ac 13 Nov 2009 21:50:31 -0000
@@ -848,6 +848,31 @@
sim_fpu=
fi
+# Since we run commands on the build system, we have to create a
+# separate config header for the build system if build != host.
+if test x$host = x$build; then
+ AC_CONFIG_COMMANDS([build-config.h],[cp config.h build-config.h])
+else
+ tempdir=build.$$
+ rm -rf $tempdir
+ mkdir $tempdir
+ cd $tempdir
+ case ${srcdir} in
+ /* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};;
+ *) realsrcdir=../${srcdir};;
+ esac
+ saved_CFLAGS="${CFLAGS}"
+ CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
+ LDFLAGS="${LDFLAGS_FOR_BUILD}" \
+ ${realsrcdir}/configure \
+ --enable-languages=${enable_languages-all} \
+ --target=$target_alias --host=$build_alias --build=$build_alias
+ CFLAGS="${saved_CFLAGS}"
+ mv config.h ../build-config.h
+ cd ..
+ rm -rf $tempdir
+fi
+
dnl Check for exe extension
AC_EXEEXT
Index: dgen.c
===================================================================
RCS file: /cvs/src/src/sim/ppc/dgen.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 dgen.c
--- dgen.c 16 Apr 1999 01:35:08 -0000 1.1.1.1
+++ dgen.c 13 Nov 2009 21:50:31 -0000
@@ -27,7 +27,7 @@
#include <ctype.h>
#include <stdarg.h>
-#include "config.h"
+#include "build-config.h"
#include "misc.h"
#include "lf.h"
#include "table.h"
Index: filter.c
===================================================================
RCS file: /cvs/src/src/sim/ppc/filter.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 filter.c
--- filter.c 16 Apr 1999 01:35:09 -0000 1.1.1.1
+++ filter.c 13 Nov 2009 21:50:31 -0000
@@ -21,7 +21,7 @@
#include <stdio.h>
-#include "config.h"
+#include "build-config.h"
#ifdef HAVE_STRING_H
#include <string.h>
Index: igen.c
===================================================================
RCS file: /cvs/src/src/sim/ppc/igen.c,v
retrieving revision 1.5
diff -u -u -r1.5 igen.c
--- igen.c 20 Jun 2003 03:59:33 -0000 1.5
+++ igen.c 13 Nov 2009 21:50:31 -0000
@@ -25,7 +25,7 @@
#include "misc.h"
#include "lf.h"
#include "table.h"
-#include "config.h"
+#include "build-config.h"
#include "filter.h"
Index: lf.c
===================================================================
RCS file: /cvs/src/src/sim/ppc/lf.c,v
retrieving revision 1.2
diff -u -u -r1.2 lf.c
--- lf.c 30 May 2002 15:07:06 -0000 1.2
+++ lf.c 13 Nov 2009 21:50:31 -0000
@@ -23,7 +23,7 @@
#include <stdarg.h>
#include <ctype.h>
-#include "config.h"
+#include "build-config.h"
#include "misc.h"
#include "lf.h"
Index: misc.c
===================================================================
RCS file: /cvs/src/src/sim/ppc/misc.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 misc.c
--- misc.c 16 Apr 1999 01:35:11 -0000 1.1.1.1
+++ misc.c 13 Nov 2009 21:50:31 -0000
@@ -23,7 +23,7 @@
#include <stdarg.h>
#include <ctype.h>
-#include "config.h"
+#include "build-config.h"
#include "misc.h"
#ifdef HAVE_STDLIB_H
Index: misc.h
===================================================================
RCS file: /cvs/src/src/sim/ppc/misc.h,v
retrieving revision 1.2
diff -u -u -r1.2 misc.h
--- misc.h 12 Jan 2002 10:21:12 -0000 1.2
+++ misc.h 13 Nov 2009 21:50:31 -0000
@@ -21,7 +21,7 @@
/* Frustrating header junk */
-#include "config.h"
+#include "build-config.h"
#include <stdio.h>
#include <ctype.h>
Index: table.c
===================================================================
RCS file: /cvs/src/src/sim/ppc/table.c,v
retrieving revision 1.2
diff -u -u -r1.2 table.c
--- table.c 12 Jan 2002 10:21:12 -0000 1.2
+++ table.c 13 Nov 2009 21:50:31 -0000
@@ -25,7 +25,7 @@
#include <fcntl.h>
#include <ctype.h>
-#include "config.h"
+#include "build-config.h"
#include "misc.h"
#include "lf.h"
#include "table.h"