RE: Cross compile build problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I noticed that you didn't specify --enable-languages=c etc flags in
your cross-compilation, the configure script is going to try to build
c++, java, etc. compilers. This would fail because building these
"higher" level language need the headers/libs from newlib which you
haven't build yet (chicken and egg problem). Therefore, you can only
build a C-only compiler at the beginning, build the newlib, and then
if you need other languages, you can use the C-only gcc with the
newlib to compile c++, java, etc. 

I recently got a C-only cross-compiler built and tested using
binutils-2.14, gcc-3.3.3 and newlib-1.12.0 for MIPS32 in Cygwin
on Window XP. I attach the sh script below. You can edit it
to whatever directory structure and target you need. I also
use a similar version of the script to cross-compile in Sun
for MIPS32.

If this build successfully, you would still need to supply the proper
initialization file for your embedded development hardware/simulator,
this is typically called crt0.S (otherwise, you would get a error
when you link your Coldfile program). If you cannot get crt0.S
from your supplier, you can start from newlib-1.12.0/libgloss/m68k/crt0.S
and hack this file to properly init your CPU. You can go to newlib
website http://sources.redhat.com/newlib for more details.

Hope this helps.

PS: There used to be a discussion group called cross-gcc, anybody
    know what happen to it?

YK.

=============================================================
Here is the cross-compile shell script:

#!/bin/sh
PF="/cygdrive/d/tools/test"
TG="mipsisa32-mips-elf"
SD="--enable-multilib=no --program-prefix=bcmx --with-gnu-as --with-gnu-ld
-v"
BD="$PF/$TG/bin"
BM="build"

PATH="$PF/bin:$PATH"

if test "$1" != special
then
  echo "cross-build: configure binutils"
  BDIR=$BM-binutils
  rm -rf $BDIR
  mkdir $BDIR
  cd $BDIR
  ../binutils-2.14/configure --prefix=$PF --target=$TG $SD
  echo "cross-build: compile binutils"
  make all
  echo "cross-build: install binutils"
  make install
  cd ..
fi

if test "$1" != special
then
  echo "cross-build: configure gcc"
  BDIR=$BM-gcc
  rm -rf $BDIR
  mkdir $BDIR
  cd $BDIR
  ../gcc-3.3.3/configure --enable-languages=c --with-newlib --prefix=$PF
--target=$TG $SD
  echo "cross-build: compile gcc"
  make all
  echo "cross-build: install gcc"
  make install
  cd ..
fi

if test "$1" != special
then
  echo "cross-build: configure newlib"
  BDIR=$BM-newlib
  rm -rf $BDIR
  mkdir $BDIR
  cd $BDIR
  ../newlib-1.12.0/configure --with-newlib --host=$TG --prefix=$PF $SD
  echo "cross-build: compile newlib"
  make all CC_FOR_TARGET=$BD/gcc \
       AS_FOR_TARGET=$BD/as \
       LD_FOR_TARGET=$BD/ld \
       AR_FOR_TARGET=$BD/ar \
       RANLIB_FOR_TARGET=$BD/ranlib
  echo "cross-build: install newlib"
  make install
  cd ..
fi

# Bug in gcc-3.3.3? doesn't link/copy automatically.
if test "$1" != special
then
  cd $PF/bin
  ln -s $TG-gcc bcmxgcc
fi

-----Original Message-----
From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On
Behalf Of Brian Rose
Sent: Saturday, September 25, 2004 6:26 PM
To: GCC
Subject: Cross compile build problems


I am trying to put together some GNU tools for embedded development. We are
working on a Motorola coldfire 5206e (among others) and I'd like to use
non-commercial tools for development. The target is a microcontroller
without an OS.

I am on a WindowsXP system with the Cygwin library installed. I am using the
following process to build the tools. All of this is done in my
/cygwin/home/brose directory

1) Download the source tarballs into coldfire/archive
2) Extract the sources into coldfire/src
3) Build and install binutils (works fine) like this
     cd $HOME/coldfire
     mkdir builds
     mkdir builds/binutils
     mkdir bins
     mkdir bins/binutils
     cd builds/binutils
     ../../src/binutils-2.15/configure --target=m68k-elf
--prefix=$HOME/coldfire/bins/binutils/ -v
     make all install

4) Attempt to build and install gcc like this
     cd $HOME/coldfire
     mkdir builds/gcc
     mkdir bins/gcc
     cd builds/gcc
     ../../src/gcc-3.4.2/configure --target=m68k-elf
--prefix=$HOME/coldfire/bins/gcc/ -v
     make all install

And I get this...

--snip--
/home/brose/coldfire/tools/build/gcc/gcc/xgcc
-B/home/brose/coldfire/tools/build/gcc/gcc/
-B/home/brose/coldfire/tools/bins/gcc//m68k-elf/bin/
-B/home/brose/coldfire/tools/bins/gcc//m68k-elf/lib/ -isystem
/home/brose/coldfire/tools/bins/gcc//m68k-elf/include -isystem
/home/brose/coldfire/tools/bins/gcc//m68k-elf/sys-include -O2 -DIN_GCC
-DCROSS_COMPILE   -W -Wall -Wwrite-strings -Wstrict-prototypes
-Wmissing-prototypes -Wold-style-definition  -isystem ./include  -I. -I.
-I../../../src/gcc-3.4.2/gcc -I../../../src/gcc-3.4.2/gcc/.
-I../../../src/gcc-3.4.2/gcc/../include   -g0 -finhibit-size-directive
-fno-inline-functions -fno-exceptions -fno-zero-initialized-in-bss
-fno-unit-at-a-time  \
   -Dinhibit_libc -c ../../../src/gcc-3.4.2/gcc/crtstuff.c -DCRT_BEGIN \
   -o crtbegin.o
as: unrecognized option `-mc68020'
make[1]: *** [crtbegin.o] Error 1
make[1]: Leaving directory `/home/brose/coldfire/tools/build/gcc/gcc'
make: *** [all-gcc] Error 2


I've tried the --with-as=$HOME/coldfire/tools/bins/bintuils/bin/m68k-elf-as 
with no luck.

Has anyone built the current compiler on/for Windows with a m68k target in 
mind? Pray tell, what was the procedure?

Thanks in advance,

--

Brian Rose










[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux