Article View: gnu.gcc.help
Article #50886GCC cross-compiler environment---pointers/help needed
From: Paul Smith
Date: Fri, 23 Jul 1993 06:38
Date: Fri, 23 Jul 1993 06:38
184 lines
8159 bytes
8159 bytes
My company is evaluating a new set of development tools, since we're
beginning to port to different platforms, and require ANSI-compliant
compilers, etc.
I'm pushing to get GCC adopted as the new C compiler.
However, one of the major requirements for any compiler we get is that
it can cross-compile for the sun3 68k system. We want to be able to
compile our code on a sparc and have it run on a sun3. No problem, I
said, GCC can do that!
So, to put money where the mouth is, I attempted to generate a cross
compiler today. Perhaps someone can give me some pointers:
1) I grabbed gas-2.1.1 from prep, uncompressed, untarred.
2) I ran:
./configure --target=sun3 --prefix=/usr/xsun3 sun4
make CC=gcc CFLAGS=-O2
make CC=gcc CFLAGS=-O2 install
All these worked fine, and installed under /usr/xsun3.
3) I grabbed binutils-2.1.1 from prep, uncompressed, untarred.
4) I ran:
./configure --target=sun3 --prefix=/usr/xsun3 sun4
make CC=gcc CFLAGS=-O2
make CC=gcc CFLAGS=-O2 install
Again, this worked fine, and installed some things in /usr/xsun3.
5) I grabbed gcc-2.4.5 from prep, uncompress, untarred.
6) After perusing the INSTALL manual, I ran the following configure:
./configure --prefix=/usr/xsun3 --target=sun3 --with-gnu-as \
--with-gnu-ld --local-prefix=/usr/xsun3 --host=sun4
7) I then moved to a sun3 and compiled libgcc1.a
SUGGESTION: it would be nice if you could provide a small shell script
which would at least compile libgcc1.a, and preferably move the
necessary .c and .h files as well: I didn't want to move the whole
gcc-2.4.5 over so I wanted to do the build by "hand".
8) I put libgcc1.a into /usr/xsun3/lib, thinking the GCC build would
look for it there.
9) I ran:
make CC=/usr/gnu/bin/gcc CFLAGS=-O2 LANGUAGES=c
This ran flawlessly, compiling everything in sight and more, until
it tried to locate libgcc1.a, whereupon it gave up.
10) I moved libgcc1.a to the gcc-2.4.5 directory, and ran:
make CC=/usr/gnu/bin/gcc CFLAGS=-O2 LANGUAGES=c
again. It located libgcc1.a this time, then immediately started
trying to build libgcc2.a--from the INSTALL file I got the
impression it wasn't supposed to do that until you said "make
install".
11) At any rate, the build of libgcc2.a failed immediately because every
attempt to use /usr/xsun3/sun3/bin/ar (which is how the makefile
wants to call ar) which didn't exist. I created it by saying:
ln /usr/xsun3/bin/sun3-ar /usr/xsun3/sun3/bin/ar
ERROR: either binutils should install "ar" into $(prefix)/$(target)/bin,
or GCC should look for it as $(prefix)/bin/$(target)-ar.
12) Once again, the make... this time libgcc2.a built fine until it
tried to compile _eprintf, whereupon it failed with:
./libgcc2.c:1270: stdio.h: No such file or directory
The compile line used for this was:
./xgcc -B./ -O2 -DCROSS_COMPILE -DIN_GCC -O2 -g1 -I. -I. -I./config \
-c -DL_eprintf ./libgcc2.c -o _eprintf.o
Well, looking in the standard include directories for /usr/xsun3,
which is obviously the only place xgcc was looking, there were no
include files to speak of.
13) So, remembering that the INSTALL manual says libgcc2.a is only
supposed to run during "make install", I tried this:
make CC=/usr/gnu/bin/gcc CFLAGS=-O2 LANGUAGES=c install
Sure enough, it did a *bunch* 'o stuff, installing things left and
right in a flurry of bits.
ERROR: libgcc2.a shouldn't be built during cross-compilation until after
the install is done.
14) But, it still died in the same place with the same error. Examining
/usr/xsun3/lib/gcc-lib/sun3/include reveals some header files, but
no stdio.h; in fact, only about 1/4 of the headers in my straight
sun4 installation of GCC.
15) Looking through the makefile for the fixincludes run, I note it uses
SYSTEM_HEADER_DIR to look for headers to fix. Although initially
correct, in the cross-compiler section of the makefile it is
overridden to contain "$(tooldir)/include", where tooldir is set to:
# Directory in which to find other cross-compilation tools and headers.
# Used in install-cross.
tooldir = $(exec_prefix)/$(target)
or, in my case, /usr/xsun3/sun3/include: obviously there's nothing
there!
ERROR: Some information should be given about header files: either GCC
should provide enough of its own, or INSTALL should suggest how to go
about fixincluding the headers for your TARGET machine, or it should
discuss the pros/cons with fixincluding headers for the HOST machine.
Or all 3.
16) I then deleted stmp-fixinc and ran:
make CC=/usr/gnu/bin/gcc CFLAGS=-O2 LANGUAGES=c \
SYSTEM_HEADER_DIR=/usr/include install
Although I suspect this isn't totally correct because I'm putting my
sparc headers (fixed, of course) into my /usr/xsun3 area, but I
don't have the system headers for sun3's handy at the moment :(
This time the thing ran all the way through and installed
everything, but it didn't run cross-test.
ERROR: cross-test wasn't run during the install.
17) So I ran cross-test by hand, and got this error:
/usr/xsun3/sun3/bin/ld: Can't open crt0.o
I could find no info on the INSTALL or anywhere else on what to do
about crt0.o; there was no gcrt0.o built during the build, etc.
Adding a -v to the ./xgcc line shows the linker invoked as:
/usr/sun3/sun3/bin/ld -e start -dc -dp -o cross-test crt0.o \
Mcrt1.o -L. -L/usr/xsun3/lib/gcc-lib/sun3/2.4.5 cross-test.o \
-lgcc -lc -L/usr/lib/f68881 -lgcc
so there isn't even an obvious path as to where crt0.o should go. I
put it in /usr/xsun3/lib, that didn't work, so I put it in
/usr/xsun3/lib/gcc-lib/sun3/2.4.5, and it then found crt0.o.
18) Then I immediately got the error:
/usr/xsun3/sun3/bin/ld: Can't open Mcrt1.o
I grabbed this from a sun3 and put it with crt0.o. Then it couldn't
find "c", so I grabbed /lib/libc.a from a sun3 and put it there too.
At that point it linked.
ERROR: the installation info doesn't give any info about these items
either: although libc.a is obvious it should still be mentioned.
I was then able to compile a "hello world" and it ran fine on a sun3. I
don't have time at the moment to try anything more exotic; maybe next
week.
So, although ultimately successful, I'm wondering if I did something
wrong, missed some important info, etc. to cause myself some grief...
are are the cross-compilation rules just not totally robust yet? Any
hints to make things go more smoothly next time?
Thanks,
paul
_____________________________________________________________________________
/ \
Paul D. Smith | There's a fine line between fishing, and
<psmith@wellfleet.com> | standing on the shore like an idiot.
Wellfleet Communications, Inc. |
Network Management Development | -- Steven Wright
\_____________________________________________________________________________/
Technical Details
Message-ID:
<9307230635.AA13189@lemming.wellfleet>Path:
arc1-ca.pugleaf.net!gmd.de!rrz.uni-koeln.de!news.dfn.de!darwin.sura.net!howland.reston.ans.net!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!wellfleet.COM!psmithShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,a252c2e63ece416,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1993-07-23 01:26:08 PST Path: arc1-ca.pugleaf.net!gmd.de!rrz.uni-koeln.de!news.dfn.de!darwin.sura.net!howland.reston.ans.net!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!wellfleet.COM!psmith From: psmith@wellfleet.COM (Paul Smith) Newsgroups: gnu.gcc.help Subject: GCC cross-compiler environment---pointers/help needed Date: 23 Jul 1993 02:38:47 -0400 Organization: GNUs Not Usenet Lines: 184 Sender: daemon@cis.ohio-state.edu Distribution: gnu Message-ID: <9307230635.AA13189@lemming.wellfleet> Reply-To: psmith@wellfleet.com