All of lore.kernel.org
 help / color / mirror / Atom feed
* xf86-video-intel (git-13461a1): BROKEN with clang-3.2 due to __cpuid() not available?
@ 2013-02-26 12:35 Sedat Dilek
  2013-02-26 12:58 ` Chris Wilson
  0 siblings, 1 reply; 8+ messages in thread
From: Sedat Dilek @ 2013-02-26 12:35 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 2614 bytes --]

With xf86-video-intel-git13461a1 [1] I see this:

[ build-log ]
...
  CC     sna_cpu.lo
8 warnings generated.
  CC     sna_damage.lo
  CC     sna_display.lo
sna_cpu.c:47:2: error: implicit declaration of function '__cpuid' is
invalid in C99 [-Werror,-Wimplicit-function-declaration]
        __cpuid(1, eax, ebx, ecx, edx);
        ^
sna_cpu.c:49:12: error: use of undeclared identifier 'bit_SSE3'
        if (eax & bit_SSE3)
                  ^
sna_cpu.c:52:12: error: use of undeclared identifier 'bit_SSSE3'
        if (eax & bit_SSSE3)
                  ^
sna_cpu.c:55:12: error: use of undeclared identifier 'bit_SSE4_1'
        if (eax & bit_SSE4_1)
                  ^
sna_cpu.c:58:12: error: use of undeclared identifier 'bit_SSE4_2'
        if (eax & bit_SSE4_2)
                  ^
sna_cpu.c:61:12: error: use of undeclared identifier 'bit_AVX'
        if (eax & bit_AVX)
                  ^
sna_cpu.c:64:12: error: use of undeclared identifier 'bit_MMX'
        if (edx & bit_MMX)
                  ^
sna_cpu.c:67:12: error: use of undeclared identifier 'bit_SSE'
        if (edx & bit_SSE)
                  ^
sna_cpu.c:70:12: error: use of undeclared identifier 'bit_SSE2'
        if (edx & bit_SSE2)
                  ^
sna_cpu.c:73:12: error: use of undeclared identifier 'bit_SSE4a'
        if (edx & bit_SSE4a)
                  ^
10 errors generated.
make[4]: *** [sna_cpu.lo] Error 1
make[4]: *** Waiting for unfinished jobs....

I checked for installed cpuid.h files, can't say if you this requires
the one from kernel or compiler sources.

In my running Linux-Next (next-20130226) kernel I have no "cpuid.h" header-file.

Checking the compiler side:

[ /usr/lib/gcc/x86_64-linux-gnu/4.6/include/cpuid.h ]
...
#if __GNUC__ >= 3
#define __cpuid(level, a, b, c, d)                      \
  __asm__ ("xchg{l}\t{%%}ebx, %1\n\t"                   \
           "cpuid\n\t"                                  \
           "xchg{l}\t{%%}ebx, %1\n\t"                   \
           : "=a" (a), "=r" (b), "=c" (c), "=d" (d)     \
           : "0" (level))
...
#endif
...

[ /opt/llvm/lib/clang/3.2/include/cpuid.h ]
...
static inline int __get_cpuid (unsigned int level, unsigned int *eax,
                               unsigned int *ebx, unsigned int *ecx,
                               unsigned int *edx) {
    __asm("cpuid" : "=a"(*eax), "=b" (*ebx), "=c"(*ecx), "=d"(*edx) :
"0"(level));
    return 1;
}
...

So, clang should be treated differently?

Regards,
- Sedat -

[1] http://cgit.freedesktop.org/xorg/driver/xf86-video-intel/commit/src/sna/sna_cpu.c?id=13461a18b1605feb17304d52136d100df50ca296

[-- Attachment #2: clang-3-2_cpuid.h --]
[-- Type: text/x-chdr, Size: 1606 bytes --]

/*===---- cpuid.h - X86 cpu model detection --------------------------------===
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 *===-----------------------------------------------------------------------===
 */

#if !(__x86_64__ || __i386__)
#error this header is for x86 only
#endif

static inline int __get_cpuid (unsigned int level, unsigned int *eax,
                               unsigned int *ebx, unsigned int *ecx,
                               unsigned int *edx) {
    __asm("cpuid" : "=a"(*eax), "=b" (*ebx), "=c"(*ecx), "=d"(*edx) : "0"(level));
    return 1;
}

[-- Attachment #3: gcc-4-6_cpuid.h --]
[-- Type: text/x-chdr, Size: 5624 bytes --]

/*
 * Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 *
 * This file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 3, or (at your option) any
 * later version.
 * 
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * Under Section 7 of GPL version 3, you are granted additional
 * permissions described in the GCC Runtime Library Exception, version
 * 3.1, as published by the Free Software Foundation.
 * 
 * You should have received a copy of the GNU General Public License and
 * a copy of the GCC Runtime Library Exception along with this program;
 * see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

/* %ecx */
#define bit_SSE3	(1 << 0)
#define bit_PCLMUL	(1 << 1)
#define bit_SSSE3	(1 << 9)
#define bit_FMA		(1 << 12)
#define bit_CMPXCHG16B	(1 << 13)
#define bit_SSE4_1	(1 << 19)
#define bit_SSE4_2	(1 << 20)
#define bit_MOVBE	(1 << 22)
#define bit_POPCNT	(1 << 23)
#define bit_AES		(1 << 25)
#define bit_XSAVE	(1 << 26)
#define bit_OSXSAVE	(1 << 27)
#define bit_AVX		(1 << 28)
#define bit_F16C	(1 << 29)
#define bit_RDRND	(1 << 30)

/* %edx */
#define bit_CMPXCHG8B	(1 << 8)
#define bit_CMOV	(1 << 15)
#define bit_MMX		(1 << 23)
#define bit_FXSAVE	(1 << 24)
#define bit_SSE		(1 << 25)
#define bit_SSE2	(1 << 26)

/* Extended Features */
/* %ecx */
#define bit_LAHF_LM	(1 << 0)
#define bit_ABM		(1 << 5)
#define bit_SSE4a	(1 << 6)
#define bit_XOP         (1 << 11)
#define bit_LWP 	(1 << 15)
#define bit_FMA4        (1 << 16)
#define bit_TBM         (1 << 21)

/* %edx */
#define bit_MMXEXT	(1 << 22)
#define bit_LM		(1 << 29)
#define bit_3DNOWP	(1 << 30)
#define bit_3DNOW	(1 << 31)

/* Extended Features (%eax == 7) */
#define bit_FSGSBASE	(1 << 0)
#define bit_BMI		(1 << 3)

#if defined(__i386__) && defined(__PIC__)
/* %ebx may be the PIC register.  */
#if __GNUC__ >= 3
#define __cpuid(level, a, b, c, d)			\
  __asm__ ("xchg{l}\t{%%}ebx, %1\n\t"			\
	   "cpuid\n\t"					\
	   "xchg{l}\t{%%}ebx, %1\n\t"			\
	   : "=a" (a), "=r" (b), "=c" (c), "=d" (d)	\
	   : "0" (level))

#define __cpuid_count(level, count, a, b, c, d)		\
  __asm__ ("xchg{l}\t{%%}ebx, %1\n\t"			\
	   "cpuid\n\t"					\
	   "xchg{l}\t{%%}ebx, %1\n\t"			\
	   : "=a" (a), "=r" (b), "=c" (c), "=d" (d)	\
	   : "0" (level), "2" (count))
#else
/* Host GCCs older than 3.0 weren't supporting Intel asm syntax
   nor alternatives in i386 code.  */
#define __cpuid(level, a, b, c, d)			\
  __asm__ ("xchgl\t%%ebx, %1\n\t"			\
	   "cpuid\n\t"					\
	   "xchgl\t%%ebx, %1\n\t"			\
	   : "=a" (a), "=r" (b), "=c" (c), "=d" (d)	\
	   : "0" (level))

#define __cpuid_count(level, count, a, b, c, d)		\
  __asm__ ("xchgl\t%%ebx, %1\n\t"			\
	   "cpuid\n\t"					\
	   "xchgl\t%%ebx, %1\n\t"			\
	   : "=a" (a), "=r" (b), "=c" (c), "=d" (d)	\
	   : "0" (level), "2" (count))
#endif
#else
#define __cpuid(level, a, b, c, d)			\
  __asm__ ("cpuid\n\t"					\
	   : "=a" (a), "=b" (b), "=c" (c), "=d" (d)	\
	   : "0" (level))

#define __cpuid_count(level, count, a, b, c, d)		\
  __asm__ ("cpuid\n\t"					\
	   : "=a" (a), "=b" (b), "=c" (c), "=d" (d)	\
	   : "0" (level), "2" (count))
#endif

/* Return highest supported input value for cpuid instruction.  ext can
   be either 0x0 or 0x8000000 to return highest supported value for
   basic or extended cpuid information.  Function returns 0 if cpuid
   is not supported or whatever cpuid returns in eax register.  If sig
   pointer is non-null, then first four bytes of the signature
   (as found in ebx register) are returned in location pointed by sig.  */

static __inline unsigned int
__get_cpuid_max (unsigned int __ext, unsigned int *__sig)
{
  unsigned int __eax, __ebx, __ecx, __edx;

#ifndef __x86_64__
  /* See if we can use cpuid.  On AMD64 we always can.  */
#if __GNUC__ >= 3
  __asm__ ("pushf{l|d}\n\t"
	   "pushf{l|d}\n\t"
	   "pop{l}\t%0\n\t"
	   "mov{l}\t{%0, %1|%1, %0}\n\t"
	   "xor{l}\t{%2, %0|%0, %2}\n\t"
	   "push{l}\t%0\n\t"
	   "popf{l|d}\n\t"
	   "pushf{l|d}\n\t"
	   "pop{l}\t%0\n\t"
	   "popf{l|d}\n\t"
	   : "=&r" (__eax), "=&r" (__ebx)
	   : "i" (0x00200000));
#else
/* Host GCCs older than 3.0 weren't supporting Intel asm syntax
   nor alternatives in i386 code.  */
  __asm__ ("pushfl\n\t"
	   "pushfl\n\t"
	   "popl\t%0\n\t"
	   "movl\t%0, %1\n\t"
	   "xorl\t%2, %0\n\t"
	   "pushl\t%0\n\t"
	   "popfl\n\t"
	   "pushfl\n\t"
	   "popl\t%0\n\t"
	   "popfl\n\t"
	   : "=&r" (__eax), "=&r" (__ebx)
	   : "i" (0x00200000));
#endif

  if (!((__eax ^ __ebx) & 0x00200000))
    return 0;
#endif

  /* Host supports cpuid.  Return highest supported cpuid input value.  */
  __cpuid (__ext, __eax, __ebx, __ecx, __edx);

  if (__sig)
    *__sig = __ebx;

  return __eax;
}

/* Return cpuid data for requested cpuid level, as found in returned
   eax, ebx, ecx and edx registers.  The function checks if cpuid is
   supported and returns 1 for valid cpuid information or 0 for
   unsupported cpuid level.  All pointers are required to be non-null.  */

static __inline int
__get_cpuid (unsigned int __level,
	     unsigned int *__eax, unsigned int *__ebx,
	     unsigned int *__ecx, unsigned int *__edx)
{
  unsigned int __ext = __level & 0x80000000;

  if (__get_cpuid_max (__ext, 0) < __level)
    return 0;

  __cpuid (__level, *__eax, *__ebx, *__ecx, *__edx);
  return 1;
}

[-- Attachment #4: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: xf86-video-intel (git-13461a1): BROKEN with clang-3.2 due to __cpuid() not available?
  2013-02-26 12:35 xf86-video-intel (git-13461a1): BROKEN with clang-3.2 due to __cpuid() not available? Sedat Dilek
@ 2013-02-26 12:58 ` Chris Wilson
  2013-02-26 13:20   ` Sedat Dilek
  0 siblings, 1 reply; 8+ messages in thread
From: Chris Wilson @ 2013-02-26 12:58 UTC (permalink / raw)
  To: Sedat Dilek; +Cc: intel-gfx

On Tue, Feb 26, 2013 at 01:35:51PM +0100, Sedat Dilek wrote:
> With xf86-video-intel-git13461a1 [1] I see this:
> 
> [ build-log ]
> ...
>   CC     sna_cpu.lo
> 8 warnings generated.
>   CC     sna_damage.lo
>   CC     sna_display.lo
> sna_cpu.c:47:2: error: implicit declaration of function '__cpuid' is
> invalid in C99 [-Werror,-Wimplicit-function-declaration]
>         __cpuid(1, eax, ebx, ecx, edx);
>         ^
[snip]

> So, clang should be treated differently?

It doesn't use cpuid.h unless the compiler claims to be gcc >= 4. It
would appear once again that clang is broken.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: xf86-video-intel (git-13461a1): BROKEN with clang-3.2 due to __cpuid() not available?
  2013-02-26 12:58 ` Chris Wilson
@ 2013-02-26 13:20   ` Sedat Dilek
  2013-02-26 13:33     ` Chris Wilson
  0 siblings, 1 reply; 8+ messages in thread
From: Sedat Dilek @ 2013-02-26 13:20 UTC (permalink / raw)
  To: Chris Wilson, Sedat Dilek, intel-gfx

On Tue, Feb 26, 2013 at 1:58 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> On Tue, Feb 26, 2013 at 01:35:51PM +0100, Sedat Dilek wrote:
>> With xf86-video-intel-git13461a1 [1] I see this:
>>
>> [ build-log ]
>> ...
>>   CC     sna_cpu.lo
>> 8 warnings generated.
>>   CC     sna_damage.lo
>>   CC     sna_display.lo
>> sna_cpu.c:47:2: error: implicit declaration of function '__cpuid' is
>> invalid in C99 [-Werror,-Wimplicit-function-declaration]
>>         __cpuid(1, eax, ebx, ecx, edx);
>>         ^
> [snip]
>
>> So, clang should be treated differently?
>
> It doesn't use cpuid.h unless the compiler claims to be gcc >= 4. It
> would appear once again that clang is broken.

Can you explain why clang is BROKEN in your eyes?

So, this cpuid.h is from the compiler's include-dir?
If YES, there is no __cpuid() used/defined in clang's "cpuid.h".
clang has __get_cpuid()...

