Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Nov 2008 12:20:07 +0100
From:      Christoph Mallon <christoph.mallon@gmx.de>
To:        Alexander Leidinger <Alexander@Leidinger.net>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: New C compiler and analyzer lang/cparser in ports
Message-ID:  <492FD3E7.6000205@gmx.de>
In-Reply-To: <20081128093858.57826oi96gmzliww@webmail.leidinger.net>
References:  <492F0591.7050807@gmx.de> <20081128093858.57826oi96gmzliww@webmail.leidinger.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Alexander Leidinger schrieb:
> Quoting Christoph Mallon <christoph.mallon@gmx.de> (from Thu, 27 Nov 
> 2008 21:39:45 +0100):
> 
>> cparser is a C compiler, which can parse C89 and C99 as well as many 
>> GCC and some MSVC extensions. The handled GCC extensions include 
>> __attribute__, inline assembler, computed goto and statement 
>> expressions. The compiler driver is compatible with with GCC (-fxxx, 
>> -Wxxx, -M, ...). It also provides many useful analyses for warnings - 
>> for some examples see below.
> 
> How much of the GCC stuff in /usr/include/cdefs.h would work with 
> cparser? Info: this is the major part one has to do to make another 
> compiler ready to compile our kernel.

I guess, you mean /usr/include/sys/cdefs.h. Let's have a look.

#define __GNUCLIKE_ASM 3
#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS

cparser supports GCC style inline assembler (except for x87 floating 
point constraints, which are not implemented, yet) and also supports 
builtins like __builtin_nanf.

#define __GNUCLIKE___TYPEOF 1
#define __GNUCLIKE___OFFSETOF 1

cparser supports __typeof__ and __builtin_offsetof

#define __GNUCLIKE___SECTION 1

This is missing.

#define __GNUCLIKE_ATTRIBUTE_MODE_DI 1

The __attribute__((mode($FOO)) insanity is supported.

# define __GNUCLIKE_CTOR_SECTION_HANDLING 1

__attribute__((constructor)) and destructor are supported.

#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
# define __GNUCLIKE_BUILTIN_VARARGS 1
# define __GNUCLIKE_BUILTIN_STDARG 1
# define __GNUCLIKE_BUILTIN_VAALIST 1

cparser handles these GCC builtins.

#define __CC_SUPPORTS_INLINE 1
#define __CC_SUPPORTS___INLINE 1
#define __CC_SUPPORTS___INLINE__ 1

I think we support all alternative spellings with any number of 
underscores for all keywords. (:

I'll skip some simple stuff now, which also works.

#define __dead2   __attribute__((__noreturn__))
#define __pure2   __attribute__((__const__))
#define __unused  __attribute__((__unused__))
#define __used    __attribute__((__used__))
#define __packed  __attribute__((__packed__))
#define __aligned(x)  __attribute__((__aligned__(x)))
#define __section(x)  __attribute__((__section__(x)))

All of these are parsed and except for __section__ are handled, e.g. 
__noreturn__ is used for optimization. We also have -Wmissing-noreturn, 
which warns about functions, which should have this attribute.

I'm skipping more attribute stuff.

#define __weak_reference(sym,alias) \
   __asm__(".weak " #alias); \
   __asm__(".equ "  #alias ", " #sym)

global asm statements are supported, too.

The compiler driver is compatible with GCC, but we need to support more 
switches. This is a matter of time and digging through GCC documentation.

Regards
	Christoph



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?492FD3E7.6000205>