clang-tidy & SSE with GCC toolchain

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

clang-tidy & SSE with GCC toolchain

Jon Chesterfield via cfe-dev

Hey!

 

I have a project which is compiled with GCC (7) and Clang (5.0). The clang built uses the GCC tool chain, like this (Red Hat 7 with devtoolset-7):

     clang++ -gcc-toolchain /opt/rh/devtoolset-7/root/usr […]

 

The code compiles and runs fine, but running clang-tidy (using the same compiler flags) chokes on the SSE built-ins in GCC’s headers:

/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/xmmintrin.h:54:3: error: argument to '__builtin_prefetch' must be a constant integer [clang-diagnostic-error]

  __builtin_prefetch (__P, (__I & 0x4) >> 2, __I & 0x3);

  ^

/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/xmmintrin.h:130:19: error: use of undeclared identifier '__builtin_ia32_addss' [clang-diagnostic-error]

  return (__m128) __builtin_ia32_addss ((__v4sf)__A, (__v4sf)__B);

                  ^

/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/xmmintrin.h:136:19: error: use of undeclared identifier '__builtin_ia32_subss' [clang-diagnostic-error]

  return (__m128) __builtin_ia32_subss ((__v4sf)__A, (__v4sf)__B);

 

[more errors following…]

 

This happens as soon as I include <xmmintrin.h> (e.g. indirectly via Boost.UUID).

 

I’m wondering that the clang compiler accepts the code, while clang-tidy doesn’t.

Any ideas how to fix this? My current workaround is to disable SSE-support in Boost.UUID via macro for clang-tidy, but the problem will re-appear as soon as some other lib tries to use SSE instructions.

 

Cheers,

Daniel Evers

 




Utimaco TS GmbH
Germanusstr. 4, D.52080 Aachen, Germany, Tel: +49-241-1696-0, www.utimaco.com
Seat: Aachen – Registergericht Aachen HRB 18923
VAT ID No.: DE 815 496 507
Managementboard: Malte Pollmann (Chairman) CEO, Dr. Frank J. Nellissen CFO

This communication is confidential. We only send and receive email on the basis of the terms set out at https://www.utimaco.com/en/e-mail-disclaimer/

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang-tidy & SSE with GCC toolchain

Jon Chesterfield via cfe-dev
The gcc version of xmmintrin.h is not compatible with clang. Clang has its own version. Maybe you need to explicitly add the clang include directory to your command line?

~Craig

On Thu, Jan 25, 2018 at 4:25 AM, Daniel Evers via cfe-dev <[hidden email]> wrote:

Hey!

 

I have a project which is compiled with GCC (7) and Clang (5.0). The clang built uses the GCC tool chain, like this (Red Hat 7 with devtoolset-7):

     clang++ -gcc-toolchain /opt/rh/devtoolset-7/root/usr […]

 

The code compiles and runs fine, but running clang-tidy (using the same compiler flags) chokes on the SSE built-ins in GCC’s headers:

/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/xmmintrin.h:54:3: error: argument to '__builtin_prefetch' must be a constant integer [clang-diagnostic-error]

  __builtin_prefetch (__P, (__I & 0x4) >> 2, __I & 0x3);

  ^

/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/xmmintrin.h:130:19: error: use of undeclared identifier '__builtin_ia32_addss' [clang-diagnostic-error]

  return (__m128) __builtin_ia32_addss ((__v4sf)__A, (__v4sf)__B);

                  ^

/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/xmmintrin.h:136:19: error: use of undeclared identifier '__builtin_ia32_subss' [clang-diagnostic-error]

  return (__m128) __builtin_ia32_subss ((__v4sf)__A, (__v4sf)__B);

 

[more errors following…]

 

This happens as soon as I include <xmmintrin.h> (e.g. indirectly via Boost.UUID).

 

I’m wondering that the clang compiler accepts the code, while clang-tidy doesn’t.

Any ideas how to fix this? My current workaround is to disable SSE-support in Boost.UUID via macro for clang-tidy, but the problem will re-appear as soon as some other lib tries to use SSE instructions.

 

Cheers,

Daniel Evers

 




Utimaco TS GmbH
Germanusstr. 4, D.52080 Aachen, Germany, Tel: <a href="tel:+49%20241%2016960" value="+4924116960" target="_blank">+49-241-1696-0, www.utimaco.com
Seat: Aachen – Registergericht Aachen HRB 18923
VAT ID No.: DE 815 496 507
Managementboard: Malte Pollmann (Chairman) CEO, Dr. Frank J. Nellissen CFO

This communication is confidential. We only send and receive email on the basis of the terms set out at https://www.utimaco.com/en/e-mail-disclaimer/

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang-tidy & SSE with GCC toolchain

Jon Chesterfield via cfe-dev
Daniel,
check the original compilation with -H to see which xmmintrin.h got compiled.

Does clang-tidy understand  -gcc-toolchain?


Csaba

On Thu, Jan 25, 2018 at 6:43 PM, Craig Topper via cfe-dev
<[hidden email]> wrote:

