[Mesa-dev] [PATCH] i965: Fix union usage for GCC <= 4.6.

Jonathan Gray jsg at jsg.id.au
Fri Dec 5 19:46:24 PST 2014


On Fri, Dec 05, 2014 at 06:56:27PM -0800, Matt Turner wrote:
> On Fri, Dec 5, 2014 at 6:18 PM, Vinson Lee <vlee at freedesktop.org> wrote:
> > This patch fixes this build error with GCC <= 4.6.
> >
> >   CXX    test_vf_float_conversions.o
> > test_vf_float_conversions.cpp: In function ???unsigned int f2u(float)???:
> > test_vf_float_conversions.cpp:63:20: error: expected primary-expression before ???.??? token
> >
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86939
> > Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> > ---
> >  .../drivers/dri/i965/test_vf_float_conversions.cpp |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp b/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp
> > index 2ea36fd..6a8bcea 100644
> > --- a/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp
> > +++ b/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp
> > @@ -60,7 +60,8 @@ union fu {
> >  static unsigned
> >  f2u(float f)
> >  {
> > -   union fu fu = { .f = f };
> > +   union fu fu;
> > +   fu.f = f;
> >     return fu.u;
> >  }
> 
> I'm surprised that this is necessary. Can someone point me to some
> documentation that says that designated initializers for unions only
> were added with gcc-4.7?
> 
> Jonathan, can you confirm that this is required? I suppose you didn't
> notice because you didn't build with 'make check'?

No I don't normally run make check, it seems it errors out before then
as it assumes /bin/bash is present

/bin/sh: ./es1api/ABI-check: No such file or directory
FAIL: es1api/ABI-check
/bin/sh: ./es2api/ABI-check: No such file or directory
FAIL: es2api/ABI-check

glsl_test does not link due to missing pthread symbols

And there looks to be a large amount of other scripts that want bash, ugh.

Running gmake check from src/mesa/drivers/dri instead of the top level gives:

test_vf_float_conversions.cpp: In function 'unsigned int f2u(float)':
test_vf_float_conversions.cpp:63: error: expected primary-expression before 'union'
test_vf_float_conversions.cpp:63: error: expected `)' before 'union'
Makefile:1013: recipe for target 'test_vf_float_conversions.o' failed

With the below diff from the top level I get as far as
====== Testing optimization passes ======
Testing ./lower_jumps/lower_returns_main_true.opt_test...FAIL
Traceback (most recent call last):
  File "/usr/users/jsg/src/mesa/src/glsl/tests/compare_ir", line 43, in <module>
    ir2 = sort_decls(parse_sexp(f.read()))
  File "/usr/users/jsg/src/mesa/src/glsl/tests/sexps.py", line 66, in parse_sexp
    raise Exception('Multiple sexps')
Exception: Multiple sexps
Testing ./lower_jumps/lower_returns_main_false.opt_test...FAIL
Traceback (most recent call last):
  File "/usr/users/jsg/src/mesa/src/glsl/tests/compare_ir", line 43, in <module>
    ir2 = sort_decls(parse_sexp(f.read()))
  File "/usr/users/jsg/src/mesa/src/glsl/tests/sexps.py", line 66, in parse_sexp
    raise Exception('Multiple sexps')
Exception: Multiple sexps

(and a bunch more of these)

Along with the ABI-check scripts it seems at the very least
all occurances of "#!/bin/bash" should be changed to
"#!/usr/bin/env bash" if they are actually bash specific.

In other words these:
bin/bugzilla_mesa.sh:#!/bin/bash
bin/shortlog_mesa.sh:#!/bin/bash
src/egl/wayland/wayland-egl/wayland-egl-symbols-check:#!/bin/bash
src/gallium/targets/gbm/gallium-gbm-symbols-check:#!/bin/bash
src/gallium/tools/addr2line.sh:#!/bin/bash
src/gallium/tools/trace/tracediff.sh:#!/bin/bash
src/gbm/gbm-symbols-check:#!/bin/basH

diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
index 0ccc81d..66986eb 100644
--- a/src/glsl/Makefile.am
+++ b/src/glsl/Makefile.am
@@ -137,7 +137,8 @@ glsl_test_SOURCES = \
 	test.cpp \
 	test_optpass.cpp
 
-glsl_test_LDADD = libglsl.la
+glsl_test_LDADD = libglsl.la				\
+	$(PTHREAD_LIBS)
 
 # We write our own rules for yacc and lex below. We'd rather use automake,
 # but automake makes it especially difficult for a number of reasons:
diff --git a/src/glsl/tests/optimization-test b/src/glsl/tests/optimization-test
index 26a51be..19e3ce5 100755
--- a/src/glsl/tests/optimization-test
+++ b/src/glsl/tests/optimization-test
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 
 if [ ! -z "$srcdir" ]; then
    compare_ir=`pwd`/tests/compare_ir
diff --git a/src/mapi/es1api/ABI-check b/src/mapi/es1api/ABI-check
index 44654cd..223658b 100755
--- a/src/mapi/es1api/ABI-check
+++ b/src/mapi/es1api/ABI-check
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 # Print defined gl.* functions not in GL ES 1.1 or in
 # (FIXME, none of these should be part of the ABI)
diff --git a/src/mapi/es2api/ABI-check b/src/mapi/es2api/ABI-check
index abbb55c..5c9e826 100755
--- a/src/mapi/es2api/ABI-check
+++ b/src/mapi/es2api/ABI-check
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 # Print defined gl.* functions not in GL ES 3.0 or in
 # (FIXME, none of these should be part of the ABI)


More information about the mesa-dev mailing list