scons: Fix MSYS2 Mingw-w64 build.
authorpal1000 <liviuprodea@yahoo.com>
Fri, 1 Mar 2019 10:30:15 +0000 (12:30 +0200)
committerJose Fonseca <jfonseca@vmware.com>
Sun, 29 Sep 2019 09:57:16 +0000 (10:57 +0100)
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
This patch is based on https://github.com/msys2/MINGW-packages/blob/28e3f85e09b6947ea80036c49f6c38f1394f93ca/mingw-w64-mesa/link-ole32.patch but with tweaks to avoid MSVC build break when applied.

v2: Create Mingw platform alias pointing to windows host platform define to avoid spurious crosscompilation;

v3: Fix obviously wrong compiler flags for swr driver;

v4: Update original patch URL because it has been relocated;

v5: Don't bother patching autools stuff as it's not used by MSYS2 Mingw-w64 build and it's days are numbered anyway;

v6: After Mingw posix flag fix in 295851eb things are far simpler as we don't need more linking of uuid, ole32, version and shell32 than what is already in place.

scons/gallium.py
scons/llvm.py
src/gallium/drivers/swr/SConscript

index 9381f804a31d39c70e4f45f976a6f20f4054e056..b216304170f5ebe8c6a175bb36efbe6f18632939 100755 (executable)
@@ -237,6 +237,9 @@ def generate(env):
     hosthost_platform = host_platform.system().lower()
     if hosthost_platform.startswith('cygwin'):
         hosthost_platform = 'cygwin'
+    # Avoid spurious crosscompilation in MSYS2 environment.
+    if hosthost_platform.startswith('mingw'):
+        hosthost_platform = 'windows'
     host_machine = os.environ.get('PROCESSOR_ARCHITEW6432', os.environ.get('PROCESSOR_ARCHITECTURE', host_platform.machine()))
     host_machine = {
         'x86': 'x86',
index 33505f794477be470fe7ebc97c7815aa9faada30..fc128ab1e680fa39566f69f7aad417bb567c7533 100644 (file)
@@ -30,6 +30,7 @@ Tool-specific initialization for LLVM
 import os
 import os.path
 import re
+import platform as host_platform
 import sys
 import distutils.version
 
@@ -192,6 +193,12 @@ def generate(env):
             'uuid',
         ])
 
+        # Mingw-w64 zlib is required when building with LLVM support in MSYS2 environment
+        if host_platform.system().lower().startswith('mingw'):
+            env.Append(LIBS = [
+                 'z',
+            ])
+
         if env['msvc']:
             # Some of the LLVM C headers use the inline keyword without
             # defining it.
index 61432a0c342b1c28f30392aa98fd91e0e81dddad..1230cbb5b77e4e47c5916eac104a45f762dcdff7 100644 (file)
@@ -214,7 +214,7 @@ env.Prepend(CPPPATH = [
 envavx = env.Clone()
 
 envavx.Append(CPPDEFINES = ['KNOB_ARCH=KNOB_ARCH_AVX'])
-if env['platform'] == 'windows':
+if env['msvc']:
     envavx.Append(CCFLAGS = ['/arch:AVX'])
 else:
     envavx.Append(CCFLAGS = ['-mavx'])
@@ -230,7 +230,7 @@ env.Alias('swrAVX', swrAVX)
 envavx2 = env.Clone()
 
 envavx2.Append(CPPDEFINES = ['KNOB_ARCH=KNOB_ARCH_AVX2'])
-if env['platform'] == 'windows':
+if env['msvc']:
     envavx2.Append(CCFLAGS = ['/arch:AVX2'])
 else:
     envavx2.Append(CCFLAGS = ['-mavx2', '-mfma', '-mbmi2', '-mf16c'])