> The gcc version of xmmintrin.h is not compatible with clang. Clang has its
> own version. Maybe you need to explicitly add the clang include directory to
> your command line?
>
> ~Craig
>
> On Thu, Jan 25, 2018 at 4:25 AM, Daniel Evers via cfe-dev
> <[hidden email]> wrote:
>>
>> Hey!
>>
>>
>>
>> I have a project which is compiled with GCC (7) and Clang (5.0). The clang
>> built uses the GCC tool chain, like this (Red Hat 7 with devtoolset-7):
>>
>>      clang++ -gcc-toolchain /opt/rh/devtoolset-7/root/usr […]
>>
>>
>>
>> The code compiles and runs fine, but running clang-tidy (using the same
>> compiler flags) chokes on the SSE built-ins in GCC’s headers:
>>
>>
>> /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/xmmintrin.h:54:3:
>> error: argument to '__builtin_prefetch' must be a constant integer
>> [clang-diagnostic-error]
>>
>>   __builtin_prefetch (__P, (__I & 0x4) >> 2, __I & 0x3);
>>
>>   ^
>>
>>
>> /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/xmmintrin.h:130:19:
>> error: use of undeclared identifier '__builtin_ia32_addss'
>> [clang-diagnostic-error]
>>
>>   return (__m128) __builtin_ia32_addss ((__v4sf)__A, (__v4sf)__B);
>>
>>                   ^
>>
>>
>> /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/xmmintrin.h:136:19:
>> error: use of undeclared identifier '__builtin_ia32_subss'
>> [clang-diagnostic-error]
>>
>>   return (__m128) __builtin_ia32_subss ((__v4sf)__A, (__v4sf)__B);
>>
>>
>>
>> [more errors following…]
>>
>>
>>
>> This happens as soon as I include <xmmintrin.h> (e.g. indirectly via
>> Boost.UUID).
>>
>>
>>
>> I’m wondering that the clang compiler accepts the code, while clang-tidy
>> doesn’t.
>>
>> Any ideas how to fix this? My current workaround is to disable SSE-support
>> in Boost.UUID via macro for clang-tidy, but the problem will re-appear as
>> soon as some other lib tries to use SSE instructions.
>>
>>
>>
>> Cheers,
>>
>> Daniel Evers
>>
>>
>>
>>
>> ________________________________
>>
>> Utimaco TS GmbH
>> Germanusstr. 4, D.52080 Aachen, Germany, Tel: +49-241-1696-0,
>> www.utimaco.com
>> Seat: Aachen – Registergericht Aachen HRB 18923
>> VAT ID No.: DE 815 496 507
>> Managementboard: Malte Pollmann (Chairman) CEO, Dr. Frank J. Nellissen CFO
>>
>> This communication is confidential. We only send and receive email on the
>> basis of the terms set out at https://www.utimaco.com/en/e-mail-disclaimer/
>>
>> _______________________________________________
>> cfe-dev mailing list
>> [hidden email]
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>



--
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang-tidy & SSE with GCC toolchain

Jon Chesterfield via cfe-dev
Hi,

Thanks for the tip. I checked the output and clang++ uses its own includes instead of the GCC headers.
Does the compiler add some pre-defined include paths that the clang-based tools don't have by default?

Clang-tidy at least doesn't complain about -gcc-toolchain ;-) But I'm not sure if it's relevant here.

Thx
Daniel

-----Original Message-----
From: Csaba Raduly [mailto:[hidden email]]
Sent: Freitag, 26. Januar 2018 10:08
To: Craig Topper <[hidden email]>
Cc: Daniel Evers <[hidden email]>; [hidden email]
Subject: Re: [cfe-dev] clang-tidy & SSE with GCC toolchain

Daniel,
check the original compilation with -H to see which xmmintrin.h got compiled.

Does clang-tidy understand  -gcc-toolchain?


Csaba

On Thu, Jan 25, 2018 at 6:43 PM, Craig Topper via cfe-dev <[hidden email]> wrote:

