Xref: wupost comp.unix.xenix.sco:4106 alt.sources:3916
Path: wupost!zaphod.mps.ohio-state.edu!samsung!uunet!mcsun!ukc!stl!robobar!ronald
From: Steve.Bleazard@robobar.Co.Uk
Newsgroups: comp.unix.xenix.sco,alt.sources
Subject: Xenix Patch Kit for GAS 1.38.1/GCC 1.40/GDB 3.5 (part 1/4)
Message-ID: <Xenix/gcc-1.40a.txt@robobar.co.uk>
Date: 27 Aug 91 14:26:02 GMT
Sender: ronald@robobar.co.uk (Ronald S H Khoo)
Organization: Robobar Ltd., Perivale, Middx., ENGLAND.
Lines: 219
X-Md4-Signature: cf830922cf3330ce10c53d35cfd2f692

Archive-Name: Xenix/gcc-1.40a.txt

This is part 1 of a 4 part posting.
This part contains only the README for this patch kit
Please save it separately in a file called README.GCC

# @(#) $Id: README.GCC,v 1.2 1991/08/22 20:02:56 ronald Exp $

This README describes the port of GNU CC to SCO XENIX 386 from RoboBar Ltd.
This port consists of patch kits to GCC 1.40, GAS 1.38.1 and GDB 3.5
The port was done by Steve Bleazard <steve@robobar.co.uk> with assistance
from Ronald Khoo <ronald@ibmpcug.co.uk> who wrote this README and packaged
the kit.

Disclaimer:  RoboBar Ltd has no connection with the Santa Cruz Operation
	     whatsoever, other than being an indirect customer of theirs.
	     There is no warranty, nor claim of fitness for any purpose of
	     any program code you may happen to find in these files.
	     Various trademarks of Intel Corp,  Microsoft Corp, and the
	     Santa Cruz Operation, Inc. are mentioned in these files,
	     and are hereby acknowledged.

(C) Copyright 1991 RoboBar Ltd.  Permission is granted to redistribute
    this article without any encumbrance, other than that this copyright
    notice be retained, and that any modifications be clearly marked as such.

Overview:

This port works on SCO XENIX 386.  It has been tested on:
	OS version: 2.3.4  with  Development System version 2.3.1b
but we believe that it should be useable with some effort on versions
2.2 and later.

The object file format used is the native Microsoft/Intel OMF format,
	so the GNU binutils are not used.  Therefore, this port is
	compatible with third party SCO-compatible object libraries.
The SCO Development System provides the system libraries and include files.
The standard Microsoft assembler is not used -- instead the GNU assembler
	was ported to produce OMF.
A linker helper-program (provided by Christoph Badura <bad@flatlin.ka.sub.org>,
	installed as /usr/local/lib/gcc-ld) helps gcc's -L -l options to work.
	However, the standard XENIX /bin/ld does the real linking--it
	is executed by Christoph's program.
Symbolic debugging is supported for the accompanying port of GDB only.
	SCO's sdb debugging format is not documented, and seems to change
	from release to release, so we can't support it.
The port of GDB was started from an sdb-based port by rdk386!ron (Ron Kuris)
	Without his lead, this port would probably not exist.
The GNU compiler system, as modified by these patches, serves as our
	production compiler at RoboBar.  We believe it to be of
	production quality, and in any case of much higher quality than
	SCO XENIX's native Microsoft compiler system.

This README documents how to compile and install this GCC port from
the patches alone.  You can skip some of the steps if you already
have XENIX GCC binaries from earlier versions of this XENIX GCC port.
If you are building from scratch, you can use the commands indicated
by => in this README as a guide.  On *our* system, those commands
were directly executed from this file via a script.  If your version
of XENIX or the Development System is different from ours, you may
have to hack a bit, though.

Note that parts of the procedure require you to be root, with a umask no
more paranoid than 022.

What you need:

	SCO XENIX 386 Operating System
	SCO XENIX 386 Development System
	Larry Wall's "patch" program, version 2, patchlevel 12.
		(from volume 7 of comp.sources.unix, or the GNU
		 enhanced one from prep.ai.mit.edu)
	The standard GNU distributions of the compiler and assembler:
		gcc-1.40.tar.Z and gas-1.38.1.tar.Z
		(from prep.ai.mit.edu:/pub/gnu)
	The three patches in this kit:
		gcc-1.40.pch
		gas-1.38.pch
		gdb-3.5b.pch
	A modicum of free disc space.  10 Mb is comfortable.  You can
	do it with less, but the instructions here assume 10Mb free.

	Patience.  Lots of patience.  The patience of a saint.

What to do:

	First, ensure /usr/local/bin is in your PATH, and that
	the "patch" program can be found in your path.
=>	PATH=/usr/local/bin:/bin:/usr/bin export PATH

	Next, unpack the GNU distributions, and copy alloca.c from
	the GCC directory into the GAS directory:

=>	zcat < gas-1.38.1.tar.Z | tar xf -
=>	zcat < gcc-1.40.tar.Z | tar xf -
=>	zcat < gdb-3.5.tar.Z | tar xf -
=>	cp gcc-1.40/alloca.c gas-1.38/alloca.c

	Now, compile the GNU assembler with the standard compiler.
		(Do not switch the optimiser on, as this will cause
		 incorrect code to be generated.  And "const" breaks it)
=>	cd gas-1.38
=>	patch < ../gas-1.38.pch
=>	cc -c alloca.c
=>	make ax386 G0="-Dconst= -DUSG -DWORKING_DOT_WORD" O1= LOADLIBES=alloca.o

	(Throughout this build, you will get plenty of warning messages
	 from the compiler.  At this stage, it is best to ignore them)

	Now, install the assembler as /usr/local/lib/gcc-as

=>	mkdir /usr/local ; mkdir /usr/local/lib ; mkdir /usr/local/bin
=>	cp ax386 /usr/local/lib/gcc-as

	Now, you need to make minimal necessary changes to your
	system include files and then build gcc itself.
	You may have to modify fixmin.xenix depending on your version
	of the Operating and Development systems.  Sigh.

=>	cd ../gcc-1.40
=>	patch -p < ../gcc-1.40.pch
=>	sh fixmin.xenix		# have to be root to do this!
=>	sh config.gcc xenix386

	Compile gcc for the first time using the Microsoft compiler:

=>	make -f Makefile.msc -f Makefile msc ALLOCA=alloca.o CFLAGS=

	(This build may fail somewhere and core dump near the end when
	 it tries to build gnulib2.  Ignore it, it doesn't matter)

	Save this version of gcc, then make gcc with this saved version.

=>	make stage1
=>	make CC=stage1/gcc CFLAGS=-Bstage1/	# cannot optimise yet

	Now we can build an optimised version of gcc.

=>	make stage2
=>	rm -rf stage1	# regain some disc space if you're short of it.
=>	make CC=stage2/gcc CFLAGS="-Bstage2/ -O"

	At this point, we have a correctly compiled version of gcc.
	We now install it, then go and recompile gas with gcc

=>	make install INSTALL=cp
=>	cd ../gas-1.38
=>	rm -f *.o ax386
=>	make ax386 G0="-O -DUSG -DWORKING_DOT_WORD" O1= LOADLIBES= CC=gcc
=>	cp ax386 /usr/local/lib/gcc-as
=>	rm -f /usr/local/bin/gas
=>	ln /usr/local/lib/gcc-as /usr/local/bin/gas

	Finally, we compile gcc again, using a correctly built gas.

=>	cd ../gcc-1.40
=>	make stage3
=>	rm -rf stage2	# regain some disc space if you're short of it.
=>	make CC=stage3/gcc CFLAGS="-Bstage3/ -O"

	In fact, if we're lucky, this version should be identical to
	the previous version, and if it is, we're happy.  So let's check.

=>	for i in *.o ; do cmp -s $i stage3/$i || echo $i broke ; done

	(Hopefully none should break, if any do, you will have to iterate
	 through more stage builds of both gcc and gas until it no longer
	 breaks)

	Now, we install Christopher's ld helper program so that
	gcc's -l and -L options will work:

=>	gcc -O -Iconfig xenixld.c -o gcc-ld
=>	cp gcc-ld /usr/local/lib/gcc-ld

	Now, it's probably wise to undo the damage we did to /usr/include

=>	sh fixmin.xenix undo

	However, the include files are really not in a useable state.
	You will have to hack them a lot, but the fix.h.xenix file contains
	a few useful hints.  But *PLEASE* read it before you execute it,
	as it may well need customising for your site.  In particular,
	if you've done stuff like adding #ifdef _SIZE_T to your include files,
	the script may not work anymore.  But the __M_I386__ hack in there
	must be done, or else you won't be able to use gcc -ansi.

=>	sh fix.h.xenix

	I guess a debugger is useful to have so let's build that:

=>	cd ../dist-gdb
=>	patch -p < ../gdb-3.5b.pch
=>	sh config.gdb xenix386

	Depending on the version of your Development System libraries,
	you may have to edit m-xenix386.h at this point to #define
	the symbol PTRACE_ADDR_ARG_STRUCT.  This is necessary for version 2.2,
	but not for 2.3 (the default).

=>	make CC=gcc GLOBAL_CFLAGS="-O -I. -traditional -DNO_PROTOTYPE"
=>	mv gdb /usr/local/bin

	There's a helper module that's useful for use with GDB.
	Read the source file gdbspace.asm for more info.
	(/usr/lib/storel is part of your XENIX link kit).
=>	/usr/lib/storel gdbspace.asm && mv gdbspace.o /usr/local/lib/libgdb.a

	Then it's probably time for a long beer.  Of course, Murphy's
	Law states that your disc controller will probably die,
	destroying your disc in the process just at this point ....

If you come across any XENIX-related GCC problems, please send mail to
Steve Bleazard <steve@robobar.co.uk>  or  uunet!mcsun!ukc!robobar!steve
-- 
Steve.Bleazard@RoboBar.Co.Uk        | Phone:  +44 81 991 1142 x153
Snr Software Engineer, Robobar Ltd. | Fax:    +44 81 998 8343 (G3)
22 Wadsworth Road, Perivale.        |
Middx., UB6 7JD ENGLAND.            | ...!ukc!robobar!steve
