PDA

View Full Version : Cannot build glslang on Linux



IneQuation.pl
02-25-2014, 08:44 AM
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

kowal
03-06-2014, 06:44 AM
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:



[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*) :



../glslang/MachineIndependent/libglslang.a(ParseHelper.cpp.o): In function `glslang::TParseContext::parseShaderStrings(glslan g::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:



[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

cepheus
03-07-2014, 02:30 PM
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.

IneQuation.pl
03-09-2014, 03:10 AM
Yes, it works now. :) Thanks a lot!