Crossgcc for PPC under cygwin32

David Fiddes
Mon Jun 15 01:14:00 GMT 1998


> Hi to everybody,
> 	I am trying to build crossgcc under cygwin32 B19.1 for PowerPC. The
> BINUTILS building passed O'K. The problems started already while running
> configure script:
> ...............


> 	After all those errors there are no Makefiles created in
> build directory.
> 	May be my problem is that I didn't apply any patches? (I
> use gcc 2.8.1, do
> I need patches?).
> 	How all these "cd: lstat /d failed" may be eliminated under
> cygwin32?
> 	How this problem with sed may be fixed?

Are you running with binary mounts (run "mount with no params to find out)?
I would guess that's why things might fail. What version of gcc are you
using... I'm not sure but gcc-2.8 certainly had problems under cygwin32. I'd
recommend binutils-2.9.1, egcs-1.0.3a and newlib-1.8.0 as a base for
cygwin32 compilers... in case your interested here's the recipe I currently
use for m68k cygwin32 cross compilers:

1) Get Cygwin32 b19, binutils-2.9.1, egcs-1.0.3a, and newlib-1.8.0 and
install Cygwin32 beta 19 to say e:\cygnus.
(see for details on how to get
Cygwin32 beta 19 and your local GNU mirror for the rest)

2) Get Sergey Okhapkin's Coolview cywinb19.dll replacement from and replace the files in beta19 with the newer ones.

3) Run Cygwin32 from the Start menu.

4) Run the mount utility with no parameters to setup an initial mount table.

5) Create a Virtual UNIX root directory (on my system this is e:\unix).

6) Run "umount /" to disconnect the virtual unix root from the C: drive.
Then "mount -b e:\\unix /" to put it in the right place. You must include
the -b as this sets "binary mounts" which makes cygwin32 read text files as
unix text file rather than trying to do a fancy translation which is the
default behaviour. You also need to mount the cygnus directory by doing
something like "mount -b e:\\cygnus /cygnus" Note the double \'s as bash
interprets "\" as an escape char as in unix. You should end up with a mount
table a bit like:

bash-2.01$ mount
Device           Directory           Type        Flags
\\.\tape1:       /dev/st1            native      text!=binary
\\.\tape0:       /dev/st0            native      text!=binary
\\.\b:           /dev/fd1            native      text!=binary
\\.\a:           /dev/fd0            native      text!=binary
e:\cygnus        /cygnus             native      text=binary
e:\unix          /                   native      text=binary

If you get it wrong and mount the wrong directory or have the wrong
parameters you must umount the directory before retrying. If you don't
you'll get a "device or mount point busy" error just like unix...don't you
just love it?!?

7) Go to the root directory of your new "unix" system using "cd /". Run
"mkdir /bin" and "mkdir /tmp" to create a /bin and /tmp directory...check in
explorer that the directories have been put in the right place. Copy
bash.exe from e:\cygnus\b19\H-i386-cygwin32\bin to /bin/sh.exe to give you a
/bin/sh for shell scripts. Also copy bash.exe in H-i386-cygwin32/bin to
sh.exe replacing the original sh which is based on ash(a lightweight shell)
as it has a fair number of bugs.

8) Open /cygnus/H-i386-cygwin32/lib/gcc-lib/i386-cygwin32/2.7-B19/specs in a
UNIX format capable text editor. Change the line:

-lcygwin %{mwindows:-luser32 -lgdi32 -lcomdlg32} -lkernel32

to look like:
-lcygwin %{mwindows:-luser32 -lgdi32 -lcomdlg32} -lkernel32 -ladvapi32

This just adds an extra DLL to the default compile config which is needed to
compile EGCS and gcc2.8.

9) Create a /source directory and unpack egcs, binutils and newlib to it
using tar <---very very important...don't be tempted to use WinZip or
similar. It's "tar -xzvfegcs-1.0.3a.tar.gz" if you've forgotten. :)

10) Create a /build directory and add sub directories for binutils and egcs
e.g /build/binutils and /build/egcs.

11) Apply any patches to the source that you may have. Make sure that all
patched files are UNIX format as "patch" has a bad habit of producing DOS
format files which the compiler/build script occasionally have problems

12) cd to /source/egcs-1.0.3a. You have to create a symbolic link between
parts of newlib and the main compiler source here otherwise egcs wont build
right. Run "ln -s ../newlib-1.8.0/newlib newlib" and then "ln -s
../newlib-1.8.0/libgloss libgloss"

That's all the configuration we follow the unix build procedure.

13) Go to /build/binutils. Configure the tool by running
"/source/binutils-2.9.1/configure --target=m68k-coff --prefix=/gcc-m68k -ver
bose" This will take ages... Build the thing by running "make all" then
install by doing "make install". In this case it will install all the
binutils, gas, ld, etc to e:\unix\gcc-m68k

14) Edit e:\cygnus\b19\cygnus.bat and add e:\unix\gcc-m68k\bin to the PATH
statement. You need this so that the egcs build procedure can create target
libraries, etc. Remember to quit and restart your Cygwin32 bash shell so it
takes effect.

15) Goto /build/egcs Configure the compilers by running
"/source/egcs-1.0.3a/configure --target=m68k-coff --prefix=/gcc-m68k -verbos
e" This will take ages and ages and ages... Build the thing by running "make
cross LANGUAGES="c c++" "(don't use "all" here!) then install by doing
"make -k install LANGUAGES="c c++" ". In this case it will install all of
the compiler and libraries to /gcc-m68k.
Budget around 2-3 hours for this on a PII-233 with NT4 and 64MB of RAM.

16) Run strip *.exe in each install directory where there is EXE's to remove
useless debug information (be careful that you don't accidentally strip
libraries otherwise they're useless!!!)

You may have serious difficulties building the toolset under Windows 95 I've
not tried it sucessfully recently as there has been a nasty bug in the
Cygwin32 libraries that has been causing win95 to lock up erratically. I
think that the latest cygwinb19.dll has been fixed but I'm not sure. I would
seriously reccomend that you use a Win NT 4 machine for the build. Running
the finished compiler on 95 is not a problem.

hope that's of interest,

David Fiddes, CALM Software Production Officer
Department of Mathematics, Heriot-Watt University, Edinburgh
email - Tel: +44 131-451-3251
Le Mans 98 : Victoire! Allan McNish, Stephane Ortelli, Laurent Aiello  -
Porsche 911 GT1-98

More information about the crossgcc mailing list