delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/04/29/11:27:29

From: khan AT xraylith DOT wisc DOT edu (Mumit Khan)
Subject: building mingw32 cross-compiler [Re: gcc and cross-compilers]
29 Apr 1998 11:27:29 -0700 :
Message-ID: <Pine.HPP.3.96.980428103946.26885A-100000.cygnus.gnu-win32@hp2.xraylith.wisc.edu>
References: <199804271936 DOT WAA21669 AT freenet DOT hut DOT fi>
Mime-Version: 1.0
To: Kai Ruottu <karuottu AT freenet DOT hut DOT fi>
Cc: Hannu Koivisto <azure AT iki DOT fi>, gnu-win32 AT cygnus DOT com,
khan AT xraylith DOT wisc DOT edu

On Mon, 27 Apr 1998, Kai Ruottu wrote:

> Linux-to-mingw32 compiler from the egcs-1.0.2 sources and using
> the Mumit's libs and headers :
> -------------------------------------------------------------
> Problem:  Needs 'crt0.o' as the startup routine, mingw32 has 'crt1.o'.
> Solution: make a symbolic link from 'crt1.o' to 'crt0.o'

Hmmm ... the i386/config/mingw32.h does have crt1, so I don't understand
why you need this? Anyway, read on.

For the rest, did you apply my source patch to egcs-1.0.2 (these are
integrated into newer dev. snapshots, but didn't get into the release
tree on time)? Without these patches, you're pretty much out of luck.
See my ftp site for patches against 1.0.2:

 ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/releases/patches/

> 
>  After making five or so egcs-1.0.2-based compilers, this seems
> the hardest to make... Linux-to-cygwin32 with egcs-1.0.2 was just
> a piece of cake...
> 

I've been doing it for a long time now, so it can't be all that hard ;-)

Here's what you might do to build i386-mingw32-gcc on i386-linux-gnulibc1:

============= Building mingw32 cross compiler on Linux: ==================
Step 1: Choose an installation prefix. I usually use the following
  directory instead of dumping in /usr/local since I do multiple versions
  of both the compiler and cygwin32 which may/do conflict. Let's say you 
  choose the following:
      
      prefix = /usr/local/mingw32

Step 2: Get the includes and libraries from *pre-built* mingw32
  distribution (eg., mine at
  http://www.xraylith.wisc.edu/~khan/software/gnu-win32/) and populate the
  installation tree.

      % mkdir $prefix
      % mkdir $prefix/i386-mingw32/include
      % mkdir $prefix/i386-mingw32/lib
  
  Copy the /mingw32/i386-mingw32/include hierarchy to
  to $prefix/i386-mingw32/include and /mingw32/i386-mingw32/lib 
  hierarchy to $prefix/i386-mingw32/lib.

  These are the headers for mingw32 (*slightly* modified from Colin's 
  copy), startup files (crt1.0, dllcrt1.o), mingw helper libraries
  (libmingw32.a, libmoldnames.a), and the export libraries which are
  the same as mingw32 version (libkernel32.a, ...).

Build Binutils (gas, ld, etc):
=======================================================================

Step 1: Get binutils-2.9 source from one of the GNU sites.

Step 2: Configure, build and install:

      % cd /usr/local/src
      % gunzip -c /tmp/binutils-2.9.tar.gz | tar xvf -
      % cd binutils-2.9
      % mkdir binutils-2.9/XMINGW32
      % cd binutils-2.9/XMINGW32
      % ../configure --prefix=$prefix --target=i386-mingw32 -v
      % make
      % make install
    

Build the compiler (this is for egcs, gcc is similar but needs a bit more
work since it doesn't come with the C++ libraries, g77 etc):
=======================================================================

Step 1: Get the egcs-1.0.2 or whatever release source code from 
  ftp://egcs.cygnus.com/pub/ and *****APPLY MY PATCHES***** from
  ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/releases/patches/

Step 2: Unpack, patch, Configure, build and install:
   
   % cd /usr/local/src
   % gunzip -c /tmp/egcs-1.0.2.tar.gz | tar xvf -
   % cd egcs-1.0.2
   % patch -p2 -s < /tmp/egcs-1.0.2-mingw32.diff
   % mkdir XMINGW32
   % cd XMINGW32
   % ../configure --prefix=$prefix --target=i386-mingw32 -v
   % make
   % make install 

Note 1:
  g77 build: Depending on how your local setup is, you might need to 
  modify gcc/g77/Makefile to modify HOST_CC to use gcc instead of 
  `$(CC) -b $(host)'

Note 2: 
  If you're building the snapshots, you might need to create objc runtime
  info header by hand or just create an empty one.

Now you can run the compilers (after adding $prefix/bin to path) using
i386-mingw32-gcc etc.

=========================================================================

Hopefully I haven't missed any crucial step here. I would very much
appreciate if you would post whatever changes you actually needed to
get things done, and I'll put it up on my web page.

Regards,
Mumit


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019