*BSD News Article 18186


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!howland.reston.ans.net!sol.ctr.columbia.edu!destroyer!news.itd.umich.edu!news.itd.umich.edu!not-for-mail
From: pauls@terminator.rs.itd.umich.edu (Paul Southworth)
Newsgroups: comp.os.386bsd.questions
Subject: Re: How to build a Cross Compiler?
Date: 9 Jul 1993 13:11:21 -0400
Organization: Information Technology Division, University of Michigan
Lines: 48
Message-ID: <21k8rp$sig@terminator.rs.itd.umich.edu>
References: <21k4u1INNonr@gap.caltech.edu>
NNTP-Posting-Host: terminator.rs.itd.umich.edu

In article <21k4u1INNonr@gap.caltech.edu> you write:
>Because XFree86-1.3 doesn't fully work with NetBSD-current (namely because
>of the new db code) I am trying to build the whole XFree86-1.3 distribution
>from scratch on a Sparc Server 670.  The problem is, is that I need to
>find a cross linker and cross ar and ranlib that will link for NetBSD on a
>sun.  I looked on prep.ai.mit.edu for gld or something similar but could
>not find it.  Yes I did try archie and found three sites.. none of them
>had what I needed.  Is the linker called something else?  Also how
>do I create the need libgcc1.a?  Any help would be greatly appreciated..
>

I'm working on this as well, on a Sun4/60 system.  My understanding is
as follows (I haven't finished it yet so this is NOT authoritative):

1. you compile the first stage of gcc with the correct --target and --host
   and other flags to tell it where to look for libs and includes.  As far
   as I could tell you should only bother to do gcc and not the other 
   tools, like g++ -- specify this by doing "make LANGUAGES=c"

2. you compile the first stage of gcc on your NetBSD machine and snatch
   the libgcc1.a out of it.  I don't think there is any
   substitute for building it on the target machine.  Then I think you also
   need to grab (a) the fixed includes, and (b) the rest of the libs off the
   NetBSD machine from /usr/lib.  I would suspect that libgcc1.a that you
   grab should be from the identical distribution that you are making as
   your cross-compiler on the host machine.

3. DO NOT attempt to do stage 2-3 compiles because a cross compiler cannot
   be used to build itself. (Think about it...)

4. GNU ld is in the binutils distribution on prep.ai.mit.edu if memory
   serves.  You should be able to build just that piece of the binutils
   distribution.  You need to build it as a cross-linker.

5. GNU CC also produces assembler output.  You need to get the GNU GAS
   distribution and build that as a cross-assembler.

6. By my reading of the install docs, you can use the ar and ranlib from
   the Sun, but you need to put them in the directory tree where the rest
   of the cross-building stuff is, that is, you're going to do something
   like make /usr/i386-bsd/[bin, lib, and include] on the Sun, putting ar
   and ranlib in /usr/i386-bsd/bin, the fixed includes in ~include and the
   libs in ~lib.  This directory specification has to be hard wired into
   gcc when you build it, so think about it in advance.  My configure
   options look like this:

configure --host=sun4-sunos4.1 --target=i386-bsd --prefix=/usr/i386-bsd
--local-prefix=/usr/i386-bsd