Merge branch 'gallium-polygon-stipple'
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_misc.cpp
index 843a14a500c3f89264a162246c066e2732c197c5..85fabc574b22be88ce0303ef860e6e94e7997724 100644 (file)
@@ -71,6 +71,23 @@ lp_set_target_options(void)
 #if HAVE_LLVM >= 0x0207
    llvm::JITEmitDebugInfo = true;
 #endif
+#endif
+
+   /*
+    * LLVM revision 123367 switched the default stack alignment to 16 bytes on
+    * Linux (and several other Unices in later revisions), to match recent gcc
+    * versions.
+    *
+    * However our drivers can be loaded by old binary applications, still
+    * maintaining a 4 bytes stack alignment.  Therefore we must tell LLVM here
+    * to only assume a 4 bytes alignment for backwards compatibility.
+    */
+#if defined(PIPE_ARCH_X86)
+#if HAVE_LLVM >= 0x0300
+   llvm::StackAlignmentOverride = 4;
+#else
+   llvm::StackAlignment = 4;
+#endif
 #endif
 
 #if defined(DEBUG) || defined(PROFILE)
@@ -93,13 +110,23 @@ lp_set_target_options(void)
     * See also:
     * - http://llvm.org/bugs/show_bug.cgi?id=3287
     * - http://l4.me.uk/post/2009/06/07/llvm-wrinkle-3-configuration-what-configuration/
+    *
+    * The -disable-mmx global option can be specified only once  since we
+    * dynamically link against LLVM it will reside in a separate shared object,
+    * which may or not be delete when this shared object is, so we use the
+    * llvm::DisablePrettyStackTrace variable (which we set below and should
+    * reside in the same shared library) to determine whether the -disable-mmx
+    * option has been set or not.
+    *
+    * Thankfully this ugly hack is not necessary on LLVM 2.9 onwards.
     */
-   static boolean first = TRUE;
-   if (first) {
+   if (!llvm::DisablePrettyStackTrace) {
+      static boolean first = TRUE;
       static const char* options[] = {
          "prog",
          "-disable-mmx"
       };
+      assert(first);
       llvm::cl::ParseCommandLineOptions(2, const_cast<char**>(options));
       first = FALSE;
    }