> The gcc version of xmmintrin.h is not compatible with clang. Clang has
> its own version. Maybe you need to explicitly add the clang include
> directory to your command line?
>
> ~Craig
>
> On Thu, Jan 25, 2018 at 4:25 AM, Daniel Evers via cfe-dev
> <[hidden email]> wrote:
>>
>> Hey!
>>
>>
>>
>> I have a project which is compiled with GCC (7) and Clang (5.0). The
>> clang built uses the GCC tool chain, like this (Red Hat 7 with devtoolset-7):
>>
>>      clang++ -gcc-toolchain /opt/rh/devtoolset-7/root/usr […]
>>
>>
>>
>> The code compiles and runs fine, but running clang-tidy (using the
>> same compiler flags) chokes on the SSE built-ins in GCC’s headers:
>>
>>
>> /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/xmmintrin.h:54:3:
>> error: argument to '__builtin_prefetch' must be a constant integer
>> [clang-diagnostic-error]
>>
>>   __builtin_prefetch (__P, (__I & 0x4) >> 2, __I & 0x3);
>>
>>   ^
>>
>>
>> /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/xmmintrin.h:130:19:
>> error: use of undeclared identifier '__builtin_ia32_addss'
>> [clang-diagnostic-error]
>>
>>   return (__m128) __builtin_ia32_addss ((__v4sf)__A, (__v4sf)__B);
>>
>>                   ^
>>
>>
>> /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/xmmintrin.h:136:19:
>> error: use of undeclared identifier '__builtin_ia32_subss'
>> [clang-diagnostic-error]
>>
>>   return (__m128) __builtin_ia32_subss ((__v4sf)__A, (__v4sf)__B);
>>
>>
>>
>> [more errors following…]
>>
>>
>>
>> This happens as soon as I include <xmmintrin.h> (e.g. indirectly via
>> Boost.UUID).
>>
>>
>>
>> I’m wondering that the clang compiler accepts the code, while
>> clang-tidy doesn’t.
>>
>> Any ideas how to fix this? My current workaround is to disable
>> SSE-support in Boost.UUID via macro for clang-tidy, but the problem
>> will re-appear as soon as some other lib tries to use SSE instructions.
>>
>>
>>
>> Cheers,
>>
>> Daniel Evers
>>
>>
>>
>>
>> ________________________________
>>
>> Utimaco TS GmbH
>> Germanusstr. 4, D.52080 Aachen, Germany, Tel: +49-241-1696-0,
>> www.utimaco.com
>> Seat: Aachen – Registergericht Aachen HRB 18923 VAT ID No.: DE 815
>> 496 507
>> Managementboard: Malte Pollmann (Chairman) CEO, Dr. Frank J.
>> Nellissen CFO
>>
>> This communication is confidential. We only send and receive email on
>> the basis of the terms set out at
>> https://www.utimaco.com/en/e-mail-disclaimer/
>>
>> _______________________________________________
>> cfe-dev mailing list
>> [hidden email]
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>



--
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++ The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds "People disagree with me. I just ignore them." -- Linus Torvalds


________________________________

Utimaco TS GmbH
Germanusstr. 4, D.52080 Aachen, Germany, Tel: +49-241-1696-0, www.utimaco.com
Seat: Aachen – Registergericht Aachen HRB 18923
VAT ID No.: DE 815 496 507
Managementboard: Malte Pollmann (Chairman) CEO, Dr. Frank J. Nellissen CFO

This communication is confidential. We only send and receive email on the basis of the terms set out at https://www.utimaco.com/en/e-mail-disclaimer/
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang-tidy & SSE with GCC toolchain

Jon Chesterfield via cfe-dev
On Fri, Jan 26, 2018 at 10:36 AM, Daniel Evers via cfe-dev
<[hidden email]> wrote:
> Hi,
>
> Thanks for the tip. I checked the output and clang++ uses its own includes instead of the GCC headers.
> Does the compiler add some pre-defined include paths that the clang-based tools don't have by default?
>
> Clang-tidy at least doesn't complain about -gcc-toolchain ;-) But I'm not sure if it's relevant here.

There used to (not sure if it's still there) a special relative lookup
for the builtins, something like
$dirname(driver-binary)/../lib/clang-6.0/include. So if your
clang-tidy is not in /usr/bin, it might not find the builtins.

- Kim
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang-tidy & SSE with GCC toolchain

Jon Chesterfield via cfe-dev
Hi @all,

Thanks again for all help - it turned out the problem was home-grown after all :(
Somewhere in the script to generate the compilation database, the GCC include were explicitly added. This brought in the problems. (seems like we needed this for an older version were clang was installed in a different directory than clang-tidy)

I fixed it to pass the Clang parameters as-is and all problems were gone... Same flags for clang-tidy and clang++ and it works as expected.

Sorry & thanks again!
Daniel

-----Original Message-----
From: Kim Gräsman [mailto:[hidden email]]
Sent: Freitag, 26. Januar 2018 11:12
To: Daniel Evers <[hidden email]>
Cc: Csaba Raduly <[hidden email]>; Craig Topper <[hidden email]>; [hidden email]
Subject: Re: [cfe-dev] clang-tidy & SSE with GCC toolchain

On Fri, Jan 26, 2018 at 10:36 AM, Daniel Evers via cfe-dev <[hidden email]> wrote:
> Hi,
>
> Thanks for the tip. I checked the output and clang++ uses its own includes instead of the GCC headers.
> Does the compiler add some pre-defined include paths that the clang-based tools don't have by default?
>
> Clang-tidy at least doesn't complain about -gcc-toolchain ;-) But I'm not sure if it's relevant here.

There used to (not sure if it's still there) a special relative lookup for the builtins, something like $dirname(driver-binary)/../lib/clang-6.0/include. So if your clang-tidy is not in /usr/bin, it might not find the builtins.

- Kim


________________________________

Utimaco TS GmbH
Germanusstr. 4, D.52080 Aachen, Germany, Tel: +49-241-1696-0, www.utimaco.com
Seat: Aachen – Registergericht Aachen HRB 18923
VAT ID No.: DE 815 496 507
Managementboard: Malte Pollmann (Chairman) CEO, Dr. Frank J. Nellissen CFO

This communication is confidential. We only send and receive email on the basis of the terms set out at https://www.utimaco.com/en/e-mail-disclaimer/
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev