This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: linking newlib (libc.a crt0.o) for powerpc-ibm-eabi target on i686-pc-cygwin host
- To: Anthony P Ferranti <ferranti at us dot ibm dot com>
- Subject: Re: linking newlib (libc.a crt0.o) for powerpc-ibm-eabi target on i686-pc-cygwin host
- From: "William A. Gatliff" <bgat at saturn dot billgatliff dot com>
- Date: Thu, 13 Sep 2001 16:27:19 -0500
- Cc: newlib at sourceware dot cygnus dot com, crossgcc at sourceware dot cygnus dot com,gcc-help at gcc dot gnu dot org, binutils at sources dot redhat dot com
- References: <OFB521D8CC.9F4D67AC-ON85256AC6.006F12D6@raleigh.ibm.com>
- Reply-To: bgat at billgatliff dot com
Sorry for the crossposted reply, but...
Did you look at http://crossgcc.billgatliff.com? There's a FAQ there.
In particular, LANGUAGE=c isn't supported after 2.95.1. I don't know
what the results are, but they may explain what you're seeing.
HTH,
b.g.
On Thu, Sep 13, 2001 at 05:11:19PM -0400, Anthony P Ferranti wrote:
> I am experiencing problems when cross-compiling programs with GCC that
> involve a linking stage. I believe they are related to the library
> "libc.a" and the startup file "crt0.o". It is my understanding that these
> files are installed with newlib and they appear to be present. This
> appears to be the same problem Dan Alderman experienced on Feb 12, 2001 and
> posted to this mailing list. Dan, if you could remember how you solved
> this problem your help would be greatly apprecieated. I am new to the UNIX
> environment and C-programming. Building GCC as a cross-compiler has been
> my first project so I'm a bit confused. I've tried reading all the FAQs
> and mailing lists to no avail. Any help is greatly appreciated.
>
> Here is what I did to install an i686-pc-cygwin hosted powerpc-unknown-eabi
> cross-compiler in "/usr/local". Source files were unpacked into
> "/usr/local/src". Packages were built in "/usr/local/obj"...
>
>
> cygwin$ host=i686-pc-cygwin
> cygwin$ build=$host
> cygwin$ target=powerpc-unknown-eabi
> cygwin$ prefix=/usr/local
> cygwin$ srcroot=$prefix/src
> cygwin$ buildroot=$prefix/obj
>
>
> First, I configure, build, and install binutils...
>
>
> cygwin$ mkdir -p $buildroot/binutils
> cygwin$ cd $buildroot/binutils
> cygwin$ $srcroot/binutils-2.10.1/configure \
> --with-included-gettext \
> --host=$host --target=$target --build=$build \
> --prefix=$prefix -v
> cygwin$ make >make.log 2>&1
> cygwin$ make install >install.log 2>&1
>
>
> Next, I configure, build, and install the GCC C compiler...
>
>
> cygwin$ mkdir -p $buildroot/gcc
> cygwin$ cd $buildroot/gcc
> cygwin$ $srcroot/gcc-2.95.3-5/configure \
> --enable-languages=c,c++ \
> --with-included-gettext \
> --with-cpu=powerpc \
> --host=$host --target=$target --build=$build \
> --with-newlib \
> --prefix=$prefix -v
> cygwin$ make LANGUAGES=c all-gcc >make_c_only.log 2>&1
> cygwin$ make LANGUAGES=c install-gcc >install_c_only.log 2>&1
>
>
> Next, I configure, build, and install newlib...
>
>
> cygwin$ mkdir -p $buildroot/newlib
> cygwin$ cd $buildroot/newlib
> cygwin$ $srcroot/newlib-1.9.0/configure \
> --host=$host --target=$target --build=$build \
> --prefix=$prefix -v
> cygwin$ make >make.log 2>&1
> cygwin$ make install >install.log 2>&1
>
>
> Next, I configure, build, and install the remaining GCC compilers, and
> language runtime and/or support libraries...
>
>
> cygwin$ cd $buildroot/gcc
> cygwin$ make >make.log 2>&1
> cygwin$ make install >install.log 2>&1
>
>
> At this point, I I realize there are problems during compiles with a
> linking stage. After reading numerous FAQs, mailing list archives, etc, I
> try to reconfigure, rebuild, and reinstall newlib with some additional
> options...
>
>
> cygwin$ cd $buildroot/newlib
> cygwin$ mv make.log make.log.old
> cygwin$ mv install.log install.log.old
> cygwin$ make distclean
> cygwin$ $srcroot/newlib-1.9.0/configure \
> --host=$host --target=$target --build=$build \
> --prefix=$prefix -v
> cygwin$ make \
> CC_FOR_TARGET=$prefix/bin/$target-gcc \
> AS_FOR_TARGET=$prefix/bin/$target-as \
> LD_FOR_TARGET=$prefix/bin/$target-ld \
> AR_FOR_TARGET=$prefix/bin/$target-ar \
> RANLIB_FOR_TARGET=$prefix/bin/$target-ranlib \
> NM_FOR_TARGET=$prefix/bin/$target-nm \
> >make.log 2>&1
> cygwin$ make install >install.log 2>&1
>
>
> These are the problems I am experiencing...
>
>
> cygwin$ $target-gcc helloworld.c
> /usr/local/lib/gcc-lib/powerpc-unknown-eabi/2.95.3-5/../../../../powerpc-unknown-eabi/bin/ld:
>
> warning: cannot find entry symbol _start; defaulting to 01800074
> /c/TEMP/ccWya32M.o: In function `main':
> /c/TEMP/ccWya32M.o(.text+0x24): undefined reference to `printf'
> /usr/local/lib/gcc-lib/powerpc-unknown-eabi/2.95.3-5/libgcc.a(eabi.o)
> (.got2+0x8): undefined reference to `__SDATA_START__'
> /usr/local/lib/gcc-lib/powerpc-unknown-eabi/2.95.3-5/libgcc.a(eabi.o)
> (.got2+0xc): undefined reference to `__SBSS_END__'
> /usr/local/lib/gcc-lib/powerpc-unknown-eabi/2.95.3-5/libgcc.a(eabi.o)
> (.got2+0x14): undefined reference to `__SDATA2_START__'
> /usr/local/lib/gcc-lib/powerpc-unknown-eabi/2.95.3-5/libgcc.a(eabi.o)
> (.got2+0x18): undefined reference to `__SBSS2_END__'
> /usr/local/lib/gcc-lib/powerpc-unknown-eabi/2.95.3-5/libgcc.a(eabi-ctors.o):
>
> In function `__do_global_ctors':
> /usr/local/obj/gcc/gcc/eabi-ctors.c(.sdata+0x0): undefined reference to
> `__init'
> /usr/local/obj/gcc/gcc/eabi-ctors.c(.sdata+0x4): undefined reference to
> `__fini'
> collect2: ld returned 1 exit status
>
>
> I believe that _start is supposed to be defined in crt0.o but I added -e
> main to bypass this. Does anyone know ehat eabi.o does or why eliminating
> it reduces the errors? Here is what I tried next...
>
>
> cygwin$ $target-gcc -e main -mno-eabi helloworld.c
> /c/TEMP/ccwCYRid.o: In function `main':
> /c/TEMP/ccwCYRid.o(.text+0x20): undefined reference to `printf'
> collect2: ld returned 1 exit status
>
>
> Next I added the -L\usr\local\$target\lib command. There are files called
> libc.a and crt0.o in that directory. This had no effect...
>
>
> cygwin$ $target-gcc -e main -mno-eabi -L\usr\local\$target\lib
> helloworld.c
> /c/TEMP/ccFfHYTg.o: In function `main':
> /c/TEMP/ccFfHYTg.o(.text+0x20): undefined reference to `printf'
> collect2: ld returned 1 exit status
>
>
> Finally I added the -lc to force libc.a to be linked. Again, no effect...
>
>
> cygwin$ $target-gcc -e main -mno-eabi -L\usr\local\$target\lib -lc
> helloworld.c
> /c/TEMP/ccTbWSZk.o: In function `main':
> /c/TEMP/ccTbWSZk.o(.text+0x20): undefined reference to `printf'
> collect2: ld returned 1 exit status
>
>
> Any sugestions??? if I add the -msim option it compiles correctly for the
> simulation board but in that case libc.a and crt0.o are not used.
>
> Regards,
> Tony Ferranti
> ferranti@us.ibm.com
>
>
> ------
> Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
> Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
>
--
Bill Gatliff
bgat@billgatliff.com