DragonFly BSD
DragonFly kernel List (threaded) for 2003-11
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Non-gcc compilers


From: Alexander Leidinger <Alexander@xxxxxxxxxxxxx>
Date: Mon, 17 Nov 2003 11:56:01 +0100

On Sun, 16 Nov 2003 14:40:02 -0800 (PST)
Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx> wrote:

(CCing Marius Strobl, as he contributed parts of the patchset)

> :Please check if you have the patch with the in_cksum.c diff (using the 
> :asm version doesn't work with icc, ATM I don't know if this is a bug in 
> :the asm or in icc).
> 
>     Yes, I've got that, though I am horrified!  Horrified by the in_cksum
>     code, that is, not the patch :-).  Holy cow!

The first time I looked at it I was a little bit irritated too. I've
first seen the short asm version in in_cksum.h and then was pointed to
the huge C version. As I just wanted to get it working, I've just copied
the bits from sys/alpha/alpha/in_cksum.c and tested the resulting
kernel.

If someone decides to improve the C version, he should also have a look
at the asm version (I'm interested to see the final diff). In an
discussions on the developers list David O'Brien told us:
---snip---
> Of course, there are other possibilities.  For instance, it could
> be an icc bug...

No it is our code bug.  This is now one of the biggest reasons we can't
build i386 kernels with -O2.  The GCC bugs that bit us before are
[mostly] gone.
---snip---

>     I am augmenting the mk/*.mk files by adding a CC_CLASS variable which
>     classifies the compiler as "icc" or "gcc".  This way the CC variable
>     can be set to a particular version of an icc or gcc compiler without
>     messing up the conditionals (e.g. 'gcc33').

Sounds good in principle, but I wait for the actual implementation
before I comment further.

>     I am adjusting the cdefs.h.  This is what I have for cdefs.h so far.
>     It's a little messy at the moment, but what it comes down to is that I
>     am removing all __GNUC__ tests from the rest of the kernel codebase and
>     replacing those tests with __COMPILER_XXX_SUPPORTED__ tests.   This way
>     we will be able to work on compiler support entirely within the .mk and
>     cdefs.h files once the rest of the system source is conforming.

Looks good so far, I'm commenting more inline. You have to increase the
__DragonFly_version if you import the cdehs.h changes, the icc ports
doesn't have to install the cdefs.h replacement header and needs a way
to know about it.

[parts of cdefs.h]
> #if defined(__GNUC__) || defined(__INTEL_COMPILER)
> #define __COMPILER_GNULIKE__
> #define __COMPILER_DOTDOT_MACROS_SUPPORTED__
> #define __COMPILER_INLINES_SUPPORTED__
> #define __COMPILER_GNULIKE_ATTRIBUTE_SUPPORTED__
> #define __COMPILER_GNULIKE_ASM_SUPPORTED__
> #endif

FreeBSD (and dragonfly) have an additional attribute which isn't in the
original gcc version and therefore isn't suported in icc.
__COMPILER_GNULIKE_ATTRIBUTE_SUPPORTED__ is not enough for this (or you
have to special case the FreeBSD specific attribute).

Do you want to include cdefs.h in every file which uses inline assembly?

> #if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3)
> #define __COMPILER_GNULIKE_VALIST__
> #elif defined(__INTEL_COMPILER)
> /*#define __COMPILER_GNULIKE_VALIST__ NOT YET */
> #endif
> 
> #if (defined(__GNUC__) && __GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ > 9)
> #define __COMPILER_GNULIKE_ASM_SUPPORTED2__
> #elif defined(__ICC)
> #define __COMPILER_GNULIKE_ASM_SUPPORTED2__
> #endif
> 
> #if defined(__GNUC__)
> #if __GNUC__ >= 2
> #define __COMPILER_PRAGMA_PACK_SUPPORTED__
> #endif
> #elif defined(__INTEL_COMPILER)
> #define __COMPILER_PRAGMA_PACK_SUPPORTED__
> #endif

Why don't you merge them together (defined(__GNUC__) ||
defined(__INTEL_COMPILER)), do you want a strict separation?

> #if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7
> #define __dead2		__attribute__((__noreturn__))
> #define __pure2		__attribute__((__const__))
> #define __unused
> #elif __GNUC_PREREQ__(2, 7)
> #define __dead2		__attribute__((__noreturn__))
> #define __pure2		__attribute__((__const__))
> #define __unused	__attribute__((__unused__))
> #define __packed        __attribute__((__packed__))
> #define __aligned(x)    __attribute__((__aligned__(x)))
> #define __section(x)    __attribute__((__section__(x)))
> #elif defined(__INTEL_COMPILER)
> #define __dead2		__attribute__((__noreturn__))
> #define __pure2		__attribute__((__const__))
> #define __unused	__attribute__((__unused__))
> #define __packed	__attribute__((__packed__))
> #define __aligned(x)	__attribute__((__aligned__(x)))
> #define __section(x)	__attribute__((__section__(x)))
> #elif !defined(__COMPILER_GNULIKE__)
> #define __dead2
> #define __pure2
> #define __unused
> #endif

Do you intent to use the __COMPILER_GNULIKE_ATTRIBUTE_SUPPORTED__ define
here?

> /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
> #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
> #define __func__        NULL
> #endif
> 
> #endif	/* LINT */
> 
> /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
> #if !(__GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3)
> #define	__func__	NULL
> #endif

I assume this isn't intended.

> /*
>  * Compiler-dependent macros to declare that functions take printf-like
>  * or scanf-like arguments.  They are null except for versions of gcc
>  * that are known to support the features properly (old versions of gcc-2
>  * didn't permit keeping the keywords out of the application namespace).
>  */
> #if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 7
> #define	__printflike(fmtarg, firstvararg)
> #define	__scanflike(fmtarg, firstvararg)
> #else
> #define	__printflike(fmtarg, firstvararg) \
> 	    __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
> #define	__scanflike(fmtarg, firstvararg) \
> 	    __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
> #endif
> 
> /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
> #if __FreeBSD_cc_version >= 300001
> #define	__printf0like(fmtarg, firstvararg) \
> 	    __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
> #else
> #define	__printf0like(fmtarg, firstvararg)
> #endif

I have to test if those are supported in a recent icc...

> #if defined(__GNUC__) || defined(__ICC)
> #ifndef __INTEL_COMPILER
> #define __strong_reference(sym,aliassym)	\
> 	extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
> #endif

. ..and this too.

Bye,
Alexander.

-- 
      ...and that is how we know the Earth to be banana-shaped.

http://www.Leidinger.net                       Alexander @ Leidinger.net
  GPG fingerprint = C518 BC70 E67F 143F BE91  3365 79E2 9C60 B006 3FE7



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]