glsl: work around MinGW 7.x compiler bug
authorBrian Paul <brianp@vmware.com>
Wed, 1 May 2019 20:22:57 +0000 (14:22 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 2 May 2019 02:06:54 +0000 (20:06 -0600)
I'm not sure what triggered this, but building with
scons platform=windows toolchain=crossmingw machine=x86 build=profile
with MinGW g++ 7.3 or 7.4 causes an internal compiler error.

We can work around it by forcing -O1 optimization.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Neha Bhende <bhenden@vmware.com>
src/compiler/glsl/builtin_variables.cpp

index 17ee80cd419f200a389ffefcd7a4604a25e3eb84..1b9963a530a344128597fef4b3ddad1da88cbe98 100644 (file)
  * DEALINGS IN THE SOFTWARE.
  */
 
+
+/**
+ * Building this file with MinGW g++ 7.3 or 7.4 with:
+ *   scons platform=windows toolchain=crossmingw machine=x86 build=profile
+ * triggers an internal compiler error.
+ * Overriding the optimization level to -O1 works around the issue.
+ * MinGW 5.3.1 does not seem to have the bug, neither does 8.3.  So for now
+ * we're simply testing for version 7.x here.
+ */
+#if defined(__MINGW32__) && __GNUC__ == 7
+#warning "disabling optimizations for this file to work around compiler bug in MiGW gcc 7.x"
+#pragma GCC optimize("O1")
+#endif
+
+
 #include "ir.h"
 #include "ir_builder.h"
 #include "linker.h"