Merge branch 'mesa_7_5_branch' into mesa_7_6_branch
[mesa.git] / scons / gallium.py
index aed813f02795d5f6b4e0be60b0a492ec105cb770..bf6172b4d777d226a0c2f10385b79ea0fc531914 100644 (file)
@@ -38,6 +38,8 @@ import SCons.Action
 import SCons.Builder
 import SCons.Scanner
 
+import fixes
+
 
 def quietCommandLines(env):
     # Quiet command lines
@@ -325,8 +327,10 @@ def generate(env):
     if gcc:
         if debug:
             ccflags += ['-O0', '-g3']
-        elif env['toolchain'] == 'crossmingw':
-            ccflags += ['-O0', '-g3'] # mingw 4.2.1 optimizer is broken
+        elif env['CCVERSION'].startswith('4.2.'):
+            # gcc 4.2.x optimizer is broken
+            print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations"
+            ccflags += ['-O0', '-g3']
         else:
             ccflags += ['-O3', '-g3']
         if env['profile']:
@@ -449,11 +453,17 @@ def generate(env):
 
     # Linker options
     linkflags = []
+    shlinkflags = []
     if gcc:
         if env['machine'] == 'x86':
             linkflags += ['-m32']
         if env['machine'] == 'x86_64':
             linkflags += ['-m64']
+        shlinkflags += [
+            '-Wl,-Bsymbolic',
+        ]
+        # Handle circular dependencies in the libraries
+        env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group'
     if platform == 'windows' and msvc:
         # See also:
         # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
@@ -501,6 +511,7 @@ def generate(env):
             '/entry:_DllMainCRTStartup',
         ]
     env.Append(LINKFLAGS = linkflags)
+    env.Append(SHLINKFLAGS = shlinkflags)
 
     # Default libs
     env.Append(LIBS = [])