This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: "building binutils for target" question



OK. So you can build your cross-toolchain with crosstool-NG, that's
supported. But for building the cross-native compiler to run on your
PPC, you'll mostly be on your own; crostool-NG won't help you much...
I have just succeeded in building and installing "cross-native" GCC and its accompanying tools/libraries - the whole lot!!!

In the next few days I will further optimise this process as I am not convinced I am 100% there yet - I used some pretty ugly hacks to get there (see my "libstdc++.la nasties" thread for details).

Of course I used crosstool-NG as a template in what needs doing, with the following "deviations": ;-)

1. GMP, MPFR, PPL, ClooG, (MPC, if needed) should be built the standard way using the (previously built) cross GCC for the target platform after that cross toolchain is already completed.

I am attaching a patch which enables GCC 4.4.5 to be built with MPFR v3.0.0+. One thing of note, however, is something I could not cure despite my best efforts. When I run PPL ./configure (after building GMP and MPFR) I get this:

ppl configure:
configure: WARNING: CANNOT PROPAGATE EXCEPTIONS BACK FROM GMP:
*** MEMORY EXHAUSTION MAY RESULT IN ABRUPT TERMINATION.
*** This is OK, if you do not plan to use the bounded memory capabilities
*** offered by the PPL.  Otherwise, if you are using GCC or the Intel C/C++
*** compiler, please make sure you use a version of GMP compiled with the
*** `-fexceptions' compiler option.
*** To build such a version, you can configure GMP as follows:
*** CPPFLAGS=-fexceptions ./configure --enable-cxx --prefix=/usr/local

I included the above flags (in both CPPFLAGS as well as CFLAGS when building GMP, MPFR and PPL), but *still* get that warning. It annoys me because I did not have that when I was building my cross toolchain. Any ideas what am I doing wrong?

2. For building "cross-native" GCC I applied the 2nd patch I am attaching, plus used the following options during configure (in addition to the ones used for building the final cross GCC): --with-host-libstdcxx="-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm" --disable-libstdcxx-pch --disable-libpchstdcxx.

These are in addition to the obvious --build, --host & --target parameters (in my case --build=x86_64 --host=powerpc --target=powerpc).

I am not sure as to whether I need all of these options and whether they overlap (they probably do, but since I am no GCC expert I cannot vouch for the correctness of this - I will probably have a better idea when I look into this further tomorrow), but it works, at least by quickly looking at what has been done anyway.

I also enabled the ssp library in GCC as well (--with-libssp).

3. Issuing "make all" and then "make install" does the job perfectly and I am having spanking new gcc as well as <target_tupple>-gcc executables in my sysroot/bin. Checking them with "file " and readelf assures me that these executables are for the right platform, but I will be able to properly test these when I build my final image or use qemu - probably some time next week.


As for the CFLAGS/LDFLAGS includes that is a given, although I am thinking if I run with chroot to /some/place/staging and then execute make install then I won't be needing this, right? I might be wrong though!

You can't use a chroot: the chroot you'd like to chroot into is a PPC
system, while the machine you're running on is an x86_64...
That won't be needed, at least not in the way I expected - I would need to have the host tools (x86_64 in my case) + the cross GCC (with its associated libraries) so that when I do chroot I can execute them freely. They then will be used to build everything for the target image and prepare the whole staging area.


MZ
--- gcc-4.4.5.orig/configure	2010/10/06 10:10:14	165019
+++ gcc-4.4.5/configure		2010/10/06 10:29:55	165020
@@ -4596,7 +4596,7 @@
 if test "x$with_gmp$with_gmp_include$with_gmp_lib" = x && test -d ${srcdir}/gmp; then
   gmplibs='-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/gmp/_libs '"$gmplibs"
   gmpinc='-I$$r/$(HOST_SUBDIR)/gmp -I$$s/gmp '"$gmpinc"
-  extra_mpfr_configure_flags='--with-gmp-build=$$r/$(HOST_SUBDIR)/gmp'
+  extra_mpfr_configure_flags='--with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-gmp-lib=$$r/$(HOST_SUBDIR)/gmp/'"$lt_cv_objdir"
   # Do not test the gmp version.  Assume that it is sufficient, since
   # it is in the source tree, and the library has not been built yet
   # but it would be included on the link line in the version check below
--- gcc-4.4.5.orig/configure.ac	2010/10/06 10:10:14	165019
+++ gcc-4.4.5/configure.ac	2010/10/06 10:29:55	165020
@@ -1250,7 +1250,7 @@
 if test "x$with_gmp$with_gmp_include$with_gmp_lib" = x && test -d ${srcdir}/gmp; then
   gmplibs='-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/gmp/_libs '"$gmplibs"
   gmpinc='-I$$r/$(HOST_SUBDIR)/gmp -I$$s/gmp '"$gmpinc"
-  extra_mpfr_configure_flags='--with-gmp-build=$$r/$(HOST_SUBDIR)/gmp'
+  extra_mpfr_configure_flags='--with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-gmp-lib=$$r/$(HOST_SUBDIR)/gmp/'"$lt_cv_objdir"
   # Do not test the gmp version.  Assume that it is sufficient, since
   # it is in the source tree, and the library has not been built yet
   # but it would be included on the link line in the version check below

--- gcc-4.4.5.orig/libstdc++-v3/include/Makefile.am	2009-05-13 01:24:16.000000000 +0100
+++ gcc-4.4.5/libstdc++-v3/include/Makefile.am	2011-04-02 02:34:57.228893755 +0100
@@ -850,7 +850,7 @@
 	${pch1_output_builddir} ${pch2_output_builddir} ${pch3_output_builddir}
 pch_output_anchors = \
 	${pch1_output_anchor} ${pch2_output_anchor} ${pch3_output_anchor}
-PCHFLAGS=-x c++-header $(CXXFLAGS)
+PCHFLAGS=-x c++-header -nostdinc++ $(CXXFLAGS)
 if GLIBCXX_BUILD_PCH
 pch_build = ${pch_output}
 else
--- gcc-4.4.5.orig/libstdc++-v3/include/Makefile.in	2009-05-13 01:24:16.000000000 +0100
+++ gcc-4.4.5/libstdc++-v3/include/Makefile.in	2011-04-02 02:34:59.414525979 +0100
@@ -1096,7 +1096,7 @@
 pch_output_anchors = \
 	${pch1_output_anchor} ${pch2_output_anchor} ${pch3_output_anchor}
 
-PCHFLAGS = -x c++-header $(CXXFLAGS)
+PCHFLAGS = -x c++-header -nostdinc++ $(CXXFLAGS)
 @GLIBCXX_BUILD_PCH_FALSE@pch_build = 
 @GLIBCXX_BUILD_PCH_TRUE@pch_build = ${pch_output}
 

--
For unsubscribe information see http://sourceware.org/lists.html#faq

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]