[Bug 78665] New: macros in builtin_functions.cpp make invalid assumptions about M_PI definitions

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue May 13 08:03:23 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=78665

          Priority: medium
            Bug ID: 78665
          Assignee: idr at freedesktop.org
           Summary: macros in builtin_functions.cpp make invalid
                    assumptions about M_PI definitions
        QA Contact: intel-3d-bugs at lists.freedesktop.org
          Severity: normal
    Classification: Unclassified
                OS: OpenBSD
          Reporter: jsg at openbsd.org
          Hardware: Other
            Status: NEW
           Version: git
         Component: glsl-compiler
           Product: Mesa

After the following commit:

commit d877c643bea7a40e37d13d8a967c06fd006d1622
Author: Matt Turner <mattst88 at gmail.com>
Date:   Sat Apr 5 22:03:04 2014 -0700

    glsl: Use M_PI_* macros.

    Notice our multiple values for M_PI_2, which rounded ...32 up to
    ...4 and ...5.

Mesa no longer builds on OpenBSD.  Apparently the M_PI macros in glibc are not
defined with any brackets/casts like they are in OpenBSD (and perhaps
elsewhere?).

>From the OpenBSD math.h:

#define M_PI            ((double)3.14159265358979323846) /* pi */
#define M_PI_2          ((double)1.57079632679489661923) /* pi/2 */
#define M_PI_4          ((double)0.78539816339744830962) /* pi/4 */

libtool: compile:  g++ -DPACKAGE_NAME=\"Mesa\" -DPACKAGE_TARNAME=\"mesa\"
-DPACKAGE_VERSION=\"10.3.0-devel\" "-DPACKAGE_STRING=\"Mesa 10.3.0-devel\""
"-DPACKAGE_BUGREPORT=\"https://bugs.freedesktop.org/enter_bug.cgi?pro
duct=Mesa\"" -DPACKAGE_URL=\"\" -DPACKAGE=\"mesa\" -DVERSION=\"10.3.0-devel\"
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INT
TYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1
-DLT_OBJDIR=\".libs/\" -DYYTEXT_POINTER=1 -DHAVE_DLADDR=1
-DHAVE_CLOCK_GETTIME=1 -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -I.
-I../../include -I../../
src/mapi -I../../src/mesa/ -I../../src/glsl/glcpp -I../../src/gtest/include
-DDEBUG -DUSE_X86_64_ASM -DHAVE_DLOPEN -DHAVE_POSIX_MEMALIGN -DHAVE_LIBDRM
-DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING -DHAVE_PTHREAD -DUSE
_EXTERNAL_DXTN_LIB=1 -DHAVE_ALIAS -DHAVE_MINCORE -DHAVE_LLVM=0x0305
-DLLVM_VERSION_PATCH=0 -I/usr/local/include -I/usr/local/include/libelf
-fvisibility=hidden -g -O2 -Wall -fno-strict-aliasing -fno-builtin-memcmp -g -O
0 -MT builtin_functions.lo -MD -MP -MF .deps/builtin_functions.Tpo -c
../../src/glsl/builtin_functions.cpp  -fPIC -DPIC -o .libs/builtin_functions.o
../../src/glsl/builtin_functions.cpp:2547:1: error: pasting ")" and "f" does
not give a valid preprocessing token
../../src/glsl/builtin_functions.cpp:2549:1: error: pasting ")" and "f" does
not give a valid preprocessing token
../../src/glsl/builtin_functions.cpp:2551:1: error: pasting ")" and "f" does
not give a valid preprocessing token
../../src/glsl/builtin_functions.cpp:2595:1: error: pasting ")" and "f" does
not give a valid preprocessing token
../../src/glsl/builtin_functions.cpp:2632:1: error: pasting ")" and "f" does
not give a valid preprocessing token
../../src/glsl/builtin_functions.cpp:2633:1: error: pasting ")" and "f" does
not give a valid preprocessing token
../../src/glsl/builtin_functions.cpp:2638:1: error: pasting ")" and "f" does
not give a valid preprocessing token
../../src/glsl/builtin_functions.cpp: In member function
'ir_expression*<unnamed>::builtin_builder::asin_expr(ir_variable*)':
../../src/glsl/builtin_functions.cpp:2547: error: expected `)' before 'f'
../../src/glsl/builtin_functions.cpp:2547: error: call of overloaded
'imm(double)' is ambiguous
../../src/glsl/builtin_functions.cpp:2388: note: candidates are:
ir_constant*<unnamed>::builtin_builder::imm(float, unsigned int)
../../src/glsl/builtin_functions.cpp:2394: note:                
ir_constant*<unnamed>::builtin_builder::imm(int, unsigned int)
../../src/glsl/builtin_functions.cpp:2400: note:                
ir_constant*<unnamed>::builtin_builder::imm(unsigned int, unsigned int)
../../src/glsl/builtin_functions.cpp:2549: error: expected `)' before 'f'
../../src/glsl/builtin_functions.cpp:2549: error: call of overloaded
'imm(double)' is ambiguous
../../src/glsl/builtin_functions.cpp:2388: note: candidates are:
ir_constant*<unnamed>::builtin_builder::imm(float, unsigned int)
../../src/glsl/builtin_functions.cpp:2394: note:                
ir_constant*<unnamed>::builtin_builder::imm(int, unsigned int)
../../src/glsl/builtin_functions.cpp:2400: note:                
ir_constant*<unnamed>::builtin_builder::imm(unsigned int, unsigned int)
../../src/glsl/builtin_functions.cpp:2551: error: expected `)' before 'f'
../../src/glsl/builtin_functions.cpp:2551: error: call of overloaded
'imm(double)' is ambiguous
../../src/glsl/builtin_functions.cpp:2388: note: candidates are:
ir_constant*<unnamed>::builtin_builder::imm(float, unsigned int)
../../src/glsl/builtin_functions.cpp:2394: note:                
ir_constant*<unnamed>::builtin_builder::imm(int, unsigned int)
../../src/glsl/builtin_functions.cpp:2400: note:                
ir_constant*<unnamed>::builtin_builder::imm(unsigned int, unsigned int)
../../src/glsl/builtin_functions.cpp: In member function
'ir_function_signature*<unnamed>::builtin_builder::_acos(const glsl_type*)':
../../src/glsl/builtin_functions.cpp:2595: error: expected `)' before 'f'
../../src/glsl/builtin_functions.cpp:2595: error: call of overloaded
'imm(double)' is ambiguous
../../src/glsl/builtin_functions.cpp:2388: note: candidates are:
ir_constant*<unnamed>::builtin_builder::imm(float, unsigned int)
../../src/glsl/builtin_functions.cpp:2394: note:                
ir_constant*<unnamed>::builtin_builder::imm(int, unsigned int)
../../src/glsl/builtin_functions.cpp:2400: note:                
ir_constant*<unnamed>::builtin_builder::imm(unsigned int, unsigned int)
../../src/glsl/builtin_functions.cpp: In member function
'ir_function_signature*<unnamed>::builtin_builder::_atan2(const glsl_type*)':
../../src/glsl/builtin_functions.cpp:2632: error: expected `)' before 'f'
../../src/glsl/builtin_functions.cpp:2632: error: call of overloaded
'imm(double)' is ambiguous
../../src/glsl/builtin_functions.cpp:2388: note: candidates are:
ir_constant*<unnamed>::builtin_builder::imm(float, unsigned int)
../../src/glsl/builtin_functions.cpp:2394: note:                
ir_constant*<unnamed>::builtin_builder::imm(int, unsigned int)
../../src/glsl/builtin_functions.cpp:2400: note:                
ir_constant*<unnamed>::builtin_builder::imm(unsigned int, unsigned int)
../../src/glsl/builtin_functions.cpp:2633: error: expected `)' before 'f'
../../src/glsl/builtin_functions.cpp:2633: error: call of overloaded
'imm(double)' is ambiguous
../../src/glsl/builtin_functions.cpp:2388: note: candidates are:
ir_constant*<unnamed>::builtin_builder::imm(float, unsigned int)
../../src/glsl/builtin_functions.cpp:2394: note:                
ir_constant*<unnamed>::builtin_builder::imm(int, unsigned int)
../../src/glsl/builtin_functions.cpp:2400: note:                
ir_constant*<unnamed>::builtin_builder::imm(unsigned int, unsigned int)
../../src/glsl/builtin_functions.cpp:2638: error: expected `)' before 'f'
../../src/glsl/builtin_functions.cpp:2638: error: call of overloaded
'imm(double)' is ambiguous
../../src/glsl/builtin_functions.cpp:2388: note: candidates are:
ir_constant*<unnamed>::builtin_builder::imm(float, unsigned int)
../../src/glsl/builtin_functions.cpp:2394: note:                
ir_constant*<unnamed>::builtin_builder::imm(int, unsigned int)
../../src/glsl/builtin_functions.cpp:2400: note:                
ir_constant*<unnamed>::builtin_builder::imm(unsigned int, unsigned int)
Makefile:1449: recipe for target 'builtin_functions.lo' failed

/bin/sh ../../libtool  --tag=CXX   --mode=compile /usr/local/bin/clang++
-DPACKAGE_NAME=\"Mesa\" -DPACKAGE_TARNAME=\"mesa\"
-DPACKAGE_VERSION=\"10.3.0-devel\" -DPACKAGE_STRING=\"Mesa\ 10.3.0-devel\"
-DPACKAGE_BUGREPORT=\"https://bugs.freedesktop.org/enter_bug.cgi\?product=Mesa\"
-DPACKAGE_URL=\"\" -DPACKAGE=\"mesa\" -DVERSION=\"10.3.0-devel\"
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\"
-DYYTEXT_POINTER=1 -DHAVE_DLADDR=1 -DHAVE_CLOCK_GETTIME=1
-DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -I.  -I../../include
-I../../src/mapi -I../../src/mesa/ -I../../src/glsl/glcpp
-I../../src/gtest/include -DDEBUG -DUSE_X86_64_ASM -DHAVE_DLOPEN
-DHAVE_POSIX_MEMALIGN -DHAVE_LIBDRM -DGLX_INDIRECT_RENDERING
-DGLX_DIRECT_RENDERING -DHAVE_PTHREAD -DUSE_EXTERNAL_DXTN_LIB=1 -DHAVE_ALIAS
-DHAVE_MINCORE -DHAVE_LLVM=0x0305 -DLLVM_VERSION_PATCH=0 -I/usr/local/include
-I/usr/local/include/libelf -fvisibility=hidden -g -O2 -Wall
-fno-strict-aliasing -fno-builtin-memcmp -g -O0  -MT builtin_functions.lo -MD
-MP -MF .deps/builtin_functions.Tpo -c -o builtin_functions.lo `test -f
'../../src/glsl/builtin_functions.cpp' || echo
'./'`../../src/glsl/builtin_functions.cpp
libtool: compile:  /usr/local/bin/clang++ -DPACKAGE_NAME=\"Mesa\"
-DPACKAGE_TARNAME=\"mesa\" -DPACKAGE_VERSION=\"10.3.0-devel\"
"-DPACKAGE_STRING=\"Mesa 10.3.0-devel\""
"-DPACKAGE_BUGREPORT=\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\""
-DPACKAGE_URL=\"\" -DPACKAGE=\"mesa\" -DVERSION=\"10.3.0-devel\"
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\"
-DYYTEXT_POINTER=1 -DHAVE_DLADDR=1 -DHAVE_CLOCK_GETTIME=1
-DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -I. -I../../include
-I../../src/mapi -I../../src/mesa/ -I../../src/glsl/glcpp
-I../../src/gtest/include -DDEBUG -DUSE_X86_64_ASM -DHAVE_DLOPEN
-DHAVE_POSIX_MEMALIGN -DHAVE_LIBDRM -DGLX_INDIRECT_RENDERING
-DGLX_DIRECT_RENDERING -DHAVE_PTHREAD -DUSE_EXTERNAL_DXTN_LIB=1 -DHAVE_ALIAS
-DHAVE_MINCORE -DHAVE_LLVM=0x0305 -DLLVM_VERSION_PATCH=0 -I/usr/local/include
-I/usr/local/include/libelf -fvisibility=hidden -g -O2 -Wall
-fno-strict-aliasing -fno-builtin-memcmp -g -O0 -MT builtin_functions.lo -MD
-MP -MF .deps/builtin_functions.Tpo -c ../../src/glsl/builtin_functions.cpp 
-fPIC -DPIC -o .libs/builtin_functions.o
../../src/glsl/builtin_functions.cpp:2547:23: error: pasting formed ')f', an
invalid preprocessing token
              sub(imm(M_PI_2f),
                      ^
../../src/glsl/builtin_functions.cpp:68:17: note: expanded from macro 'M_PI_2f'
#define M_PI_2f f(M_PI_2)
                ^
../../src/glsl/builtin_functions.cpp:65:14: note: expanded from macro 'f'
#define f(x) join(x)
             ^
../../src/glsl/builtin_functions.cpp:66:19: note: expanded from macro 'join'
#define join(x) x ## f
                  ^
../../src/glsl/builtin_functions.cpp:2547:23: error: expected ')'
../../src/glsl/builtin_functions.cpp:68:17: note: expanded from macro 'M_PI_2f'
#define M_PI_2f f(M_PI_2)
                ^
../../src/glsl/builtin_functions.cpp:65:14: note: expanded from macro 'f'
#define f(x) join(x)
             ^
../../src/glsl/builtin_functions.cpp:66:22: note: expanded from macro 'join'
#define join(x) x ## f
                     ^
../../src/glsl/builtin_functions.cpp:2547:22: note: to match this '('
              sub(imm(M_PI_2f),
                     ^
../../src/glsl/builtin_functions.cpp:2549:31: error: pasting formed ')f', an
invalid preprocessing token
                      add(imm(M_PI_2f),
                              ^
../../src/glsl/builtin_functions.cpp:68:17: note: expanded from macro 'M_PI_2f'
#define M_PI_2f f(M_PI_2)
                ^
../../src/glsl/builtin_functions.cpp:65:14: note: expanded from macro 'f'
#define f(x) join(x)
             ^
../../src/glsl/builtin_functions.cpp:66:19: note: expanded from macro 'join'
#define join(x) x ## f
                  ^
../../src/glsl/builtin_functions.cpp:2551:39: error: pasting formed ')f', an
invalid preprocessing token
                              add(imm(M_PI_4f - 1.0f),
                                      ^
../../src/glsl/builtin_functions.cpp:69:17: note: expanded from macro 'M_PI_4f'
#define M_PI_4f f(M_PI_4)
                ^
../../src/glsl/builtin_functions.cpp:65:14: note: expanded from macro 'f'
#define f(x) join(x)
             ^
../../src/glsl/builtin_functions.cpp:66:19: note: expanded from macro 'join'
#define join(x) x ## f
                  ^
../../src/glsl/builtin_functions.cpp:2595:26: error: pasting formed ')f', an
invalid preprocessing token
   body.emit(ret(sub(imm(M_PI_2f), asin_expr(x))));
                         ^
../../src/glsl/builtin_functions.cpp:68:17: note: expanded from macro 'M_PI_2f'
#define M_PI_2f f(M_PI_2)
                ^
../../src/glsl/builtin_functions.cpp:65:14: note: expanded from macro 'f'
#define f(x) join(x)
             ^
../../src/glsl/builtin_functions.cpp:66:19: note: expanded from macro 'join'
#define join(x) x ## f
                  ^
../../src/glsl/builtin_functions.cpp:2595:26: error: expected ')'
../../src/glsl/builtin_functions.cpp:68:17: note: expanded from macro 'M_PI_2f'
#define M_PI_2f f(M_PI_2)
                ^
../../src/glsl/builtin_functions.cpp:65:14: note: expanded from macro 'f'
#define f(x) join(x)
             ^
../../src/glsl/builtin_functions.cpp:66:22: note: expanded from macro 'join'
#define join(x) x ## f
                     ^
../../src/glsl/builtin_functions.cpp:2595:25: note: to match this '('
   body.emit(ret(sub(imm(M_PI_2f), asin_expr(x))));
                        ^
../../src/glsl/builtin_functions.cpp:2632:39: error: pasting formed ')f', an
invalid preprocessing token
                 assign(r, add(r, imm(M_PIf))),
                                      ^
../../src/glsl/builtin_functions.cpp:67:15: note: expanded from macro 'M_PIf'
#define M_PIf f(M_PI)
              ^
../../src/glsl/builtin_functions.cpp:65:14: note: expanded from macro 'f'
#define f(x) join(x)
             ^
../../src/glsl/builtin_functions.cpp:66:19: note: expanded from macro 'join'
#define join(x) x ## f
                  ^
../../src/glsl/builtin_functions.cpp:2632:39: error: expected ')'
../../src/glsl/builtin_functions.cpp:67:15: note: expanded from macro 'M_PIf'
#define M_PIf f(M_PI)
              ^
../../src/glsl/builtin_functions.cpp:65:14: note: expanded from macro 'f'
#define f(x) join(x)
             ^
../../src/glsl/builtin_functions.cpp:66:22: note: expanded from macro 'join'
#define join(x) x ## f
                     ^
../../src/glsl/builtin_functions.cpp:2632:38: note: to match this '('
                 assign(r, add(r, imm(M_PIf))),
                                     ^
../../src/glsl/builtin_functions.cpp:2633:39: error: pasting formed ')f', an
invalid preprocessing token
                 assign(r, sub(r, imm(M_PIf)))));
                                      ^
../../src/glsl/builtin_functions.cpp:67:15: note: expanded from macro 'M_PIf'
#define M_PIf f(M_PI)
              ^
../../src/glsl/builtin_functions.cpp:65:14: note: expanded from macro 'f'
#define f(x) join(x)
             ^
../../src/glsl/builtin_functions.cpp:66:19: note: expanded from macro 'join'
#define join(x) x ## f
                  ^
../../src/glsl/builtin_functions.cpp:2638:37: error: pasting formed ')f', an
invalid preprocessing token
         assign(r, mul(sign(y), imm(M_PI_2f))));
                                    ^
../../src/glsl/builtin_functions.cpp:68:17: note: expanded from macro 'M_PI_2f'
#define M_PI_2f f(M_PI_2)
                ^
../../src/glsl/builtin_functions.cpp:65:14: note: expanded from macro 'f'
#define f(x) join(x)
             ^
../../src/glsl/builtin_functions.cpp:66:19: note: expanded from macro 'join'
#define join(x) x ## f
                  ^
../../src/glsl/builtin_functions.cpp:2638:37: error: expected ')'
../../src/glsl/builtin_functions.cpp:68:17: note: expanded from macro 'M_PI_2f'
#define M_PI_2f f(M_PI_2)
                ^
../../src/glsl/builtin_functions.cpp:65:14: note: expanded from macro 'f'
#define f(x) join(x)
             ^
../../src/glsl/builtin_functions.cpp:66:22: note: expanded from macro 'join'
#define join(x) x ## f
                     ^
../../src/glsl/builtin_functions.cpp:2638:36: note: to match this '('
         assign(r, mul(sign(y), imm(M_PI_2f))));
                                   ^
11 errors generated.
Makefile:1449: recipe for target 'builtin_functions.lo' failed

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/intel-3d-bugs/attachments/20140513/f8c4557c/attachment-0001.html>


More information about the intel-3d-bugs mailing list