Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Cannot build glslang on Linux

  1. #1
    Intern Contributor IneQuation.pl's Avatar
    Join Date
    Aug 2008
    Location
    Gliwice, Poland
    Posts
    69

    Cannot build glslang on Linux

    Hey everyone,

    A freshly checked out glslang does not build on an up-to-date Debian testing amd64, spewing out a heap of errors in the Bison-generated cpp source:

    (posted log to pastebin because it was too long)
    http://pastebin.com/bpyjCrWS

    Bison version is 3.0.2, gcc is 4.8.2. Any tips?

    Leszek
    Last edited by IneQuation.pl; 02-25-2014 at 08:52 AM. Reason: forum butchers the formatting

  2. #2
    Junior Member Regular Contributor
    Join Date
    Aug 2009
    Location
    Poland
    Posts
    111
    This is change in bison 3 (removed some deprecated functionality), this hit mesa some time ago:

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



    I managed to get it co compile by patching two files:

    Code :
    [dk@sirius glslang]$ svn diff
    Index: glslang/MachineIndependent/Scan.cpp
    ===================================================================
    --- glslang/MachineIndependent/Scan.cpp    (revision 25716)
    +++ glslang/MachineIndependent/Scan.cpp    (working copy)
    @@ -42,8 +42,8 @@
     
     #include "../Include/Types.h"
     #include "SymbolTable.h"
    +#include "ParseHelper.h"
     #include "glslang_tab.cpp.h"
    -#include "ParseHelper.h"
     #include "ScanContext.h"
     #include "Scan.h"
     
    Index: glslang/MachineIndependent/glslang.y
    ===================================================================
    --- glslang/MachineIndependent/glslang.y    (revision 25716)
    +++ glslang/MachineIndependent/glslang.y    (working copy)
    @@ -97,15 +97,21 @@
     
     %{
     
    +
     #define YYPARSE_PARAM voidParseContext
     #define parseContext (*(TParseContext*)voidParseContext)
     #define YYLEX_PARAM parseContext
    -#define yyerror(msg) parseContext.parserError(msg)
     
    +#define yyerror(ctx, msg) ctx->parserError(msg)
    +
    +
     extern int yylex(YYSTYPE*, TParseContext&);
     
     %}
     
    +%parse-param {glslang::TParseContext* voidParseContext}
    +%lex-param {parseContext}
    +
     %pure_parser  // enable thread safety
     %expect 1     // One shift reduce conflict because of if | else

    but it blows up during linking with undefined ref to yyparse(void*) :

    Code :
    ../glslang/MachineIndependent/libglslang.a(ParseHelper.cpp.o): In function `glslang::TParseContext::parseShaderStrings(glslang::TPpContext&, glslang::TInputScanner&, bool)':
    ParseHelper.cpp:(.text+0x7ef): undefined reference to `yyparse(void*)'
    collect2: error: ld returned 1 exit status
    StandAlone/CMakeFiles/glslangValidator.dir/build.make:93: recipe for target 'StandAlone/glslangValidator' failed
    make[2]: *** [StandAlone/glslangValidator] Error 1
    CMakeFiles/Makefile2:332: recipe for target 'StandAlone/CMakeFiles/glslangValidator.dir/all' failed
    make[1]: *** [StandAlone/CMakeFiles/glslangValidator.dir/all] Error 2
    Makefile:75: recipe for target 'all' failed
    make: *** [all] Error 2
    ./BuildLinuxCMake.sh: line 7: ./StandAlone/glslangValidator: No such file or directory
    ~/glslang


    yyparse is present in compiled object code:

    [dk@sirius glslang.dir]$ objdump -t -C gen_glslang_tab.cpp.o | grep yyparse
    0000000000000137 g F .text 000000000000d5a7 yyparse(glslang::TParseContext*)

    but with wrong type



    edit: OK, managed to build it with following patches:

    Code :
    [dk@sirius glslang]$ svn diff
    Index: glslang/MachineIndependent/ParseHelper.cpp
    ===================================================================
    --- glslang/MachineIndependent/ParseHelper.cpp    (revision 25716)
    +++ glslang/MachineIndependent/ParseHelper.cpp    (working copy)
    @@ -43,7 +43,7 @@
     
     #include "preprocessor/PpContext.h"
     
    -extern int yyparse(void*);
    +extern int yyparse(glslang::TParseContext*);
     
     namespace glslang {
     
    @@ -143,7 +143,7 @@
     {
         currentScanner = &input;
         ppContext.setInput(input, versionWillBeError);
    -    yyparse((void*)this);
    +    yyparse(this);
         finalErrorCheck();
     
         return numErrors == 0;
    Index: glslang/MachineIndependent/Scan.cpp
    ===================================================================
    --- glslang/MachineIndependent/Scan.cpp    (revision 25716)
    +++ glslang/MachineIndependent/Scan.cpp    (working copy)
    @@ -42,8 +42,8 @@
     
     #include "../Include/Types.h"
     #include "SymbolTable.h"
    +#include "ParseHelper.h"
     #include "glslang_tab.cpp.h"
    -#include "ParseHelper.h"
     #include "ScanContext.h"
     #include "Scan.h"
     
    Index: glslang/MachineIndependent/glslang.y
    ===================================================================
    --- glslang/MachineIndependent/glslang.y    (revision 25716)
    +++ glslang/MachineIndependent/glslang.y    (working copy)
    @@ -97,15 +97,21 @@
     
     %{
     
    +
     #define YYPARSE_PARAM voidParseContext
     #define parseContext (*(TParseContext*)voidParseContext)
     #define YYLEX_PARAM parseContext
    -#define yyerror(msg) parseContext.parserError(msg)
     
    +#define yyerror(ctx, msg) ctx->parserError(msg)
    +
    +
     extern int yylex(YYSTYPE*, TParseContext&);
     
     %}
     
    +%parse-param {glslang::TParseContext* voidParseContext}
    +%lex-param {parseContext}
    +
     %pure_parser  // enable thread safety
     %expect 1     // One shift reduce conflict because of if | else
    Last edited by kowal; 03-06-2014 at 08:14 AM. Reason: new info

  3. #3
    Newbie Newbie
    Join Date
    Mar 2014
    Posts
    2
    Can you use version 2.7?

    I get:

    $ bison -V
    bison (GNU Bison) 2.7.12-4996

    $ sudo apt-get install bison
    bison is already the newest version.

    I'll have a look at the proposed changes and see if they also work on above version. If so, I'll commit them.

    Update: The changes don't work as is on 2.7, but a similar set of changes do (removing the #define of the *_PARAM stuff). That's committed now, as

    "Use more modern bison %parse-param and %lex-param rather than #defined YYPARSE_PARAM and YYLEX_PARAM. This should make it build across a broader range of modern versions of bison, as well as avoid void* and type casting."

    Thanks.
    Last edited by cepheus; 03-07-2014 at 05:20 PM.

  4. #4
    Intern Contributor IneQuation.pl's Avatar
    Join Date
    Aug 2008
    Location
    Gliwice, Poland
    Posts
    69
    Yes, it works now. Thanks a lot!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •