Skip to content

Commit

Permalink
Fix ODR violations
Browse files Browse the repository at this point in the history
On a shared build, these symbols exist in both libglslang.so and
libSPIRV.so, leading to an ODR violation at runtime.
  • Loading branch information
silverclaw authored and arcady-lunarg committed Aug 24, 2023
1 parent f1cb860 commit adfcaba
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
13 changes: 9 additions & 4 deletions glslang/Include/PoolAlloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,16 @@ class TAllocation {
unsigned char* mem; // beginning of our allocation (pts to header)
TAllocation* prevAlloc; // prior allocation in the chain

const static unsigned char guardBlockBeginVal;
const static unsigned char guardBlockEndVal;
const static unsigned char userDataFill;
static inline constexpr unsigned char guardBlockBeginVal = 0xfb;
static inline constexpr unsigned char guardBlockEndVal = 0xfe;
static inline constexpr unsigned char userDataFill = 0xcd;

# ifdef GUARD_BLOCKS
static inline constexpr size_t guardBlockSize = 16;
# else
static inline constexpr size_t guardBlockSize = 0;
# endif

const static size_t guardBlockSize;
# ifdef GUARD_BLOCKS
inline static size_t headerSize() { return sizeof(TAllocation); }
# else
Expand Down
4 changes: 0 additions & 4 deletions glslang/MachineIndependent/Initialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ const bool ARBCompatibility = true;

const bool ForwardCompatibility = false;

// change this back to false if depending on textual spellings of texturing calls when consuming the AST
// Using PureOperatorBuiltins=false is deprecated.
bool PureOperatorBuiltins = true;

namespace {

//
Expand Down
3 changes: 3 additions & 0 deletions glslang/MachineIndependent/Initialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class TBuiltIns : public TBuiltInParseables {
int dimMap[EsdNumDims];
};

// change this back to false if depending on textual spellings of texturing calls when consuming the AST
// Using PureOperatorBuiltins=false is deprecated.
constexpr bool PureOperatorBuiltins = true;
} // end namespace glslang

#endif // _INITIALIZE_INCLUDED_
2 changes: 1 addition & 1 deletion glslang/MachineIndependent/ParseHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
//

#include "ParseHelper.h"
#include "Initialize.h"
#include "Scan.h"

#include "../OSDependent/osinclude.h"
Expand Down Expand Up @@ -2685,7 +2686,6 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
}
}

extern bool PureOperatorBuiltins;

// Deprecated! Use PureOperatorBuiltins == true instead, in which case this
// functionality is handled in builtInOpCheck() instead of here.
Expand Down
10 changes: 0 additions & 10 deletions glslang/MachineIndependent/PoolAlloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,6 @@ TPoolAllocator::~TPoolAllocator()
}
}

const unsigned char TAllocation::guardBlockBeginVal = 0xfb;
const unsigned char TAllocation::guardBlockEndVal = 0xfe;
const unsigned char TAllocation::userDataFill = 0xcd;

# ifdef GUARD_BLOCKS
const size_t TAllocation::guardBlockSize = 16;
# else
const size_t TAllocation::guardBlockSize = 0;
# endif

//
// Check a single guard block for damage
//
Expand Down
4 changes: 2 additions & 2 deletions glslang/MachineIndependent/preprocessor/Pp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,6 @@ namespace {
int op_cmpl(int a) { return ~a; }
int op_not(int a) { return !a; }

};

struct TBinop {
int token, precedence, (*op)(int, int);
} binop[] = {
Expand Down Expand Up @@ -412,6 +410,8 @@ struct TUnop {
{ '!', op_not },
};

} // anonymous namespace

#define NUM_ELEMENTS(A) (sizeof(A) / sizeof(A[0]))

int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, bool& err, TPpToken* ppToken)
Expand Down

0 comments on commit adfcaba

Please sign in to comment.