Bug 93454 - Can't build with LLVM/clang 3.7.0 - SSSE3 instruction set not enabled
Summary: Can't build with LLVM/clang 3.7.0 - SSSE3 instruction set not enabled
Status: RESOLVED NOTOURBUG
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/nouveau (show other bugs)
Version: 11.0
Hardware: x86-64 (AMD64) Linux (All)
: medium major
Assignee: Nouveau Project
QA Contact: Nouveau Project
URL: https://llvm.org/bugs/show_bug.cgi?id...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-20 01:49 UTC by Tomasz Paweł Gajc
Modified: 2015-12-23 10:42 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Tomasz Paweł Gajc 2015-12-20 01:49:10 UTC
System is OpenMandriva Cooker running LLVM/clang 3.7.0 as default compiler.

When i build mesa i got this error:

Makefile:1205: recipe for target 'nv50/nv84_video_vp.lo' failed
make[3]: Leaving directory '/builddir/build/BUILD/mesa-11.0.7/src/gallium/drivers/nouveau'
In file included from nv50/nv84_video_vp.c:25:
In file included from ../../../../src/gallium/auxiliary/util/u_sse.h:140:
/usr/bin/../lib64/clang/3.7.0/include/tmmintrin.h:28:2: error: "SSSE3 instruction set not enabled"
#error "SSSE3 instruction set not enabled"
 ^
1 error generated.
make[3]: *** [nv50/nv84_video_vp.lo] Error 1
make[3]: *** Waiting for unfinished jobs....

Adding -mssse3 to CFLAGS will not work for all hardware.
Comment 1 Ilia Mirkin 2015-12-20 01:54:14 UTC
Hmmm... this comes from

#if defined(PIPE_ARCH_SSSE3)

#include <tmmintrin.h>

Which in turn comes from, hilariously,

#if defined(PIPE_CC_GCC) && (__GNUC__ * 100 + __GNUC_MINOR__) < 409 && !defined(__SSSE3__)
/* #warning SSE3 support requires -msse3 compiler options before GCC 4.9 */
#else
#define PIPE_ARCH_SSSE3
#endif

I'm guessing that was meant to be

#if defined(PIPE_CC_GCC) && (__GNUC__ * 100 + __GNUC_MINOR__) < 409 || !defined(__SSSE3__)
Comment 2 Ilia Mirkin 2015-12-20 01:56:27 UTC
Hmmm... this comes from

#if defined(PIPE_ARCH_SSSE3)

#include <tmmintrin.h>

Which in turn comes from, hilariously,

#if defined(PIPE_CC_GCC) && (__GNUC__ * 100 + __GNUC_MINOR__) < 409 && !defined(__SSSE3__)
/* #warning SSE3 support requires -msse3 compiler options before GCC 4.9 */
#else
#define PIPE_ARCH_SSSE3
#endif

I'm guessing that was meant to be

#if defined(PIPE_CC_GCC) && (__GNUC__ * 100 + __GNUC_MINOR__) < 409 || !defined(__SSSE3__)
Comment 3 Tomasz Paweł Gajc 2015-12-20 02:14:59 UTC
Let me try that in src/gallium/include/pipe/p_config.h
Comment 4 Ilia Mirkin 2015-12-20 03:03:10 UTC
This logic was last altered in the change below... My copy of clang 3.5 purports to be gcc 4.2.1. What does clang 3.7 report?

clang -E -dM - < /dev/null | grep GNUC

commit eb643db30e1bdf5171d0a012674016c317925b6e
Author: Jose Fonseca <jfonseca@vmware.com>
Date:   Sun Aug 9 11:21:03 2015 +0100

    gallium: GCC 4.9 allows to include tmmintrin.h without -msse3.
    
    Fixes build with MinGW x86_64 build with GCC 4.9, due to conflicting
    definition _mm_shuffle_epi8 of u_sse.h and system headers.
    
    Trivial.
Comment 5 Tomasz Paweł Gajc 2015-12-20 03:06:28 UTC
(In reply to Ilia Mirkin from comment #4)

> clang -E -dM - < /dev/null | grep GNUC

#define __GNUC_MINOR__ 9
#define __GNUC_PATCHLEVEL__ 1
#define __GNUC_STDC_INLINE__ 1
#define __GNUC__4
Comment 6 Jose Fonseca 2015-12-20 10:37:50 UTC
The issue is simple:

- GCC used to require -msse3 in order to include tmmintrin.h 
- MSVC/ICC does not
- GCC 4.9 finally eliminated that awkward requirement -- it's now possible to use SSE3 instrinsics without giving GCC carte blanch to emit SSSE3 whenever it wants

- it appears Clang claims to be GCC 4.9 but does not in fact support this.


We can workaround by adding   

diff --git a/src/gallium/include/pipe/p_config.h b/src/gallium/include/pipe/p_config.h
index 0b570c7..7d5d7d4 100644
--- a/src/gallium/include/pipe/p_config.h
+++ b/src/gallium/include/pipe/p_config.h
@@ -96,7 +96,7 @@
 #else
 #define PIPE_ARCH_SSE
 #endif
-#if defined(PIPE_CC_GCC) && (__GNUC__ * 100 + __GNUC_MINOR__) < 409 && !defined(__SSSE3__)
+#if defined(PIPE_CC_GCC) && ((__GNUC__ * 100 + __GNUC_MINOR__) < 409 || defined(__clang__)) && !defined(__SSSE3__)
 /* #warning SSE3 support requires -msse3 compiler options before GCC 4.9 */
 #else
 #define PIPE_ARCH_SSSE3


But this is above all a bug in Clang 3.7.  If that strive/claim to be GCC 4.9 then they should handle this too.
Comment 7 Tomasz Paweł Gajc 2015-12-20 10:58:15 UTC
Hi, thanks for the workaround
I found this bug report https://llvm.org/bugs/show_bug.cgi?id=24990 and i was paring commits for llvm and clang and i did not found anything that would corresponds to above bug.
Comment 8 Jose Fonseca 2015-12-23 10:42:43 UTC
(In reply to Tomasz Paweł Gajc from comment #7)
> Hi, thanks for the workaround
> I found this bug report https://llvm.org/bugs/show_bug.cgi?id=24990 and i
> was paring commits for llvm and clang and i did not found anything that
> would corresponds to above bug.

It looks like they had fixed this already before the bug report.

From the git history, the fix is 

  https://github.com/llvm-mirror/clang/commit/41885d36e85ead75a1d18ef7d2f43663f90ed67e

Not sure what clang version got it in the end.

But given this has already been fixed in Clang, I think we shouldn't fix it in Mesa, otherwise we'll need complex logic to detect exactly which clang versions support or not this.

OpenMandriva Cooker made the decision to use LLVM/clang 3.7.0 as default compiler, so they should crossport any fixes necessary to keep light on.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.