Substituting like this...

--- a/src/sna/sna_cpu.c
+++ b/src/sna/sna_cpu.c
@@ -44,7 +44,7 @@ unsigned sna_cpu_detect(void)
        unsigned int eax, ebx, ecx, edx;
        unsigned features = 0;

-       __cpuid(1, eax, ebx, ecx, edx);
+       __get_cpuid(1, eax, ebx, ecx, edx);

        if (eax & bit_SSE3)
                features |= SSE3;

...leads to...

  CC     sna_cpu.lo
sna_cpu.c:47:17: warning: incompatible integer to pointer conversion
passing 'unsigned int' to parameter of type 'unsigned int *'; take the
address with & [-Wint-conversion]
        __get_cpuid(1, eax, ebx, ecx, edx);
                       ^~~
                       &
/opt/llvm/bin/../lib/clang/3.2/include/cpuid.h:28:66: note: passing
argument to parameter 'eax' here
static inline int __get_cpuid (unsigned int level, unsigned int *eax,
                                                                 ^
sna_cpu.c:47:22: warning: incompatible integer to pointer conversion
passing 'unsigned int' to parameter of type 'unsigned int *'; take the
address with & [-Wint-conversion]
        __get_cpuid(1, eax, ebx, ecx, edx);
                            ^~~
                            &
/opt/llvm/bin/../lib/clang/3.2/include/cpuid.h:29:46: note: passing
argument to parameter 'ebx' here
                               unsigned int *ebx, unsigned int *ecx,
                                             ^
sna_cpu.c:47:27: warning: incompatible integer to pointer conversion
passing 'unsigned int' to parameter of type 'unsigned int *'; take the
address with & [-Wint-conversion]
        __get_cpuid(1, eax, ebx, ecx, edx);
                                 ^~~
                                 &
/opt/llvm/bin/../lib/clang/3.2/include/cpuid.h:29:65: note: passing
argument to parameter 'ecx' here
                               unsigned int *ebx, unsigned int *ecx,
                                                                ^
sna_cpu.c:47:32: warning: incompatible integer to pointer conversion
passing 'unsigned int' to parameter of type 'unsigned int *'; take the
address with & [-Wint-conversion]
        __get_cpuid(1, eax, ebx, ecx, edx);
                                      ^~~
                                      &
/opt/llvm/bin/../lib/clang/3.2/include/cpuid.h:30:46: note: passing
argument to parameter 'edx' here
                               unsigned int *edx) {
                                             ^
sna_cpu.c:49:12: error: use of undeclared identifier 'bit_SSE3'
        if (eax & bit_SSE3)
                  ^
sna_cpu.c:52:12: error: use of undeclared identifier 'bit_SSSE3'
        if (eax & bit_SSSE3)
                  ^
sna_cpu.c:55:12: error: use of undeclared identifier 'bit_SSE4_1'
        if (eax & bit_SSE4_1)
                  ^
sna_cpu.c:58:12: error: use of undeclared identifier 'bit_SSE4_2'
        if (eax & bit_SSE4_2)
                  ^
sna_cpu.c:61:12: error: use of undeclared identifier 'bit_AVX'
        if (eax & bit_AVX)
                  ^
sna_cpu.c:64:12: error: use of undeclared identifier 'bit_MMX'
        if (edx & bit_MMX)
                  ^
sna_cpu.c:67:12: error: use of undeclared identifier 'bit_SSE'
        if (edx & bit_SSE)
                  ^
sna_cpu.c:70:12: error: use of undeclared identifier 'bit_SSE2'
        if (edx & bit_SSE2)
                  ^
sna_cpu.c:73:12: error: use of undeclared identifier 'bit_SSE4a'
        if (edx & bit_SSE4a)
                  ^
sna_cpu.c:76:2: error: implicit declaration of function '__cpuid' is
invalid in C99 [-Werror,-Wimplicit-function-declaration]
        __cpuid(7, eax, ebx, ecx, edx);
        ^
4 warnings and 10 errors generated.
make[3]: *** [sna_cpu.lo] Error 1

>From my understanding this happens as all those bit_XXX are not
defined in clang's cpuid.h!

Whereas gcc's cpuid.h has them:

$ grep bit_SSE /usr/lib/gcc/x86_64-linux-gnu/4.6/include/cpuid.h
#define bit_SSE3        (1 << 0)
#define bit_SSE4_1      (1 << 19)
#define bit_SSE4_2      (1 << 20)
#define bit_SSE         (1 << 25)
#define bit_SSE2        (1 << 26)
#define bit_SSE4a       (1 << 6)

Did you had a look at the attached cpuid.h files from gcc-4.6 and
llvm-3.2/clang-3.2?

Regards,
- Sedat -

> -Chris
>
> --
> Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: xf86-video-intel (git-13461a1): BROKEN with clang-3.2 due to __cpuid() not available?
  2013-02-26 13:20   ` Sedat Dilek
@ 2013-02-26 13:33     ` Chris Wilson
  2013-02-26 13:38       ` Sedat Dilek
  0 siblings, 1 reply; 8+ messages in thread
From: Chris Wilson @ 2013-02-26 13:33 UTC (permalink / raw)
  To: Sedat Dilek; +Cc: intel-gfx

On Tue, Feb 26, 2013 at 02:20:26PM +0100, Sedat Dilek wrote:
> On Tue, Feb 26, 2013 at 1:58 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > On Tue, Feb 26, 2013 at 01:35:51PM +0100, Sedat Dilek wrote:
> >> With xf86-video-intel-git13461a1 [1] I see this:
> >>
> >> [ build-log ]
> >> ...
> >>   CC     sna_cpu.lo
> >> 8 warnings generated.
> >>   CC     sna_damage.lo
> >>   CC     sna_display.lo
> >> sna_cpu.c:47:2: error: implicit declaration of function '__cpuid' is
> >> invalid in C99 [-Werror,-Wimplicit-function-declaration]
> >>         __cpuid(1, eax, ebx, ecx, edx);
> >>         ^
> > [snip]
> >
> >> So, clang should be treated differently?
> >
> > It doesn't use cpuid.h unless the compiler claims to be gcc >= 4. It
> > would appear once again that clang is broken.
> 
> Can you explain why clang is BROKEN in your eyes?

Because it claims to be gcc 4, yet fails to provide a function/macro
provided by gcc 4.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: xf86-video-intel (git-13461a1): BROKEN with clang-3.2 due to __cpuid() not available?
  2013-02-26 13:33     ` Chris Wilson
@ 2013-02-26 13:38       ` Sedat Dilek
  2013-02-26 13:50         ` Chris Wilson
  0 siblings, 1 reply; 8+ messages in thread
From: Sedat Dilek @ 2013-02-26 13:38 UTC (permalink / raw)
  To: Chris Wilson, Sedat Dilek, intel-gfx

On Tue, Feb 26, 2013 at 2:33 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> On Tue, Feb 26, 2013 at 02:20:26PM +0100, Sedat Dilek wrote:
>> On Tue, Feb 26, 2013 at 1:58 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>> > On Tue, Feb 26, 2013 at 01:35:51PM +0100, Sedat Dilek wrote:
>> >> With xf86-video-intel-git13461a1 [1] I see this:
>> >>
>> >> [ build-log ]
>> >> ...
>> >>   CC     sna_cpu.lo
>> >> 8 warnings generated.
>> >>   CC     sna_damage.lo
>> >>   CC     sna_display.lo
>> >> sna_cpu.c:47:2: error: implicit declaration of function '__cpuid' is
>> >> invalid in C99 [-Werror,-Wimplicit-function-declaration]
>> >>         __cpuid(1, eax, ebx, ecx, edx);
>> >>         ^
>> > [snip]
>> >
>> >> So, clang should be treated differently?
>> >
>> > It doesn't use cpuid.h unless the compiler claims to be gcc >= 4. It
>> > would appear once again that clang is broken.
>>
>> Can you explain why clang is BROKEN in your eyes?
>
> Because it claims to be gcc 4, yet fails to provide a function/macro
> provided by gcc 4.

Even clang latest-git has same file [1].
Any workaround you can imagine?

- Sedat -

[1] https://github.com/llvm-mirror/clang/blob/master/lib/Headers/cpuid.h

> -Chris
>
> --
> Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: xf86-video-intel (git-13461a1): BROKEN with clang-3.2 due to __cpuid() not available?
  2013-02-26 13:38       ` Sedat Dilek
@ 2013-02-26 13:50         ` Chris Wilson
  2013-02-26 14:11           ` Sedat Dilek
  0 siblings, 1 reply; 8+ messages in thread
From: Chris Wilson @ 2013-02-26 13:50 UTC (permalink / raw)
  To: Sedat Dilek; +Cc: intel-gfx

On Tue, Feb 26, 2013 at 02:38:14PM +0100, Sedat Dilek wrote:
> On Tue, Feb 26, 2013 at 2:33 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > On Tue, Feb 26, 2013 at 02:20:26PM +0100, Sedat Dilek wrote:
> >> On Tue, Feb 26, 2013 at 1:58 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> >> > On Tue, Feb 26, 2013 at 01:35:51PM +0100, Sedat Dilek wrote:
> >> >> With xf86-video-intel-git13461a1 [1] I see this:
> >> >>
> >> >> [ build-log ]
> >> >> ...
> >> >>   CC     sna_cpu.lo
> >> >> 8 warnings generated.
> >> >>   CC     sna_damage.lo
> >> >>   CC     sna_display.lo
> >> >> sna_cpu.c:47:2: error: implicit declaration of function '__cpuid' is
> >> >> invalid in C99 [-Werror,-Wimplicit-function-declaration]
> >> >>         __cpuid(1, eax, ebx, ecx, edx);
> >> >>         ^
> >> > [snip]
> >> >
> >> >> So, clang should be treated differently?
> >> >
> >> > It doesn't use cpuid.h unless the compiler claims to be gcc >= 4. It
> >> > would appear once again that clang is broken.
> >>
> >> Can you explain why clang is BROKEN in your eyes?
> >
> > Because it claims to be gcc 4, yet fails to provide a function/macro
> > provided by gcc 4.
> 
> Even clang latest-git has same file [1].
> Any workaround you can imagine?

&& !defined(__clang__)

Based on the bug reports I have, I would strongly recommend not to use
clang as it is known to miscompile the ddx. My outlook is jaundiced
though as people report the failures but not if it ever then succeeds in
not exploding during use.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: xf86-video-intel (git-13461a1): BROKEN with clang-3.2 due to __cpuid() not available?
  2013-02-26 13:50         ` Chris Wilson
@ 2013-02-26 14:11           ` Sedat Dilek
  2013-02-26 14:31             ` Chris Wilson
  0 siblings, 1 reply; 8+ messages in thread
From: Sedat Dilek @ 2013-02-26 14:11 UTC (permalink / raw)
  To: Chris Wilson, Sedat Dilek, intel-gfx

[-- Attachment #1: Type: text/plain, Size: 1813 bytes --]

On Tue, Feb 26, 2013 at 2:50 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> On Tue, Feb 26, 2013 at 02:38:14PM +0100, Sedat Dilek wrote:
>> On Tue, Feb 26, 2013 at 2:33 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>> > On Tue, Feb 26, 2013 at 02:20:26PM +0100, Sedat Dilek wrote:
>> >> On Tue, Feb 26, 2013 at 1:58 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>> >> > On Tue, Feb 26, 2013 at 01:35:51PM +0100, Sedat Dilek wrote:
>> >> >> With xf86-video-intel-git13461a1 [1] I see this:
>> >> >>
>> >> >> [ build-log ]
>> >> >> ...
>> >> >>   CC     sna_cpu.lo
>> >> >> 8 warnings generated.
>> >> >>   CC     sna_damage.lo
>> >> >>   CC     sna_display.lo
>> >> >> sna_cpu.c:47:2: error: implicit declaration of function '__cpuid' is
>> >> >> invalid in C99 [-Werror,-Wimplicit-function-declaration]
>> >> >>         __cpuid(1, eax, ebx, ecx, edx);
>> >> >>         ^
>> >> > [snip]
>> >> >
>> >> >> So, clang should be treated differently?
>> >> >
>> >> > It doesn't use cpuid.h unless the compiler claims to be gcc >= 4. It
>> >> > would appear once again that clang is broken.
>> >>
>> >> Can you explain why clang is BROKEN in your eyes?
>> >
>> > Because it claims to be gcc 4, yet fails to provide a function/macro
>> > provided by gcc 4.
>>
>> Even clang latest-git has same file [1].
>> Any workaround you can imagine?
>
> && !defined(__clang__)
>
> Based on the bug reports I have, I would strongly recommend not to use
> clang as it is known to miscompile the ddx. My outlook is jaundiced
> though as people report the failures but not if it ever then succeeds in
> not exploding during use.

Can you explain what you mean with "miscompilation"?

Attached patch lets me compile intel-ddx with clang-3.2.

- Sedat -

> -Chris
>
> --
> Chris Wilson, Intel Open Source Technology Centre

[-- Attachment #2: 0001-sna-Workaround-clang-not-providing-__cpuid-function-.patch --]
[-- Type: application/octet-stream, Size: 1031 bytes --]

From 5a7d3e9a7a09e9ac607d10f348bafa1d2e80ce0c Mon Sep 17 00:00:00 2001
From: Sedat Dilek <sedat.dilek@gmail.com>
Date: Tue, 26 Feb 2013 15:06:13 +0100
Subject: [PATCH] sna: Workaround clang not providing __cpuid() function/macro


Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com>
---
 src/sna/sna_cpu.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/sna/sna_cpu.c b/src/sna/sna_cpu.c
index 9110456..09d7768 100644
--- a/src/sna/sna_cpu.c
+++ b/src/sna/sna_cpu.c
@@ -31,7 +31,13 @@
 
 #include "sna.h"
 
-#if defined(__GNUC__) && (__GNUC__ >= 4) /* 4.4 */
+/* XXX: Workaround: clang claims to be gcc-v4 compatible but does not provide
+ * a __cpuid() function/macro.
+ * Chris Wilson: "Based on the bug reports I have, I would strongly recommend
+ * not to use clang as it is known to miscompile the ddx."
+ * See <http://lists.freedesktop.org/archives/intel-gfx/2013-February/025187.html>.
+ */
+#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__clang__)
 
 #include <cpuid.h>
 
-- 
1.8.1.4


[-- Attachment #3: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: xf86-video-intel (git-13461a1): BROKEN with clang-3.2 due to __cpuid() not available?
  2013-02-26 14:11           ` Sedat Dilek
@ 2013-02-26 14:31             ` Chris Wilson
  0 siblings, 0 replies; 8+ messages in thread
From: Chris Wilson @ 2013-02-26 14:31 UTC (permalink / raw)
  To: Sedat Dilek; +Cc: intel-gfx

On Tue, Feb 26, 2013 at 03:11:50PM +0100, Sedat Dilek wrote:
> On Tue, Feb 26, 2013 at 2:50 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > On Tue, Feb 26, 2013 at 02:38:14PM +0100, Sedat Dilek wrote:
> >> On Tue, Feb 26, 2013 at 2:33 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> >> > On Tue, Feb 26, 2013 at 02:20:26PM +0100, Sedat Dilek wrote:
> >> >> On Tue, Feb 26, 2013 at 1:58 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> >> >> > On Tue, Feb 26, 2013 at 01:35:51PM +0100, Sedat Dilek wrote:
> >> >> >> With xf86-video-intel-git13461a1 [1] I see this:
> >> >> >>
> >> >> >> [ build-log ]
> >> >> >> ...
> >> >> >>   CC     sna_cpu.lo
> >> >> >> 8 warnings generated.
> >> >> >>   CC     sna_damage.lo
> >> >> >>   CC     sna_display.lo
> >> >> >> sna_cpu.c:47:2: error: implicit declaration of function '__cpuid' is
> >> >> >> invalid in C99 [-Werror,-Wimplicit-function-declaration]
> >> >> >>         __cpuid(1, eax, ebx, ecx, edx);
> >> >> >>         ^
> >> >> > [snip]
> >> >> >
> >> >> >> So, clang should be treated differently?
> >> >> >
> >> >> > It doesn't use cpuid.h unless the compiler claims to be gcc >= 4. It
> >> >> > would appear once again that clang is broken.
> >> >>
> >> >> Can you explain why clang is BROKEN in your eyes?
> >> >
> >> > Because it claims to be gcc 4, yet fails to provide a function/macro
> >> > provided by gcc 4.
> >>
> >> Even clang latest-git has same file [1].
> >> Any workaround you can imagine?
> >
> > && !defined(__clang__)
> >
> > Based on the bug reports I have, I would strongly recommend not to use
> > clang as it is known to miscompile the ddx. My outlook is jaundiced
> > though as people report the failures but not if it ever then succeeds in
> > not exploding during use.
> 
> Can you explain what you mean with "miscompilation"?

It generates invalid object code that cause segfaults during use.

Besides which as you have also demonstrated, it barely understands C.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-02-26 14:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-26 12:35 xf86-video-intel (git-13461a1): BROKEN with clang-3.2 due to __cpuid() not available? Sedat Dilek
2013-02-26 12:58 ` Chris Wilson
2013-02-26 13:20   ` Sedat Dilek
2013-02-26 13:33     ` Chris Wilson
2013-02-26 13:38       ` Sedat Dilek
2013-02-26 13:50         ` Chris Wilson
2013-02-26 14:11           ` Sedat Dilek
2013-02-26 14:31             ` Chris Wilson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.