Subject: EGCS and kernel source
To: None <tech-kern@netbsd.org>
From: Krister Walfridsson <cato@df.lth.se>
List: tech-kern
Date: 10/31/1998 17:01:13
One well known bug in gcc is that it doesn't report an error when it
encounter incorrect constraints in asm directives, but continues to
generate (bogus) code. This has not been a big problem with gcc 2.7.2,
but at least linux has big problems with egcs.

Egcs was changed a couple of days ago so that it report an error
for such asm, and now it cannot compiler our i386 kernel. I think
this can be the sys/dev/isa/if_we.c problem reported by Martin 
Husemann.

One asm the current egcs complains on are the following (from pio.h)

static __inline void
insb(int port, void *addr, int cnt)
{
        __asm __volatile("cld\n\trepne\n\tinsb"                 :
                                                                :
                         "d" (port), "D" (addr), "c" (cnt)      :
                         "%edi", "%ecx", "memory");
}

I don't understand why it complains, so I asked the egcs mailing list.
I got the answer

   You are clobbering ecx and edi explicitly *and* you reference them
   as an input or an output.  That is wrong.  Clobbers must not overlap
   with inputs or outputs.  If they do, the compiler will now issue an
   error.

and that I should RTFM. I have RTFM but I still don't think I know how
to correct all our asms. I guess I'm just stupid...

I hope someone understand this enough to make our kernel compilable
using egcs.

   /Krister