From 72ad039d19e033baff774b184ece9ffbfef4a2ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Sun, 28 Jun 2009 10:54:23 +0100 Subject: scons: Use -Bsymbolic linker option. This prevents the error relocation R_X86_64_PC32 against symbol `_gl_DispatchTSD' can not be used when making a shared object; recompile with -fPIC when building on x86_64 architecture. --- scons/gallium.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'scons/gallium.py') diff --git a/scons/gallium.py b/scons/gallium.py index ee45af50c2..b69f2f2a75 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -448,11 +448,15 @@ 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', + ] if platform == 'windows' and msvc: # See also: # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx @@ -500,6 +504,7 @@ def generate(env): '/entry:_DllMainCRTStartup', ] env.Append(LINKFLAGS = linkflags) + env.Append(SHLINKFLAGS = shlinkflags) # Default libs env.Append(LIBS = []) -- cgit v1.2.3 From bb8f3090ba37aa3f24943fdb43c4120776289658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Sun, 28 Jun 2009 11:12:22 +0100 Subject: scons: Disable optimizations only for gcc-4.2 gcc-4.2's optimizer has a strange bug where it looses code from inner loops in certain situations. For example, if the appearently innocent looking code below is compiled with gcc-4.2 -S -O1, the inner loop's code is missing from the outputed assembly. struct Size { unsigned width; }; struct Command { unsigned length; struct Size sizes[32]; }; extern void emit_command(void *command, unsigned length); void create_surface( struct Size size, unsigned faces, unsigned levels) { struct Command cmd; unsigned face; unsigned level; cmd.length = faces*levels*sizeof(cmd.sizes[0]); for(face = 0; face < faces; ++face) { for(level = 0; level < levels; ++level) { cmd.sizes[face*levels + level] = size; // This should generate a shrl statement, but the whole for body // disappears in gcc-4.2 -O1/-O2/-O3! size.width >>= 1; } } emit(&cmd, sizeof cmd.length + cmd.length); } Note that this is not specific to MinGW's gcc-4.2 crosscompiler (the version typically found in debian/ubuntu's mingw32 packages). gcc-4.2 on Linux also displays the same error. gcc-4.3 and above gets this correctly though. Updated MinGW debian packages with gcc-4.3 are available from http://people.freedesktop.org/~jrfonseca/debian/pool/main/m/ --- scons/gallium.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scons/gallium.py') diff --git a/scons/gallium.py b/scons/gallium.py index b69f2f2a75..217478bd50 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -324,8 +324,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']: -- cgit v1.2.3