gcc VS g++

Michael Hohmuth hohmuth at innocent.com
Wed Jan 27 05:15:22 CET 1999


"Paul Phillips" <pphillips at ivue.com> writes:

> FYI gcc is version 2.7.2.3
> g++ is egcs-2.90.29 980515 (egcs-1.0.3 release)

> The GNU manual simple says that gcc uses 'C' linkage and g++ calls gcc and
> uses C++ linkage.

I don't thoroughly understand what might be meant with ``linkage''
here, but I don't think that linkage is a problem unless you combine
modules compiled with different compilers.  I have successfully used
Fiasco kernels compiled with the `gcc' driver from Gcc 2.7.2.3, so
certainly its ``linkage'' is alright.

One possible other reason for this problem is that you might be trying
to compile Fiasco without optimization ("-O" flag).  For Gcc 2.7.2.3 
I know for sure that this doesn't work: Optimization must be enabled
to allow inline-assembler code to work; if it's not, the compiler
skips the register-conflict-detection pass which makes sure arguments
for inline-assembler code are put into the correct CPU registers.
Maybe this has been corrected in Egcs (I haven't tried).

> I won't try to solve this problem right now as g++ seems to work OK. Your
> makefile uses gcc however, and I am wondering which I should be using. 

The Makefile shipped with the distribution should be using `egcc', a
driver which belongs to Egcs, so it should be using Egcs 1.0 or 1.1.
I recommend using a version of Egcs if you have access to it; Egcs 1.1
is best.

> One of your correspondence mentions a version of egcs, and I'm not
> sure of the relationships between gcc and egcs.

Gcc and Egcs are two different compiler distributions which both
include a C compiler and a C++ compiler.  Normally, only one of the
distributions is installed on one system; the front ends (driver
programs) `gcc' and `g++' access the same compiler distribution, and
one can compile both C and C++ source files with both drivers.

However, newer Linux distributions confusingly come with both Gcc and
Egcs, and both distributions contain both the C compiler and the C++
compiler.  The driver program `gcc' is made to access Gcc, while `g++'
and `egcc' use Egcs.  As I said, all of these drivers can compile C
code and C++ code, but they access different compiler distributions.

The reason why both Egcs and Gcc are installed is that the Linux-2.0
kernel cannot be compiled with compilers newer than Gcc 2.7.2.x for
political reasons (Linus Torvalds and the Egcs team like to blame and
yell at each other for that).  However, supplying only this old
version of Gcc is unsatisfying because the newer C++ compilers offer
more features and are more standards-compliant.

Does this clear up some confusion?

Michael
-- 
hohmuth at innocent.com, hohmuth at inf.tu-dresden.de
http://home.pages.de/~hohmuth/



More information about the l4-hackers mailing list