Re: New C compiler and analyzer lang/cparser in ports



Alexander Leidinger schrieb:
Quoting Christoph Mallon <christoph.mallon@xxxxxx> (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
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: trying to compile gnat
    ... checking host system type... ... checking for gcc... ... The following requested languages could not be built: ada ... Looks like you are running one of those GNAT distributions where the compiler driver for gnat is gnatgcc instead of just plain old gcc. ...
    (comp.lang.ada)
  • Re: asm volatile
    ... Only for gcc. ... intrinsics are often better - although they are normally restricted to single assembly instructions while your asm function/macro may cover more. ... Even better, of course, is when the compiler can recognise patterns in the C source and generate code directly. ... correct way of dealing with inline assembler. ...
    (comp.arch.embedded)
  • Re: asm volatile
    ... Only for gcc. ... So any compiler that is able to handle inlined assembly at least as well as gcc must have some way to distinguish ... of dealing with inline assembler. ... optimization are mutually exclusive things - unless the compiler understands ...
    (comp.arch.embedded)
  • Re: CodeWarrior 10 on Macintel
    ... But CW was definitely showing its age. ... >> be a front-end to gcc eventually. ... > they refused Apple's offer to provide a serious inline assembler, ... I wasn't commenting on the 'quality' of CW's compiler. ...
    (comp.sys.mac.programmer.codewarrior)
  • Re: [PATCH] Use -fno-unit-at-a-time if gcc supports it
    ... > look into inline assembler, ... > solution would be to add the compiler flag, ... in question so gcc knows that is somehow calls the function. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)