From: hlu@luke.eecs.wsu.edu (Hongjiu Lu -- Graduate Student)
Newsgroups: alt.os.linux,comp.os.linux
Subject: FAQ: gcc 2.1 and kernel
Date: 7 Apr 92 20:14:20 GMT
Article-I.D.: serval.1992Apr7.201420.25450
Organization: Washington State University
Originator: hlu@luke.eecs.wsu.edu

Hi,

There seems some confusion about how to use gcc 2.1 to compile 0.95a
kernel with Linus's second patch. That may be my fault. Ok. Here is the
new FAQ for gcc 2.1. Please save it. THE ONE ON FTP SITES IS NOT SO
CLEAR AS THIS ONE.


H.J.
----------FAQ FOE GCC 2.1----
QUESTION: Where is the gcc 2.1 beta?

ANSWER: It's on banjo.concert.net under /pub/Linux/GCC and
headrest.woz.colorado.edu under /pub/linux/gcc. You may find it on the
other sites. But I am not sure if they are up to date. There are two
files, 2.1lib.tar.Z and 2.1misc.tar.Z. Another file, binutils.tar.Z,
is not the part of gcc 2.1, but used by gcc 2.1. It contains all the
binary utilities you need to run gcc 2.1.

There may be also some files called 2.1shared-x.tar.Z. They have some
programs compiled in .a format. It has almost everything you want for
Linux. Please take a look at

	/usr/shared/obj/README*

after unpack 2.1shared-A.tar.Z under /usr.

QUESTION: What are the contents of them?

ANSWER: 2.1lib.tar.Z contains cc1, cc1plus and cpp. 2.1misc.tar.Z
contains gcc 2.1 drivers, header files, libraries, manual pages and
installation instructions.

QUESTION: How do I install it?

ANSWER: First of all, backup the old compiler if you have one and
remove it from your hard drive. YOU MUST BE ABSOLUTELY SURE THERE IS NO
ANY OTHER C COMPILER ON YOUR SYSTEM INSTALLED. I have heard too many
stories about it. By compiler, I mean the executables, libraries 
(crt0.o) and header files. This gcc 2.1 will only work with the kernel
above 0.95. You may have to have 2 MB ram to run it and have some swap
space (> 4MB) since cc1 and cc1plus are about 1 MB. First do

	cd /usr
	tar xvpfvz xxxx/2.1misc.tar.Z

Then read FAQ in /usr/install/gcc2. After

	cd /usr
	tar xvpfvz xxxx/2.1lib.tar.Z

run the shell script "inst2.x". If you need binutils.tar.Z, do a

	cd /usr
	tar xvpfvz xxxx/binutils.tar.Z

Please check the file permission for all files you have unpacked. Maybe
I should write a shell script to do that.

QUESTION: How do I install a new release of gcc 2.1?

ANSWER: Depends on the nature of the new release, if the gcc itself is
changed, you have to install everything in 2.1lib.tar.Z and
2.1misc.tar.Z come with the new release. If just the libraries are
changed, you can just pick 2.1update.tar.Z and unpack it in /usr. Then
do

	cd /usr
	tar xvpfvz xxxx/2.1update.tar.Z
	cd /usr/install/gcc2
	update2.x

In both cases, it is recommended to relink all the shared executables.
If the gcc itself is changed, a new set of .a's may be released too.

QUESTION: What are the main differences with the old release?

ANSWER: Here are the features

1. gcc and g++ are in one.

2. ANSI and BSD 4.4 compatible stdio.

3. iostream for g++. It has

* Full implementation of ANSI C stdio.
* Full implementation of the streambuf layer of AT&T's
  iostream library for C++.
* Full compatibility between stdio and streambufs.

and libg++.a 2.0.

4. Libc.a is almost new. Most of glibc.a 1.02 (nonnetwork stuffs) are 
here.

	a. ctype
	b. grp
	c. locale
	d. malloc (libmcheck.a)
	e. posix
	f. pwd
	g. stdlib
	h. string

Some other functions are added.

	b. cvt
	b. drand48
	c. getlogin (poeigl-1.2)
	d. getpass (poeigl-1.2)
	e. mkfifo (is that supported in kernel?)
	f. regex (GNU)
	g. curses (BSD)
	h. swab
	i. time (BSD, untested)
	j. ufc
	k. utmp stuffs (poeigl-1.2)

These old functions are not changed very much.

	a. soft math (fmod is added)
	b. math (some are new)
	c. termcap
	d. unistd

5. The shared libraries are here. To link with the static libraries,
add the -static flag to gcc.

QUESTION: Is stdio ANSI compatible?

ANSWER: Yes, please test it.

QUESTION: Is g++ in 2.1?

ANSWER: Yes. Use g++ to compile the C++ code. Libg++.a 2.0 is here.
One thing missing is curses. I will take a look if I have time. And
fix.o failed to compile. 

QUESTION: What options can I use for gcc?

ANSWER: Read manual page, gcc.ps or gcc.man. -O3, -O4, -O5 or even
higher should work with 2.1. -O3 is said to be the best. Don't ask me
why. Try it yourself. I was told you could manipulate those optimation
flags to get the best performance. Also -static tells gcc to use the
static libraries. The default is the shared libraries.

QUESTION: Where is the source code of the new libc.a?

ANSWER: The same place you find this file. It is called libc-2.1.tar.Z.

QUESTION: How can I use gcc 2.1 to compile the kernel?

ANSWER: The kernel has to be compiled with the header files come with
it. Please use my 2.1kernel.tar.Z and 2.1ps.tar.Z, which can be found
where you get gcc 2.1. The kernel uses its own header files. Do not
include any header files from gcc 2.1 while compiling the kernel.

QUESTION: Why does gcc say "foo.h not found" when compiling the
kernel and I am following the instructions above?

ANSWER: Not every source code under ./linux is kernel code. By kernel,
I mean those linked together and written to boot image. If there is a
file which is compiled to run under Linux, that is an application and
you should follow the instruction below. ./tools/build is one of them.
It should be compiled with gcc 2.1 header files. Please read my
2.1kernel.tar.Z.

QUESTION: How can I use gcc 2.1 to compile applications?

ANSWER: Any application has to be compiled with the header files come
with gcc 2.1. If you need some header files from the kernel sources,
do a

	#include "/foo/src/linux/include/linux/bar.h"

It is strongly recommended to prototype all the library functions by
including the appropriate head files. At least, it will save you
trouble of malloc (0) (read stdlib.h).

QUESTION: Why does a program compiled ok by gcc 2.1 and the new binary
utilities get an error from kernel saying something about binary file
format or some weird things?

ANSWER: Linux has changed a.out.h. The new a.out.h in Linus' second
patch is compatible with the applications compiled with the old
a.out.h. But if an application is compiled with the new ld
(binutils.tar.Z) which uses the new a.out.h, you have to use the
kernel compiled with the new a.out.h. You have to recompile the kernel
with Linus' second patch applied and old ld. And then use new ld to
link the programs.

QUESTION: Why does g++ complain even die?

ANSWER: You need "expr", which is in GNU shell utilities 1.6, echo (?)
and sed.